Details
-
Bug
-
Resolution: Duplicate
-
Major - P3
-
None
-
2.8.0
-
None
Description
Copy and pasted from a user's comment on SERVER-6117:
I tested it on v2.2.0-rc1 and could reproduce the error.
Java code (using java-driver v2.8.0):
ArrayList<ServerAddress> servers = new ArrayList<ServerAddress>();
|
servers.add(new ServerAddress("s231", 20050));
|
servers.add(new ServerAddress("s231", 20051));
|
servers.add(new ServerAddress("s231", 20052));
|
|
Mongo m = new Mongo(servers);
|
|
m.setReadPreference(ReadPreference.SECONDARY);
|
final BasicDBObject query = new BasicDBObject();
|
final BasicDBObject fields = new BasicDBObject();
|
|
query.put("_id", new BasicDBObject("$gte", Integer.valueOf(1)));
|
fields.put("_id", Long.valueOf(1));
|
|
final DB db = m.getDB("offerStore");
|
boolean ok = db.authenticate("user", "pw".toCharArray());
|
System.out.println("ok: " + ok);
|
final DBCursor c = db.getCollection("offer").find(query, fields).limit(10);
|
|
while(c.hasNext()) {
|
DBObject offer = c.next();
|
System.out.println(offer);
|
}
|
c.close();
|
Output after several runs:
ok: false
|
Exception in thread "main" com.mongodb.MongoException: unauthorized db:offerStore ns:offerStore.offer lock type:0 client:192.x.y.z
|
at com.mongodb.MongoException.parse(MongoException.java:82)
|
at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:317)
|
at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:298)
|
at com.mongodb.DBCursor._check(DBCursor.java:369)
|
at com.mongodb.DBCursor._hasNext(DBCursor.java:492)
|
at com.mongodb.DBCursor.hasNext(DBCursor.java:517)
|
at de.idealo.offerstore.mongo.TempTest.authenticationTest(TempTest.java:507)
|
at de.idealo.offerstore.mongo.TempTest.main(TempTest.java:716)
|
Attachments
Issue Links
- duplicates
-
JAVA-397 authentication for replica set fails frequently because 'getnonce' and 'authenticate' command is issued to different server
-
- Closed
-