[JAVA-2079] collectionExists returns false although collection really exists Created: 07/Jan/16  Updated: 07/Jan/16  Resolved: 07/Jan/16

Status: Closed
Project: Java Driver
Component/s: Query Operations
Affects Version/s: 3.2.0
Fix Version/s: None

Type: Bug Priority: Critical - P2
Reporter: Frank Becker Assignee: Unassigned
Resolution: Cannot Reproduce Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Server: Ubuntu 14.04 with MongoDB 3.2
Client: Mac OS X 10.9 with Java Driver version 3.2 (Java 8)



 Description   

Called "db.createCollection(COLLECTION_LOGS, options)" throws "CommandFailureException" because COLLECTION_LOGS already exists.

In the Exception handler the call to "collectionExists" returns false, but the collection really exists:
// Double check
if (!db.collectionExists(COLLECTION_LOGS))

{ // The collection is not there so it was some other issue throw e; }

 Comments   
Comment by Jeffrey Yemin [ 07/Jan/16 ]

OK, based on your previous comment I'm closing this, but if you are able to reproduce it in the future please comment and we can re-open.

Comment by Frank Becker [ 07/Jan/16 ]

It's one standalone MongoDB - extreme minimum installation on Ubuntu14. Just created the /data/db directory and started mongod in the Terminal. So it's the smallest thing you can do I think. I also only use one server address, but have three databases open in parallel (data, logs and configuration)

What (and why) I did:
I have a server and at least one client Tomcat server that communicate over the MongoDB. I used MongoDB 2.6 through to 3.0.8 with Java driver version 2.12.2
Another developer installed MongoDB 3.2 and experienced connection problems when the server or client started and the collection exists.
So I checked the compatibility matrix and upgraded to Java driver 3.2.0: switched the exception (MongoCommandException -> CommandFailureException) debugged the code and it gave me the issue when tried to connect to server 3.2. Using a server 3.0.8 everything worked. That's why I created the ticket.

Comment by Jeffrey Yemin [ 07/Jan/16 ]

Hi Frank,

Before we close this out, please let me know:

  • are you connected to a sharded cluster, a replica set, or a standalone MongoDB cluster?
  • How many server addresses are in the seed list that you create your MongoClient instance with?
Comment by Frank Becker [ 07/Jan/16 ]

I am sorry.

I tried to create a "minimum example" to reproduce - but this one worked as it should. So I wiped my Maven .m2 repository and all the target directories and re-run Maven on my project. Now my project also worked as it should. Maybe there were some old libs of the former driver left somewhere in the build path.

I can't reproduce any longer and apologise. Can be closed.

Comment by Ross Lawley [ 07/Jan/16 ]

Hi fkbecker,

That sounds off, can you provide the following:

  • The full CommandFailureException message
  • The value of COLLECTION_LOGS
  • The value of options
  • The output from running db.<collectionName>.stats() from the shell

With that information we should be able to ascertain what is happening in this case.

Ross

Generated at Thu Feb 08 08:56:16 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.