summaryrefslogtreecommitdiff
path: root/src/mongo/db/repl/read_concern_args.h
diff options
context:
space:
mode:
authorA. Jesse Jiryu Davis <jesse@mongodb.com>2020-06-01 14:31:06 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-06-01 19:22:51 +0000
commit41cff016562656589bd3a3c114d6dfb31dd3271f (patch)
tree19a2d2c6cd831e0275391ba4eb93d17ffd141d52 /src/mongo/db/repl/read_concern_args.h
parent5c1cb9b2908b4d1622b44dd1020c76b3e563610d (diff)
downloadmongo-41cff016562656589bd3a3c114d6dfb31dd3271f.tar.gz
SERVER-47952 Shard selects timestamp for one-shard snapshot find
Diffstat (limited to 'src/mongo/db/repl/read_concern_args.h')
-rw-r--r--src/mongo/db/repl/read_concern_args.h28
1 files changed, 18 insertions, 10 deletions
diff --git a/src/mongo/db/repl/read_concern_args.h b/src/mongo/db/repl/read_concern_args.h
index ba6004d13bf..2c7aca60282 100644
--- a/src/mongo/db/repl/read_concern_args.h
+++ b/src/mongo/db/repl/read_concern_args.h
@@ -182,13 +182,21 @@ public:
* Set atClusterTime, clear afterClusterTime. The BSON representation becomes
* {level: "snapshot", atClusterTime: <ts>}.
*/
- void setArgsAtClusterTimeForSnapshot(Timestamp ts) {
+ void setArgsAtClusterTime(Timestamp ts) {
invariant(_level && _level == ReadConcernLevel::kSnapshotReadConcern);
// Only overwrite a server-selected atClusterTime, not user-supplied.
- invariant(_atClusterTime.is_initialized() == _atClusterTimeSelected);
- _afterClusterTime = boost::none;
- _atClusterTime = LogicalTime(ts);
- _atClusterTimeSelected = true;
+ invariant(!_clientAtClusterTime);
+ _computedAfterClusterTime = boost::none;
+ _computedAtClusterTime = LogicalTime(ts);
+ }
+
+ /**
+ * If we have selected an atClusterTime for non-transaction snapshot reads, clear it and restore
+ * the atClusterTime and afterClusterTime passed by the client.
+ */
+ void clearArgsAtClusterTime() {
+ _computedAfterClusterTime = _clientAfterClusterTime;
+ _computedAtClusterTime = _clientAtClusterTime;
}
/**
@@ -196,7 +204,7 @@ public:
* function returns false if the atClusterTime was specified by the client.
*/
bool wasAtClusterTimeSelected() const {
- return _atClusterTimeSelected;
+ return _computedAtClusterTime && _computedAtClusterTime != _clientAtClusterTime;
}
private:
@@ -213,11 +221,13 @@ private:
/**
* Read data after cluster-wide cluster time.
*/
- boost::optional<LogicalTime> _afterClusterTime;
+ boost::optional<LogicalTime> _clientAfterClusterTime;
+ boost::optional<LogicalTime> _computedAfterClusterTime;
/**
* Read data at a particular cluster time.
*/
- boost::optional<LogicalTime> _atClusterTime;
+ boost::optional<LogicalTime> _clientAtClusterTime;
+ boost::optional<LogicalTime> _computedAtClusterTime;
boost::optional<ReadConcernLevel> _level;
/**
@@ -233,8 +243,6 @@ private:
bool _specified;
ReadWriteConcernProvenance _provenance;
-
- bool _atClusterTimeSelected = false;
};
} // namespace repl