diff options
author | William Schultz <william.schultz@mongodb.com> | 2018-11-14 16:11:03 -0500 |
---|---|---|
committer | William Schultz <william.schultz@mongodb.com> | 2018-11-14 16:17:44 -0500 |
commit | a6a0ca1ae81b34aab14a9c9a2a3d4a6ec7be66ba (patch) | |
tree | 18ddc6ff8413c2dccb528522cbd828b811994e55 /src/mongo/db/repl/read_concern_args.cpp | |
parent | c1d4e0b8e1a4c197aac2530259f78eb88fb4acd3 (diff) | |
download | mongo-a6a0ca1ae81b34aab14a9c9a2a3d4a6ec7be66ba.tar.gz |
SERVER-37560 Add API for allowing commands to support speculative majority reads
This patch lays the groundwork for allowing read queries to take advantage of "speculative" majority reads, which is a mechanism for satisfying majority read guarantees without storage engine support for reading from a historical snapshot. This patch adds a flag on the ReadConcernArgs object to indicate whether a query should use the speculative behavior, and it also adds a method to the CommandInvocation interface that allows commands to optionally support speculative majority reads. The intention is to initially only utilize this behavior for change stream queries i.e. 'aggregate' and 'find' commands, but the feature is, in theory, generic.
Diffstat (limited to 'src/mongo/db/repl/read_concern_args.cpp')
-rw-r--r-- | src/mongo/db/repl/read_concern_args.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/mongo/db/repl/read_concern_args.cpp b/src/mongo/db/repl/read_concern_args.cpp index a2014bdb1b2..4ae80592c11 100644 --- a/src/mongo/db/repl/read_concern_args.cpp +++ b/src/mongo/db/repl/read_concern_args.cpp @@ -262,6 +262,16 @@ Status ReadConcernArgs::initialize(const BSONElement& readConcernElem) { return Status::OK(); } +void ReadConcernArgs::setMajorityReadMechanism(MajorityReadMechanism mechanism) { + invariant(*_level == ReadConcernLevel::kMajorityReadConcern); + _majorityReadMechanism = mechanism; +} + +ReadConcernArgs::MajorityReadMechanism ReadConcernArgs::getMajorityReadMechanism() const { + invariant(*_level == ReadConcernLevel::kMajorityReadConcern); + return _majorityReadMechanism; +} + Status ReadConcernArgs::upconvertReadConcernLevelToSnapshot() { if (_level && *_level != ReadConcernLevel::kSnapshotReadConcern && *_level != ReadConcernLevel::kMajorityReadConcern && |