Error: database names cannot contain the character ' ' - mongodb

Notes before: this is updated, and there is a question with the name 'error: database names cannot contain the character '.' but this is with a space or a null character, not a dot! I am not sure if that could be a major difference, but apart from that question, the answer supposed there did not help me further. Also, I use Windows 7 (32 bits (not the best thing for mongodb, I know) and I made the description a bit more detailed).
To the point: I wanted to start meteor again for the first time after a couple of days (everything worked fine before) and suddenly this error appeared:
W20150803-18:44:47.168(2)? (STDERR) C:\Users\Laptop\AppData\Local\.meteor\packag
es\meteor-tool\1.1.3\mt-os.windows.x86_32\dev_bundle\server-lib\node_modules\fib
ers\future.js:245
W20150803-18:44:47.168(2)? (STDERR)
throw(ex);
W20150803-18:44:47.168(2)? (STDERR)
^
W20150803-18:44:47.168(2)? (STDERR) Error: database names cannot contain the cha
racter ' '
W20150803-18:44:47.169(2)? (STDERR) at validateDatabaseName (C:\Users\Laptop
\AppData\Local\.meteor\packages\mongo\1.1.0\npm\node_modules\mongodb\lib\mongodb
\db.js:235:59)
W20150803-18:44:47.169(2)? (STDERR) at new Db (C:\Users\Laptop\AppData\Local
\.meteor\packages\mongo\1.1.0\npm\node_modules\mongodb\lib\mongodb\db.js:97:3)
W20150803-18:44:47.169(2)? (STDERR) at connectFunction (C:\Users\Laptop\AppD
ata\Local\.meteor\packages\mongo\1.1.0\npm\node_modules\mongodb\lib\mongodb\mong
o_client.js:275:29)
W20150803-18:44:47.169(2)? (STDERR) at Function.MongoClient.connect (C:\User
s\Laptop\AppData\Local\.meteor\packages\mongo\1.1.0\npm\node_modules\mongodb\lib
\mongodb\mongo_client.js:345:5)
W20150803-18:44:47.170(2)? (STDERR) at Function.Db.connect (C:\Users\Laptop\
AppData\Local\.meteor\packages\mongo\1.1.0\npm\node_modules\mongodb\lib\mongodb\
db.js:2094:23)
W20150803-18:44:47.170(2)? (STDERR) at new MongoConnection (packages/mongo/m
ongo_driver.js:173:1)
W20150803-18:44:47.170(2)? (STDERR) at new MongoInternals.RemoteCollectionDr
iver (packages/mongo/remote_collection_driver.js:4:1)...
W20150803-18:44:47.171(2)? (STDERR) at Object.<anonymous> (packages/mongo/re
mote_collection_driver.js:38:1)
W20150803-18:44:47.171(2)? (STDERR) at Object.defaultRemoteCollectionDriver
(packages/underscore/underscore.js:750:1)
W20150803-18:44:47.171(2)? (STDERR) at new Mongo.Collection (packages/mongo/
collection.js:98:1)
A database name being empty while I haven't created any database in the meantime left me in utter darkness since then.
I thought it had to do with one specific project I tried to run (that project already had a load of issues by setting it up, but in the end it worked anyway), but I hadn't changed anything in there, neither did I change any other project. What made me more confused, is that I got this same error on every single other project I have tried to start.
After a while, I rebooted, and the projects started again, but the actual project where all of this began, failed again, this time showing an old known error:
Unexpected mongo exit code 14. 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.
The original solution to that, was running this in CMD:
"c:\mongodb\bin\mongod.exe" --port 27017 --dbpath "C:\Users\Laptop\TheDatabaseFolder\rs2" --replSet rs2 --smallfiles --setParameter failIndexKeyTooLong=false //note: this had to be done due to 32 bit issue
rs.initiate()
This still gave the same 'cannot write' error although the CMD showed that writing was permitted. Finally I did this:
set MONGO_URL=mongodb://localhost:27017/meteor
Then I fired meteor with a specific config file (due to packages failing to load)
meteor --settings ../config/development/settings.json.dist
And there was the main problem with the database name containing a space or null character again.
In general: what is the most efficient way to get rid of this problem? Why could this have been suddenly sneaking into every project to make them fail? And, where is this 'packages/mongo/collection.js' (in general 'packages/mongo' as such) located anyway? I cannot find it at all...
Thanks in advance.

I would get this error every time I restarted my computer and then tried to make any sort of request. It appears to be something with the favicon.ico file. I'm just using local host to test out API calls so I obviously did not have this file. I'm pretty sure my requests were reading this as a database name, which would have the illegal '.' character. I finally added:
app.get('/favicon.ico', function(req, res) {
res.sendStatus(204);
});
And now everything seems to work again. There is a 204 response for the favicon.ico request every time I put through a request, but it works.

Related

Command "currentOp" returned error "Invalid collection name specified 'admin.$cmd.sys.inprog'"

I just installed MongoDB Compass and connected to my DB. While watching the performance for around 10s I get the following error Command "currentOp" returned error "Invalid collection name specified 'admin.$cmd.sys.inprog'" and soon after that this one Command "serverStatus" returned error "connection 19 to 127.0.0.1:29247 timed out" Can anyone explain to me what this means and how to solve it?
Thanks

Strange error when initializing Postgres database in FeathersJS

I am converting a FeathersJS system from MySQL to Postgres and facing some problems.
After changing the connection string
"mysql": "mysql://user:password#server:port/database"
to
"postgres": "postgres://user:password#server:port/database"
at config/default.json, I changed the dialect from mysql to pg at feathers/sequelize.js.
But when I started with npm run dev I got the following JSON error message, never seen before.
{
"_bitField":18087936,
"_fulfillmentHandler0":{
"name":"SequelizeConnectionError",
"parent":{
"name":"error",
"length":93,
"severity":"FATAL",
"code":"3D000",
"file":"postinit.c",
"line":"855",
"routine":"InitPostgres"
},
"original":{
"name":"error",
"length":93,
"severity":"FATAL",
"code":"3D000",
"file":"postinit.c",
"line":"855",
"routine":"InitPostgres"
}
},
"name":"SequelizeConnectionError",
"parent":{
"name":"error",
"length":93,
"severity":"FATAL",
"code":"3D000",
"file":"postinit.c",
"line":"855",
"routine":"InitPostgres"
},
"original":{
"name":"error",
"length":93,
"severity":"FATAL",
"code":"3D000",
"file":"postinit.c",
"line":"855",
"routine":"InitPostgres"
}
}
After researching a bit with no success, here I am to ask if someone has ever seen this message.
I already tried the dialect as pg and postgres at feathers/sequelize.js, just to check if it would make any difference, but it didn't.
A true beginner error! My fault!
When I created the Postgres (Docker) container, I forgot to create the database itself!
I created the role and gave it the needed permissions, but forgot to create the database corresponding to my connection string.
The Postgres error code mentioned in my question (3D000) corresponds to invalid_catalog_name, i.e., no database corresponding to the connection string.
One may easily check this at Postgres documentation, but I was mistakenly looking for this error code at FeathersJS documentation.

sails js - error when clean the collections in start up

In my sails application I edit the config/models.js file as follows to clean the database when lifting the application.
migrate: 'drop',
connection: 'mongodb'
But when I try to run the application it displays the following error.
A hook (`orm`) failed to load!
error: Error (E_UNKNOWN) :: Encountered an unexpected error
MongoError: Index with name: _id_ already exists with different options
I am using sails version 0.10.5 ,any kind of help would be appreciated.
same here, when you have an error to the model the orm crashes, at least you have the error, sometimes with mysql you don't even have the error
the issue was, in some of my application's model files I have added following to attributes list.
attributes: {
_id: {
type: 'string',
unique: true
}
}
since I have added unique true to the attribute, it causes an error when I try to clean the collections on start up. more information about this issue can be found on Index already exists with different options error while using createIndex() in latest MongoDB java driver

Meteor deploying on Modulus

Modulus deployments is perfect without any problems, but is not working. I have created a database on Modulus with the same name on the Meteor app.
http://wikimicroscope-13216.onmodulus.net/
Console log in Modulus:
Error: URL must be in the format mongodb://user:pass#host:port/dbname
at Error (<anonymous>)
at exports.parse (/mnt/data/2/node_modules/mongodb/lib/mongodb/connection/url_parser.js:15:11)
at Function.MongoClient.connect (/mnt/data/2/node_modules/mongodb/lib/mongodb/mongo_client.js:164:16)
at Function.Db.connect (/mnt/data/2/node_modules/mongodb/lib/mongodb/db.js:2035:23)
at new MongoConnection (packages/mongo-livedata/mongo_driver.js:151)
at new MongoInternals.RemoteCollectionDriver (packages/mongo-livedata/remote_collection_driver.js:4)
at Object.<anonymous> (packages/mongo-livedata/remote_collection_driver.js:44)
at Object.defaultRemoteCollectionDriver (packages/underscore/underscore.js:750)
at new Meteor.Collection (packages/mongo-livedata/collection.js:72)
at packages/accounts-base/accounts_common.js:122
[2014-05-23T16:02:46.435Z] Application CRASH detected. Exit code 8.
[2014-05-23T16:02:47.472Z] Application restarted.
I have set mongo_url and root_url before. Here are my environment variables:
CONNECTION STRINGS
MONGO URI
mongodb://<user>:<pass>#novus.modulusmongo.net:27017/iZ3anope
MONGO CONSOLE
mongo novus.modulusmongo.net:27017/iZ3anope -u <user> -p <pass>
I have deployed with different node versions like v0.10.25, v0.10.28. It is not working.
Beside on the browser there is the messages:
!Unable to connect to any application instances.!
and in the console inspector in Chrome / local store I find a message like this:
BiDefender_BLock {"verdict":"TRACKER","hitList":""}
Thanks!
You need to fill in <user>:<pass> with the username and password you set for the database.
I had this error and solve it by executing:
modulus env set MONGO_URL "mongodb://myUser:myPass#proximus.modulusmongo.net:27017/6sd54f5f?autoReconnect=true&connectTimeoutMS=60000"
instead of:
modulus env set MONGO_URL "mongodb://myUser:myPass#proximus.modulusmongo.net:27017/6sd54f5f ?autoReconnect=true&connectTimeoutMS=60000"
If you see, I added an extra space before the '?'
When I look at logs in modulus web interface, it told me database name cannot contains character ' ' (space)
I also just had this problem and fixed it by restarting my app

Pymongo permissions issue for safe inserts

I have an instance of Mongo running and can connect and authenticate successfully to a database. I can bulk insert records using collection.insert([list of records to insert]).
However, when I add safe=True to ensure that the records are inserted, like the following command, I get the error below, which seems like a permissions issue. How can I fix this?
collection.insert(records_to_insert, safe=True)
File "/.../python2.6/site-packages/pymongo/collection.py", line 270, in insert
check_keys, safe, kwargs), safe)
File "/.../python2.6/site-packages/pymongo/connection.py", line 732, in _send_message
return self.__check_response_to_last_error(response)
File "/.../lib/python2.6/site-packages/pymongo/connection.py", line 684, in __check_response_to_last_error
raise OperationFailure(error["err"])
pymongo.errors.OperationFailure: unauthorized
You are running in MongoDB in auth mode and did not provide the related the related credentials upon connection time. Calling db.authenticate(...) should be your friend.