From 11237ffbb01dcfc810dccae6029d569afa4473db Mon Sep 17 00:00:00 2001 From: Siyuan Zhou Date: Tue, 19 May 2015 15:10:31 -0400 Subject: SERVER-18216 Add term to oplog. --- src/mongo/db/repl/repl_client_info.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/mongo/db/repl/repl_client_info.h') diff --git a/src/mongo/db/repl/repl_client_info.h b/src/mongo/db/repl/repl_client_info.h index 640e52dd7e6..69694f2795d 100644 --- a/src/mongo/db/repl/repl_client_info.h +++ b/src/mongo/db/repl/repl_client_info.h @@ -50,9 +50,22 @@ namespace repl { void setRemoteID(OID rid) { _remoteId = rid; } OID getRemoteID() const { return _remoteId; } + // If we haven't cached a term from replication coordinator, get the current term + // and cache it during the life cycle of this client. + // + // Used by logOp() to attach the current term to each log entries. Assume we don't change + // the term since caching it. This is true for write commands, since we acquire the + // global lock (IX) for write commands and stepping down also needs that lock (S). + // Stepping down will kill all user operations, so there is no write after stepping down + // in the case of yielding. + long long getTerm(); + private: + static const long long kUninitializedTerm = -1; + OpTime _lastOp = OpTime(); OID _remoteId = OID(); + long long _cachedTerm = kUninitializedTerm; }; } // namespace repl -- cgit v1.2.1