summaryrefslogtreecommitdiff
path: root/src/mongo/db/commands.h
diff options
context:
space:
mode:
authorWilliam Schultz <william.schultz@mongodb.com>2018-11-14 16:11:03 -0500
committerWilliam Schultz <william.schultz@mongodb.com>2018-11-14 16:17:44 -0500
commita6a0ca1ae81b34aab14a9c9a2a3d4a6ec7be66ba (patch)
tree18ddc6ff8413c2dccb528522cbd828b811994e55 /src/mongo/db/commands.h
parentc1d4e0b8e1a4c197aac2530259f78eb88fb4acd3 (diff)
downloadmongo-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/commands.h')
-rw-r--r--src/mongo/db/commands.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/mongo/db/commands.h b/src/mongo/db/commands.h
index 71e75362643..aed2407f8f8 100644
--- a/src/mongo/db/commands.h
+++ b/src/mongo/db/commands.h
@@ -515,6 +515,19 @@ public:
}
/**
+ * Returns true if this command invocation is allowed to utilize "speculative" majority reads to
+ * service 'majority' read concern requests. This allows a query to satisfy a 'majority' read
+ * without storage engine support for reading from a historical snapshot.
+ *
+ * Note: This feature is currently only limited to a very small subset of commands (related to
+ * change streams), and is not intended to be generally used, which is why it is disabled by
+ * default.
+ */
+ virtual bool allowsSpeculativeMajorityReads() const {
+ return false;
+ }
+
+ /**
* The command definition that this invocation runs.
* Note: nonvirtual.
*/