MongoError exception: FieldPath field names may not start with '$' - mongodb

We just migrated our infrastructure on AWS from one account to another.
The mongo version installed on the server is 2.4.9
I am new to MongoDb and faced the following 2 errors when I ran the web app -
{"name":"MongoError","errmsg":"exception: FieldPath field names may not start with '$'.","code":16410,"ok":0}
and
{"name":"MongoError","errmsg":"exception: the $cond operator requires an array of 3 operands","code":16019,"ok":0}
The web app was working on our previous instances. Can anyone point me in the right direction?

Upgrading to the latest mongodb (3.0.2) helped resolve this issue for me.
P.S. - Make sure you kill the mongod process already running using killall -15 instead of pkill -9 as the latter could cause damage.

Related

Why is my mongo command no longer working in Bash?

So mongo was running fine, and then I tried to create a database and a collection. Long story short, the server stopped responding. I thought (after about 6 hours of trying everything else, asking my friends and getting literally nowhere) that maybe I should just uninstall and reinstall mongoDB. Turns out that was a mistake, because now when I try to do the mongo command I get this
$ mongo
bash: /c/Program Files/MongoDB/Server4.4/bin/mongo.exe: No such file or directory
I noticed that there is no "/" between Server and 4.4 --- I think that's the issue, but I have no idea how to fix that. An yes, I have added MongoDB to my system variable path...
What is going on here?
It seems like commands are working now. I guess I just needed to wait like 8 hours!?

Meteor: unexpected mongo exit code null. Restarting. What is this?

The title pretty much says it - when I try to start a newly created meteor app, this appears when starting the proxy and I get the message that the mongo server can't be started.
I created some swap space already (that was mentioned in the only other thread realted to that problem) and even reinstalled it - no further success.
Weird thing is, on my normal laptop this works. The laptop I'm having trouble with is a Pentium III with 1GB RAM, maybe this matters.
Any thoughts? Is the machine too old?
EDIT:
My setup:
Thinkpad T23, PIII 1.13 GHz, 1GB RAM.
Debian Stretch/testing, Linux Kernel 4.1.0-1-686-pae
My log:
[[[[[ ~/Server/sample ]]]]]
=> Started proxy.
Unexpected mongo exit code null. Restarting.
Unexpected mongo exit code null. Restarting.
Unexpected mongo exit code null. Restarting.
Can't start Mongo Server.
This command will reset your database
meteor reset
Have you tried setting your LANG environment variable? As shown in Mongo can't be started when starting Meteor, which explains the following:
<snip>
If you get an error like
terminate called after throwing an instance of 'std::runtime_error'
what(): locale::facet::_S_create_c_locale name not valid
Unexpected mongo exit code null. Restarting.
...
Can't start Mongo server.
the solution is very easy but not easy to know:
You have not set your LANG settings in current shell.
Set your LANG env vars before starting meteor manually or permanent in your profile settings.
export LANG=C
export LC_ALL=C
Now you can run meteor and it should be able to start the mongo development process.
</snip>
It might be worth trying. HTH.
I think your suspicion about the machine being too old is correct.
You can reproduce the same error by trying to build a meteor app on a digitalocean droplet with 512mb of ram. On an otherwise identical machine with 8gb of ram, the app builds without error.
Just remove the #w=majority param in your connection string

Unexpected mongo exit code 100. Restarting

I was trying to run Meteor on my VPS and I was getting this error:
Unexpected mongo exit code 100. Restarting.
Unexpected mongo exit code 100. Restarting.
Unexpected mongo exit code 100. Restarting.
Can't start Mongo server.
MongoDB had an unspecified uncaught exception.
This can be caused by MongoDB being unable to write to a local database.
Check that you have permissions to write to .meteor/local. MongoDB does
not support filesystems like NFS that do not allow file locking.
I have figured out that the problem is in my user permissions or something like that. It works very smoothly when I try to run meteor with root access. If I try to run meteor with my "custom" user, it fails. Even though I grant him sudo privileges as listed on DigitalOcean. Why is it so? What is the problem behind?
I am on Ubuntu 14.04.1 LTS. Meteor is version 0.8.3 and I am using MongoDB coming with Meteor. I do not have seperated instalation of MongoDB.
Update: Basicly I have found the problem but I still do not now what is causing the problem. I am on DigitalOcean VPS. If I run Meteor over SSH, it fails. If I run Meteor on web Console Access, it works. I do not get it.
Answer https://stackoverflow.com/a/15752736 helped me to find out that Mongo doesn't want to start without properly set locale.
Try to run export LC_ALL="en_US.UTF-8" command before meteor command.
WARNING: This deletes the database and all of the application's data.
rm -rf .meteor/local
Solved it for me when none of the above solutions did.
I would guess that the custom user you created cannot remove the mongod.lock file due to insufficient premissions.
Also check that you have space on your HD, That was my problem.

MongoDB unauthorized users can create databases

We have an old MongoDb 2.2.6 deployment and lately we were requested to introduce anonymous user blocking to the Db. I followed the MongoDb tutorials and created an authentication user first and started the mongod with
--auth
parameter.
Then after login, I could not execute any db related commands except for the
use << db >>
. Everything was perfect. But then I tried issuing
use <<< some_junk_db_name >>
without authentication and then issued
db.some_collection.find()
command. Mongodb correctly raised an exception but later when I checked, that DB was there.
Is this a bug with MongoDb 2.2.6 or am I missing something here ?
This is a reported Bug with the number 2080 and the ticket is still not fixed. The last comment, May 17 2013, from a MongoDB Inc. member says that the Bug is still existing in the 2.4 version of MongoDB.
In Version 3.4 the Bug was no longer reproducable.

Mongo vs Mongoid - why can 1 connect and the other not?

I have a rails-app which uses both mongoid and mongo. I use mongoid for my own models, and I use mongo because I have ruote with a ruote-mon storage.
In production however; I get
Mongo::ConnectionFailure: Failed to connect to a master node at localhost:27017
when I try to connect to the ruote storage. Even when I just do Mongo::MongoClient.new
Steps I have taken so far to try to resolve this:
I have made my mongodb an explicit master by setting master = true in /etc/mongod.conf
There are no $ENV variables set that could intervene with Mongo::MongoClient.new (double checked)
I have tried to connect using Mongo::MongoClient.new(:slave_ok => true) - same error
I have restarted my mongo database several times (w/o success).
I have checked my firewall settings and I can connect to localhost:27017 with telnet (as said, the mongoid documents can be fetched and stored w/o issue)
I am out of my wits... Any suggestions?
The reason this happened is because we were sending queries with meta operators ($query, $orderby, etc...) for the ismaster command during a connect. This command's output is used to determine whether you are connected to a primary or not and would fail because very old versions of mongodb don't support the use of meta operators.
This fix will be in version 1.8.2 of the gem but I strongly encourage anyone who is still running pre-1.8 versions of mongodb to upgrade. 2.0 is the current legacy release as of the time of this post and even 1.8 is no longer widely supported.
As jmettraux mentioned you can find more details about this on the MongoDB project Jira under Ruby-525
please look at: https://jira.mongodb.org/browse/RUBY-525
Should be fixed by the 1.8.2 mongo gem.