[JAVA-1635] Authentication can initially fail when connecting to a replica set when seed list host names do not match replica set host names Created: 28/Jan/15  Updated: 29/Jan/15  Resolved: 28/Jan/15

Status: Closed
Project: Java Driver
Component/s: Cluster Management
Affects Version/s: None
Fix Version/s: 2.13.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


 Description   

This bug was introduced recently in 2.13 when the driver added support for dynamically determining which authentication mechanism to use when none is provided. Consider the following sequence of events:

  • Replica set created with host names a, b, c
  • MongoClient created with seed list a1, b1, c1
  • Application thread executes an query against a secondary
  • Application thread waits for a secondary
  • Monitor thread notifies that a1 is secondary
  • Application thread selects the a1 server
  • Application thread gets a connection to a1
  • Monitor thread notifies that b1 is primary, and hosts list is actually a, b, c. So a1, b1, c1 are removed from the cluster description
  • Application thread tries to get a1's server description from the cluster description, assuming that it must still be there, but as it's been removed, it gets null.

Result is:

 
java.lang.NullPointerException
	at com.mongodb.DBPort.authenticate(DBPort.java:367)
	at com.mongodb.DBPort.checkAuth(DBPort.java:402)
	at com.mongodb.DBTCPConnector.innerCall(DBTCPConnector.java:289)
	at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:269)

Workaround:

Use the same host names in the MongoClient seed list as are used in the replica set configuration



 Comments   
Comment by Jeffrey Yemin [ 29/Jan/15 ]

2.13.0 has been released. Closing issue.

Comment by Githook User [ 29/Jan/15 ]

Author:

{u'username': u'jyemin', u'name': u'Jeff Yemin', u'email': u'jeff.yemin@10gen.com'}

Message: Improve the error handling in DBPort.ensureOpen when calling the buildInfo command

JAVA-1635
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/56e903737f6deadbdabef47d243211adf6304b98

Comment by Githook User [ 28/Jan/15 ]

Author:

{u'username': u'jyemin', u'name': u'Jeff Yemin', u'email': u'jeff.yemin@10gen.com'}

Message: ServerMonitor now only calls buildInfo once for each established connection.

JAVA-1635
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/6a58c6db0f123290093be521759e0aaa8bd45ffe

Comment by Githook User [ 28/Jan/15 ]

Author:

{u'username': u'jyemin', u'name': u'Jeff Yemin', u'email': u'jeff.yemin@10gen.com'}

Message: A pooled DBPort instance now determines its own server version

JAVA-1635
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/8b5e41515c6eafd9789bcedaa2e5d550b4c56c30

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