diff options
author | matt dannenberg <matt.dannenberg@10gen.com> | 2016-01-05 10:29:01 -0500 |
---|---|---|
committer | Scott Hernandez <scotthernandez@tart.local> | 2016-02-24 09:55:46 -0500 |
commit | 7bc59dac4f46e8f59786130262fb1dfea68fb605 (patch) | |
tree | 0ad5c45f99655a7cc60abc6162993ec1eab0070d /src/mongo/db/repl/sync_tail.cpp | |
parent | b5a76e83860d0cff964af4989d798f19ffce4aae (diff) | |
download | mongo-7bc59dac4f46e8f59786130262fb1dfea68fb605.tar.gz |
SERVER-22276 SERVER-22277 implement "j" flag in write concern apply to secondary as well as primary
(cherry picked from commit 2c2e6a38f559f25559c2b24eff51511c6fbc4a5b)
Diffstat (limited to 'src/mongo/db/repl/sync_tail.cpp')
-rw-r--r-- | src/mongo/db/repl/sync_tail.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/mongo/db/repl/sync_tail.cpp b/src/mongo/db/repl/sync_tail.cpp index 2e5d0182bcc..b81ee3bfa8e 100644 --- a/src/mongo/db/repl/sync_tail.cpp +++ b/src/mongo/db/repl/sync_tail.cpp @@ -216,13 +216,9 @@ ApplyBatchFinalizer::~ApplyBatchFinalizer() { } void ApplyBatchFinalizer::record(OpTime newOp) { - const bool mustWaitUntilDurable = _replCoord->isV1ElectionProtocol(); - if (!mustWaitUntilDurable) { - // We have to use setMyLastOptimeForward since this thread races with - // logTransitionToPrimaryToOplog. - _replCoord->setMyLastOptimeForward(newOp); - return; - } + // We have to use setMyLastAppliedOpTimeForward since this thread races with + // logTransitionToPrimaryToOplog. + _replCoord->setMyLastAppliedOpTimeForward(newOp); stdx::unique_lock<stdx::mutex> lock(_mutex); _latestOpTime = newOp; @@ -252,9 +248,9 @@ void ApplyBatchFinalizer::_run() { auto txn = cc().makeOperationContext(); txn->recoveryUnit()->goingToWaitUntilDurable(); txn->recoveryUnit()->waitUntilDurable(); - // We have to use setMyLastOptimeForward since this thread races with + // We have to use setMyLastDurableOpTimeForward since this thread races with // logTransitionToPrimaryToOplog. - _replCoord->setMyLastOptimeForward(latestOpTime); + _replCoord->setMyLastDurableOpTimeForward(latestOpTime); } } } // anonymous namespace containing ApplyBatchFinalizer definitions. @@ -716,7 +712,7 @@ void SyncTail::oplogApplication() { auto minValidBoundaries = getMinValid(&txn); OpTime originalEndOpTime(minValidBoundaries.end); - OpTime lastWriteOpTime{replCoord->getMyLastOptime()}; + OpTime lastWriteOpTime{replCoord->getMyLastAppliedOpTime()}; while (!inShutdown()) { OpQueue ops; @@ -747,6 +743,10 @@ void SyncTail::oplogApplication() { if (replCoord->isWaitingForApplierToDrain()) { replCoord->signalDrainComplete(&txn); } + + // Reset when triggered in case it was from a rollback, safe to do at any time. + lastWriteOpTime = replCoord->getMyLastAppliedOpTime(); + continue; // This wasn't a real op. Don't try to apply it. } |