CANT find collection $cmd.sys.inprog

402 views
Skip to first unread message

majeed said

unread,
Apr 20, 2016, 9:16:59 AM4/20/16
to mongodb-user
Hi,

 how can i get using java the collection "$cmd.sys.inprog"

when i run the following :
mongodClient.getDatabase("admin").getCollection("$cmd.sys.inprog").find(new Document("op", "command"));

got the following exception:

com.mongodb.MongoQueryException: Query failed with error code 73 and error message 'Invalid collection name: admin.$cmd.sys.inprog' on server **********.com:27017


why its invalid since i can run successfully the following command with results:

mongodClient.getDatabase("admin").runCommand(new Document("currentOp", Boolean.TRUE));


please advise.

Regards,
Majeeed

Wan Bachtiar

unread,
May 5, 2016, 8:38:41 PM5/5/16
to mongodb-user

com.mongodb.MongoQueryException: Query failed with error code 73 and error message ‘Invalid collection name: admin.$cmd.sys.inprog’ on server **.com:27017

Hi Majeed,

The find() command introduced in MongoDB v3.2, that is used by MongoDB Java Driver v3.2.x does not allow querying on the system collection. You could also observe this behaviour via mongo shell by executing db.$cmd.sys.inprog.find() in v3.2:

> db.$cmd.sys.inprog.find()
2016-05-06T10:01:47.893+1000 I NETWORK  [thread1] DBClientCursor::init call() failed
Error: error doing query: failed

Please use currentOp() command instead, as you have noticed:

mongoClient.getDatabase("admin").runCommand(new Document("currentOp", Boolean.TRUE));

See MongoDB Java Driver: running a command for more info.

Kind Regards,

Wan.

Reply all
Reply to author
Forward
0 new messages