[JAVA-275] with default write concern (no getLastError), if master changes in repl set, small edge case where writes will fail undetected Created: 17/Feb/11  Updated: 17/Mar/11  Resolved: 17/Feb/11

Status: Closed
Project: Java Driver
Component/s: None
Affects Version/s: None
Fix Version/s: 2.5

Type: Bug Priority: Major - P3
Reporter: Antoine Girbal Assignee: Antoine Girbal
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to SERVER-1679 need to be a way to quickly detect a ... Closed

 Description   

In case or reads, we always get an answer back from db and if it's an error saying "not master", we do a force check master.
But for writes, with default setting, client never gets an answer back and the error goes unnoticed.
A clean fix would be to have updater thread do a forced checkmaster.
This way the max we lose is 5s worth of docs.. which is ok for w=0.



 Comments   
Comment by Antoine Girbal [ 25/Feb/11 ]

so only the former primary will drop all its connections?
I think it's still good to have the updater thread update the master when it runs isMaster on servers, it doesnt cost anything.
There is a very small edge case:

  • writes go to server1, there is no connection to server2
  • server1 steps down, and bounces all connections. New master is server2
  • driver does 1 write to server1 which gets ioexception, picks up server2 as master (through the updater's own port, not the general pool)
  • before more writes go out the master changes again to master3.
  • driver will use master2 for further writes but not get ioexceptions.
    That is if there is no read or slaveOk=true.
    Changing ticket title since it's not that bad..
Comment by Dwight Merriman [ 25/Feb/11 ]

the mongod server drops its priamry state, it will force a close of all sockets for this very reason.

because of that, doesn't require special handling.

Comment by auto [ 17/Feb/11 ]

Author:

{u'login': u'agirbal', u'name': u'agirbal', u'email': u'antoine@10gen.com'}

Message: JAVA-275: fix to implementation, was looping in case driver is started with no master available
https://github.com/mongodb/mongo-java-driver/commit/dcfe3bd1ed0e95cec1ccb62d62a0270149d8f6ea

Comment by auto [ 17/Feb/11 ]

Author:

{u'login': u'agirbal', u'name': u'agirbal', u'email': u'antoine@10gen.com'}

Message: JAVA-275: with default write concern (no getLastError), if master changes in repl set, writes will fail undetected forever
https://github.com/mongodb/mongo-java-driver/commit/7841cdf95495c89fc77d513cbba7865a14967474

Comment by Antoine Girbal [ 17/Feb/11 ]

this may not have been picked up earlier since as soon as you do a read() it will get error and force checkMaster.
Though if you have slaveOk=true, then no error.

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