system.profile collection empty even though mongod started with profile level 2 - mongodb

Specs: Win10 64bit, MongoDB v3.6.3
I'm having trouble profiling MongoDB. I have some slow queries for which I wanted to see more details, so I started mongod with --profile 2. I checked with MongoDB console if the profiler was enabled with db.getProfilingLevel() which reports 2 correctly.
However, after running some queries from my application (.Net, official driver) which I'm sure are working as I get correct results, the system.profile collection is still empty (db.system.profile.findOne() returns null).
I'm currently out of ideas what could be the problem and google searches didn't lead to any interesting results. Sometimes after a while the mongod contains this output, but it's not generated in response to any query:
.sessions: CannotImplicitlyCreateCollection: request doesn't allow collection to be created implicitly
2018-04-18T20:10:47.249+0200 I - [thread53] Creating profile collection: config.system.profile
2018-04-18T20:10:47.250+0200 W - [thread53] Caught Assertion while trying to profile update against config.system.sessions: CannotImplicitlyCreateCollection: request doesn't allow collection to be created implicitly

Related

MongoDB. Studio3T. Mongoose. Hyper returns empty array. Pluralization in naming most likely not the issue

I ran mongod in Hyper Terminal.
I established connection with Studio3T and MongoDB. And created collection and documents in Studio3T. The database, collection, and documents appear in Studio3T and MongoDB. In Hyper the database and collection exist, but the documents are not there. Any idea why?
I have consulted stackoverflow and could not find the answer in the resources listed (sorry if I missed something):
Mongoose always returning an empty array NodeJS
Model.find() returns empty in mongoose
Mongoose always return empty array?
What are naming conventions for MongoDB?
MongoDB:
Mongosh in Hyper:
Studio3T:
Code in Atom:
Run code and result in Hyper:
I started mongod and connected to the MongoDB server locally. My application code pointed to the following:
mongoose.connect("mongodb://localhost:27017/wikiDB");
The above is local. But my data is on the cloud-based MongoDB Atlas Cluster. I shouldn't need to run mongod. So, I changed my application code:
mongoose.connect("mongodb+srv://admin-yourname:password#blahblahblah.mongodb.net/wikiDB");
where yourname AND password AND blahblahblah are specific to the coder.
Now my application code points to the Atlas Cluster where my data is.
Summary:
My data is on the cloud-based Atlas Cluster.
To see my data on the Atlas Cluster from the command line, I "Connect with the MongoDB Shell" and run the connection string that MongoDB provides in the command line. Now I see my data in the command line.
To see my data on the Atlas Cluster when I run my code, I use "Connect your application" and place the connection string that MongoDB provides in my code (the mongoose.connect(....) ). Now when I run my code, I can see my data in my browser or command line if I console.log it.
If you are in the command line and run mongod in one tab, and mongosh in another, and use db.articles.find(), then nothing will appear but an empty array. That's because the data is on the cloud-based Atlas cluster. In this instance, you are viewing things locally.
If your application code points to your local MongoDB server (ran mongod in one tab, mongosh in another), then when you run the code you will see nothing but an empty array because the data is on the cloud-based Atlas cluster. In this instance, you are viewing things locally.

Mongodb shell command not returning accurate "deletedCount" upon succesful completion?

I have a mongoDB instance running with two collections in it. I'm using the nodejs driver (version 3.2.4). I am also using mongoose (version 5.5.9) but as I'm messing around and learning, I've been issuing a few commands directly from the mongoDB shell (rather than through node). My shell version is 4.0.9. I should note that this occurred when issuing the command from the built-in terminal in vscode.
I used (from the shell):
db.myCollection.deleteMany({ field: 'value' })
to delete a few documents I had in the collection. Per the documentation I expected a document with acknowledged: <boolean> and deletedCount: <number> to be returned pending a successful operation. I did get a document back that says:
{
"acknowledged": true,
"deletedCount": 0
}
However, using Robo 3T I can see that the documents I wanted to delete are definitely deleted. What gives?
UPDATE:
I've tried several things, including inserting documents matching those that I deleted, and then deleting them again, as well as issuing the commands from my standard terminal shell (not the one in vscode). I am now unable to replicate this issue. Nothing super important, especially given that I can't replicate it - but I was wondering if I had somehow issued the commands incorrectly or there was some caveat that wasn't documented clearly.
edits: specificity, added versions, update

Mongodb 3.0.15 on Ubuntu 14.04 - data disappeared - possible causes?

I have been logging bitcoin order books and trades for the past 20 days in mongodb. 1 database [bitmicro], 1 collection for trades, 1 collection for books.
now suddently all the data is gone and the logger has started from scratch since yesterday.
The mongo log doesnt show any entries since October. And a new database appeared called Warning exactly when the data loss happened
> show dbs
Warning 0.078GB
bitmicro 0.453GB
local 0.078GB
After some reading it might be the case, that the filesize of the collection became too big and ubuntu deleted it?
Since the log /var/log/mongodb/mongod.log doesnt show any entries since starting the server, how can I find out what happened?
the existence of the Warning database implies that your database was accessed by a malicious 3rd party, and your database is exposed to the internet without any authentication.
https://docs.mongodb.com/manual/administration/security-checklist/

Mongodb not listing collections when connecting remotely from CentOS

Mongo server: Windows 10 (host)
client: CentOS 6.2, a virtual box vm on windows 10 host. This is actually a cloudera quick start vm.
Issue:
mongodb connects to the remote server (from CentOS to Windows) via terminal, lists the databases fine, but 'show collections' just returns blank. That said, the collections are accessible because I can query any collection and the count also gives me the correct results.
On the other hand, I have connected to the same mongo server from IntelliJ and it shows all the collections just fine.
Just curious as to why this is happening.. Any comments?
Side Note: is there a mongodb command to count the number of collections in a database?
Thanks
_Vamsi
Make sure you are using the database you want to show the collections for. You may be using a database that doesn't have any collections.
> use desiredDatabase
> show collections
If the list is still empty, try signing in with an admin user account. The user needs to be able to perform the listCollections action. The dbAdmin role includes the listCollections action.
To get the count you can use the getCollectionNames function which returns an array and you can get the length from that.
> db.getCollectionNames().length

User field missing in system.profile collection when connecting with Mongos

We have a MongoDB cluster and clients connecting to it through a Mongos instance. The individual mongo(s) in the cluster are all running with --auth, and the Mongo use a --keyfile when communicating with them. We are profiling slow queries but are not getting the user names on queries that go through Mongo.
To make it clearer:
If I connect directly to one of the Mongo, authenticate, and run a query, then I can look in the system.profile collection afterwards, and the user field will be populated with my username.
If I connect through mongos, authenticate, and run a query, then the system.profile collection contains profiling info about the query, but the user field is blank.
The authentication is required, I can't run a query through Mongo without authenticating first, but the user name just doesn't seem to be included in the profiling info, and we'd really like to be able to see it.
Any ideas? Any alterations I can make to our configuration?
Just to actually add an answer:
As Ren stated in his comment, he filed a ticket, as this is related to a bug.