[JAVA-793] Race condition in com.mongodb.DBTCPConnector#authenticate method Created: 26/Mar/13 Updated: 28/Jul/14 Resolved: 08/Apr/13 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | Connection Management |
| Affects Version/s: | 2.11.0 |
| Fix Version/s: | 2.11.1, 2.12.0 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Jeffrey Yemin | Assignee: | Jeffrey Yemin |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||
| Description |
|
It's possible for _masterPortPool to be null in the call to MyPort.get from DBTCPConnector.authenticate, causing this mis-leading exception to be thrown:
This can be reproduced reliably when constructing a MongoClient with a List of mongos nodes and a call to DB.authenticate is the first operation on the MongoClient (as is typical). This issue can be worked around by replacing the call to DB.authenticate with a call to the MongoClient constructor that takes a List<MongoCredential>: http://api.mongodb.org/java/current/com/mongodb/MongoClient.html#MongoClient(java.util.List, java.util.List, com.mongodb.MongoClientOptions). |
| Comments |
| Comment by Jeffrey Yemin [ 27/Mar/13 ] |
|
No problem. We'll likely wait a little while before cutting 2.11.1, just in case any other high priority bugs come through. |
| Comment by Chris Curtin [ 27/Mar/13 ] |
|
That worked. No more errors while authenticating. Quick query/insert tests also worked okay. Thanks for the fast turn around! |
| Comment by Jeffrey Yemin [ 27/Mar/13 ] |
|
Can you test out a new build with a fix for this issue? You can get it here: |
| Comment by auto [ 27/Mar/13 ] |
|
Author: {u'date': u'2013-03-27T17:39:12Z', u'name': u'Jeff Yemin', u'email': u'jeff.yemin@10gen.com'}Message: |
| Comment by auto [ 27/Mar/13 ] |
|
Author: {u'date': u'2013-03-27T17:39:12Z', u'name': u'Jeff Yemin', u'email': u'jeff.yemin@10gen.com'}Message: |
| Comment by Chris Curtin [ 27/Mar/13 ] |
|
Yes, the servers are mongos processes. I've tested with both a single server and a set of servers and the same problem occurs. Is there a debug level or something I can turn on to get more details? |
| Comment by Jeffrey Yemin [ 27/Mar/13 ] |
|
Hi Chris, Just to confirm: the list of servers you are providing are a list of mongos nodes, not a list of replica set members, correct? I want to make sure there's not something wrong with the discovery process. |
| Comment by Chris Curtin [ 27/Mar/13 ] |
|
First, the error occurs immediately, not after 10 seconds as suggested in the mailing list thread. Here is the stack of running threads. First is when I successfully auth using the MongoClient(List<ServerAddress> seeds, List<MongoCredential> credentialsList, MongoClientOptions options) as suggested in the mailing list. Second is when I use DB.authenticate which fails. Both cases are thread dumps from IntelliJ when I set a 'sleep' as the last thing in the main() so I could capture the threads. Success: MongosStatus:MongosUpdater@361 daemon, prio=5, in group 'main', status: 'SLEEPING' MongoCleaner516992923@303 daemon, prio=5, in group 'main', status: 'SLEEPING' Attach Listener@620 daemon, prio=5, in group 'system', status: 'RUNNING' Signal Dispatcher@621 daemon, prio=9, in group 'system', status: 'RUNNING' Finalizer@622 daemon, prio=8, in group 'system', status: 'WAIT' Reference Handler@623 daemon, prio=10, in group 'system', status: 'WAIT' main@1, prio=5, in group 'main', status: 'RUNNING' Failure: MongosStatus:MongosUpdater@363 daemon, prio=5, in group 'main', status: 'SLEEPING' MongoCleaner1751161119@299 daemon, prio=5, in group 'main', status: 'SLEEPING' Attach Listener@370 daemon, prio=5, in group 'system', status: 'RUNNING' Signal Dispatcher@371 daemon, prio=9, in group 'system', status: 'RUNNING' Finalizer@372 daemon, prio=8, in group 'system', status: 'WAIT' Reference Handler@373 daemon, prio=10, in group 'system', status: 'WAIT' main@1, prio=5, in group 'main', status: 'RUNNING' |