diff options
author | Scott Hernandez <scotthernandez@tart.local> | 2016-03-22 11:42:41 -0400 |
---|---|---|
committer | Scott Hernandez <scotthernandez@tart.local> | 2016-03-27 11:45:02 -0400 |
commit | ec1aaf5ce52bed2897e80cbba7add95c068809dc (patch) | |
tree | b6b77429c32ff66454582aaa3cda5882d0f8c9bf /src/mongo/db/repl/replication_coordinator_impl_elect_v1.cpp | |
parent | 7a5d4214ca939ff3e522a493d848f9f35ac88d5c (diff) | |
download | mongo-ec1aaf5ce52bed2897e80cbba7add95c068809dc.tar.gz |
SERVER-23010: do not update durable OpTime, and update commited snapshot, if not durable
Diffstat (limited to 'src/mongo/db/repl/replication_coordinator_impl_elect_v1.cpp')
-rw-r--r-- | src/mongo/db/repl/replication_coordinator_impl_elect_v1.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/mongo/db/repl/replication_coordinator_impl_elect_v1.cpp b/src/mongo/db/repl/replication_coordinator_impl_elect_v1.cpp index 61c1110a58b..acc9f8cf2ec 100644 --- a/src/mongo/db/repl/replication_coordinator_impl_elect_v1.cpp +++ b/src/mongo/db/repl/replication_coordinator_impl_elect_v1.cpp @@ -124,9 +124,11 @@ void ReplicationCoordinatorImpl::_startElectSelfV1() { invariant(_rsConfig.getMemberAt(_selfIndex).isElectable()); - OpTime lastOpTimeDurable(_getMyLastDurableOpTime_inlock()); + // Note: If we aren't durable, send last applied. + const auto lastOpTime = _isDurableStorageEngine() ? _getMyLastDurableOpTime_inlock() + : _getMyLastAppliedOpTime_inlock(); - if (lastOpTimeDurable == OpTime()) { + if (lastOpTime == OpTime()) { log() << "not trying to elect self, " "do not yet have a complete set of data from any point in time"; return; @@ -147,7 +149,7 @@ void ReplicationCoordinatorImpl::_startElectSelfV1() { _selfIndex, _topCoord->getTerm(), true, // dry run - getMyLastDurableOpTime(), + lastOpTime, stdx::bind(&ReplicationCoordinatorImpl::_onDryRunComplete, this, term)); if (nextPhaseEvh.getStatus() == ErrorCodes::ShutdownInProgress) { return; @@ -238,6 +240,9 @@ void ReplicationCoordinatorImpl::_startVoteRequester(long long newTerm) { invariant(!_electionWinnerDeclarer); LoseElectionGuardV1 lossGuard(this); + const auto lastOpTime = + _isDurableStorageEngine() ? getMyLastDurableOpTime() : getMyLastAppliedOpTime(); + _voteRequester.reset(new VoteRequester); StatusWith<ReplicationExecutor::EventHandle> nextPhaseEvh = _voteRequester->start( &_replExecutor, @@ -245,7 +250,7 @@ void ReplicationCoordinatorImpl::_startVoteRequester(long long newTerm) { _selfIndex, _topCoord->getTerm(), false, - getMyLastDurableOpTime(), + lastOpTime, stdx::bind(&ReplicationCoordinatorImpl::_onVoteRequestComplete, this, newTerm)); if (nextPhaseEvh.getStatus() == ErrorCodes::ShutdownInProgress) { return; |