summaryrefslogtreecommitdiff
path: root/src/mongo/db/repl/repl_client_info.h
diff options
context:
space:
mode:
authorSiyuan Zhou <siyuan.zhou@mongodb.com>2015-05-19 15:10:31 -0400
committerSiyuan Zhou <siyuan.zhou@mongodb.com>2015-05-26 17:23:02 -0400
commit11237ffbb01dcfc810dccae6029d569afa4473db (patch)
tree9c4ba5fbf2ee32bce958d426b6627b7a0fb102fb /src/mongo/db/repl/repl_client_info.h
parent084e41d202d6757504d2cc338f4c0fe0cfe8babb (diff)
downloadmongo-11237ffbb01dcfc810dccae6029d569afa4473db.tar.gz
SERVER-18216 Add term to oplog.
Diffstat (limited to 'src/mongo/db/repl/repl_client_info.h')
-rw-r--r--src/mongo/db/repl/repl_client_info.h13
1 files changed, 13 insertions, 0 deletions
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