Build Date: 2013-Jun-13 02:15:17 PM
db.auth(null, null) gives null pointer exception
ADS MongoShell
> db.auth(null,null)
Once Nhi has a fix for this, we need to test in multiple scenarios including replica set, and setting the slaveOK flag to true. We also need to test with and w/o using the authDB parameter
I am still debugging this.
A limitation is that you cannot reuse an existing innerMongo object to authenticate to a different user. Thus there is a call to close() in the Mongo.auth() method which calls innerMongo.close(). Unfortunately, innerMongo.close() also wipes out the server address list so that the innerMongo object is no longer working, causing the bug in this issue.
My current fix is to construct a new innerMongo object based on the server address list and mongo options from the original innerMongo. Then we close the original innerMongo object. To answer one of Sachin's questions, the MongoDriver.connect() method is not invoked by creating another innerMongo instance.
This should work, but there seems to be a third innerMongo instance somewhere. The new problem is that after re-authentication, subsequent DB queries seems to be associated with a different innerMongo instance than the one we re-authenticated in Mongo.auth(). I'll need to debug this further to see why/how a third innerMongo instance is created.
I am still debugging this.
A limitation is that you cannot reuse an existing innerMongo object to authenticate to a different user. Thus there is a call to close() in the Mongo.auth() method which calls innerMongo.close(). Unfortunately, innerMongo.close() also wipes out the server address list so that the innerMongo object is no longer working, causing the bug in this issue.
My current fix is to construct a new innerMongo object based on the server address list and mongo options from the original innerMongo. Then we close the original innerMongo object. To answer one of Sachin's questions, the MongoDriver.connect() method is not invoked by creating another innerMongo instance.
This should work, but there seems to be a third innerMongo instance somewhere. The new problem is that after re-authentication, subsequent DB queries seems to be associated with a different innerMongo instance than the one we re-authenticated in Mongo.auth(). I'll need to debug this further to see why/how a third innerMongo instance is created.
Fixed the null ptr exception in beta-28. However, if DB enforces authentication, the next DB call after the db.auth() successfully executes will result in a "not authenticated" error. The current workaround is to call db.auth() a second time. The cause is that somehow a 3rd innerMongo instance is created after the first do.auth() called. This 3rd innerMongo instance is not authenticated.
Fixed the null ptr exception in beta-28. However, if DB enforces authentication, the next DB call after the db.auth() successfully executes will result in a "not authenticated" error. The current workaround is to call db.auth() a second time. The cause is that somehow a 3rd innerMongo instance is created after the first do.auth() called. This 3rd innerMongo instance is not authenticated.
Found it. I overlooked Mongo.initMongoConnection().
Found it. I overlooked Mongo.initMongoConnection().
While testing against replicated setup using ADS 14-beta-33, i still get NullPointerException while executing db.auth(null, null) on ADS mongoshell. (Pls refer to the attached onsecondary_slaveOK.png).
On common use cases of various combinations of slaveOK and authDB params, db.auth(username, password) seems to work fine on mongoshell.
While testing against replicated setup using ADS 14-beta-33, i still get NullPointerException while executing db.auth(null, null) on ADS mongoshell. (Pls refer to the attached onsecondary_slaveOK.png).
On common use cases of various combinations of slaveOK and authDB params, db.auth(username, password) seems to work fine on mongoshell.
Reopened. I focused on the positive case and neglected the negative case.
The NullPtrException was caused by Mongo.auth() not checking for null before calling toString() on the value. We'll fix this condition in Mongo.auth() and let mongo.jar deal with the null condition, which may or may not be a valid condition, but they should handle it as they see fit.
Reopened. I focused on the positive case and neglected the negative case.
The NullPtrException was caused by Mongo.auth() not checking for null before calling toString() on the value. We'll fix this condition in Mongo.auth() and let mongo.jar deal with the null condition, which may or may not be a valid condition, but they should handle it as they see fit.
Found an issue with behavior of db.auth() but it's more on mongodb side and have filed https://jira.mongodb.org/browse/SERVER-10063
Found an issue with behavior of db.auth() but it's more on mongodb side and have filed https://jira.mongodb.org/browse/SERVER-10063
Checked functionality of db.auth() on ADS 14-beta-55 mongoshell in following setups and apart from db.logout() issue , I did not find any other issues.
1) Standalone setup with(out) auth.
2) Replicated setup (3 member).
3) A sharded cluster (2 shards).
Used combinations of authDB and slaveOK params where applicable.
Due to hardware limitation, I could not test it out against a sharded cluster with replication (i.e. each shard replicated).
Checked functionality of db.auth() on ADS 14-beta-55 mongoshell in following setups and apart from db.logout() issue , I did not find any other issues.
1) Standalone setup with(out) auth.
2) Replicated setup (3 member).
3) A sharded cluster (2 shards).
Used combinations of authDB and slaveOK params where applicable.
Due to hardware limitation, I could not test it out against a sharded cluster with replication (i.e. each shard replicated).
Issue #9353 |
Closed |
Fixed |
Resolved |
Completion |
No due date |
Fixed Build beta-42 |
No time estimate |
2 issue links |
relates to #12674
Issue #12674db.auth(null, null) gives NPE |
relates to #14339
Issue #14339db.auth(null, null) gives null pointer exception when we execute it second time. |
Once Nhi has a fix for this, we need to test in multiple scenarios including replica set, and setting the slaveOK flag to true. We also need to test with and w/o using the authDB parameter