diff options
author | Lingzhi Deng <lingzhi.deng@mongodb.com> | 2020-04-30 18:27:05 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-05-06 18:06:40 +0000 |
commit | 5fdc82329bb92d7887e6b6b57725e52d668b1823 (patch) | |
tree | 0333b81c73b95b2b5783735abf5a18781cc2ab3c | |
parent | af53817b7963ed7b19e4d0383867e59fb86a0c6e (diff) | |
download | mongo-5fdc82329bb92d7887e6b6b57725e52d668b1823.tar.gz |
SERVER-47695: Don't set lastOp for client backwards in terms of timestamp after rollback
(cherry picked from commit bd579c0d3f2583c2af7dcd98c7f6cfc55009b406)
-rw-r--r-- | src/mongo/db/repl/repl_client_info.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/mongo/db/repl/repl_client_info.cpp b/src/mongo/db/repl/repl_client_info.cpp index 2538e7d16c5..21b6d0980ea 100644 --- a/src/mongo/db/repl/repl_client_info.cpp +++ b/src/mongo/db/repl/repl_client_info.cpp @@ -97,10 +97,13 @@ void ReplClientInfo::setLastOpToSystemLastOpTime(OperationContext* opCtx) { // above. } - // If the system optime has gone backwards, that must mean that there was a rollback. - // This is safe, but the last op for a Client should never go backwards, so just leave - // the last op for this Client as it was. - if (systemOpTime >= _lastOp) { + // If the system timestamp has gone backwards, that must mean that there was a rollback. + // If the system optime has a higher term but a lower timestamp than the client's lastOp, it + // means that this node's wallclock time was ahead of the current primary's before it rolled + // back. This is safe, but the timestamp of the last op for a Client should never go + // backwards, so just leave the last op for this Client as it was. + if (systemOpTime.getTerm() >= _lastOp.getTerm() && + systemOpTime.getTimestamp() >= _lastOp.getTimestamp()) { _lastOp = systemOpTime; } else { LOGV2(21280, |