Skip to content

Commit 7841cdf

Browse files
committed
[JAVA-275]: with default write concern (no getLastError), if master changes in repl set, writes will fail undetected forever
1 parent 8a955e2 commit 7841cdf

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/main/com/mongodb/Mongo.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,11 @@ void _applyMongoOptions() {
482482
if (_options.slaveOk) slaveOk();
483483
setWriteConcern( _options.getWriteConcern() );
484484
}
485-
485+
486+
DBTCPConnector getConnector() {
487+
return _connector;
488+
}
489+
486490
final ServerAddress _addr;
487491
final List<ServerAddress> _addrs;
488492
final MongoOptions _options;

src/main/com/mongodb/ReplicaSetStatus.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,10 @@ synchronized void updateAll(){
304304
it.remove();
305305
}
306306
}
307+
308+
// force check on master
309+
// otherwise master change may go unnoticed for a while if no write concern
310+
_mongo.getConnector().checkMaster(true, false);
307311
}
308312

309313
List<ServerAddress> getServerAddressList() {

0 commit comments

Comments
 (0)