[SERVER-15377] Mongo.getDatabaseNames() occasionally throws CommandFailureException - "exception: can't open database in a read lock." Created: 24/Sep/14  Updated: 10/Dec/14  Resolved: 24/Sep/14

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Adam B Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-14651 listDatabases command errors under hi... Closed
Operating System: ALL
Steps To Reproduce:

We see this periodically in our unit tests, where we have code that looks like:

foreach (String dbName in mongo.getDatabaseNames()){
mongo.getDatabase(dbName).drop();
}

Participants:

 Description   

We have been having some problems where our mongo connection fails to allow us to get the database names from the DB.

We call the method:

com.mongodb.Mongo.getDatabaseNames()
And 1 out of 100 times, it throws the following exception:

Caused by: com.mongodb.CommandFailureException:

{ "serverUsed" : "localhost:27017" , "errmsg" : "exception: can't open database in a read lock. if db was just closed, consider retrying the query. might otherwise indicate an internal error" , "code" : 15927 , "ok" : 0.0}

at com.mongodb.CommandResult.getException(CommandResult.java:76)
at com.mongodb.CommandResult.throwOnError(CommandResult.java:131)
at com.mongodb.Mongo.getDatabaseNames(Mongo.java:397)
Looking at the mongo code, the database is the internal admin database

public List<String> getDatabaseNames(){

BasicDBObject cmd = new BasicDBObject();
cmd.put("listDatabases", 1);

>>CommandResult res = getDB(ADMIN_DATABASE_NAME).command(cmd, getOptions());
res.throwOnError();
This database is not being deleted, but there are several other databases that could be deleted around this time.

Has anyone else had this problem?

reposted from StackOverflow:
http://stackoverflow.com/questions/25988180/mongo-getdatabasenames-occasionally-throws-commandfailureexception?noredirect=1#comment40757879_25988180



 Comments   
Comment by Adam B [ 24/Sep/14 ]

Thanks

Comment by J Rassi [ 24/Sep/14 ]

Hi,

I'm resolving this ticket as a dup of SERVER-14651. Feel free to add yourself as a watcher to that ticket.

~ Jason Rassi

Comment by Adam B [ 24/Sep/14 ]

The suggestion over there was to file a ticket. At any rate, filed... and I'll update over there accordingly.

Generated at Thu Feb 08 03:37:51 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.