diff options
author | Mihai Andrei <mihai.andrei@10gen.com> | 2020-03-09 14:48:58 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-04-01 21:11:41 +0000 |
commit | 526e5bcf9e8cd0e659123c553538e005ac5ab29a (patch) | |
tree | 13cec510d714d84f86116251ea66123f96011ce3 /src/mongo/db/repl/repl_client_info.h | |
parent | 2cd751b7a81912d0f6bc311423903c17e15eba48 (diff) | |
download | mongo-526e5bcf9e8cd0e659123c553538e005ac5ab29a.tar.gz |
SERVER-46665 Fix causal consistency for $out/$merge running on secondaries
Diffstat (limited to 'src/mongo/db/repl/repl_client_info.h')
-rw-r--r-- | src/mongo/db/repl/repl_client_info.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/mongo/db/repl/repl_client_info.h b/src/mongo/db/repl/repl_client_info.h index 232c95460fe..51b953d2875 100644 --- a/src/mongo/db/repl/repl_client_info.h +++ b/src/mongo/db/repl/repl_client_info.h @@ -58,6 +58,26 @@ public: } /** + * Stores the operation time of the latest proxy write, that is, a write that was forwarded + * to and executed on a different node instead of being executed locally. + */ + void setLastProxyWriteOpTimeForward(const OpTime& opTime) { + // Only advance the operation time of the latest proxy write if it is greater than the one + // currently stored. + if (opTime > _lastProxyWriteOpTime) { + _lastProxyWriteOpTime = opTime; + } + } + + /** + * Returns the greater of the times set by 'setLastOp()' and + * 'setLastProxiedWriteOpTimeForward()'. + */ + OpTime getMaxKnownOpTime() const { + return _lastOp > _lastProxyWriteOpTime ? _lastOp : _lastProxyWriteOpTime; + } + + /** * Returns true when either setLastOp() or setLastOpToSystemLastOpTime() was called to set the * opTime under the current OperationContext. */ @@ -88,6 +108,8 @@ private: static const long long kUninitializedTerm = -1; OpTime _lastOp = OpTime(); + + OpTime _lastProxyWriteOpTime; }; } // namespace repl |