diff options
author | Louis Williams <louis.williams@mongodb.com> | 2019-03-26 16:10:05 -0400 |
---|---|---|
committer | Louis Williams <louis.williams@mongodb.com> | 2019-03-26 16:10:05 -0400 |
commit | 31a26cdd8900471c1bc9a934e8d4c16d06f611a3 (patch) | |
tree | b6679fd95dc56e8ae155aef2d58245bc3dbfc24e /src/mongo/db/read_concern_mongod.cpp | |
parent | aaa404d9d7e56a1d327f72e505f4e67b4a821959 (diff) | |
download | mongo-31a26cdd8900471c1bc9a934e8d4c16d06f611a3.tar.gz |
SERVER-40227 Pass ignore prepare behavior from a command attribute rather than using a whitelist
Diffstat (limited to 'src/mongo/db/read_concern_mongod.cpp')
-rw-r--r-- | src/mongo/db/read_concern_mongod.cpp | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/src/mongo/db/read_concern_mongod.cpp b/src/mongo/db/read_concern_mongod.cpp index 97a93de9788..7e1d0b101db 100644 --- a/src/mongo/db/read_concern_mongod.cpp +++ b/src/mongo/db/read_concern_mongod.cpp @@ -198,16 +198,10 @@ Status makeNoopWriteIfNeeded(OperationContext* opCtx, LogicalTime clusterTime) { return Status::OK(); } -// These commands are known to only perform reads, and therefore may be able to safely ignore -// prepare conflicts. The exception is aggregate, which may do writes to an output collection, but -// it enables enforcement of prepare conflicts before performing writes. -static const stdx::unordered_set<std::string> ignorePrepareCommandWhitelist = { - "aggregate", "count", "distinct", "find", "getMore", "group"}; - /** * Returns whether the command should ignore prepare conflicts or not. */ -bool shouldIgnorePrepared(StringData cmdName, +bool shouldIgnorePrepared(PrepareConflictBehavior prepareConflictBehavior, repl::ReadConcernLevel readConcernLevel, boost::optional<LogicalTime> afterClusterTime, boost::optional<LogicalTime> atClusterTime) { @@ -223,11 +217,7 @@ bool shouldIgnorePrepared(StringData cmdName, return false; } - if (ignorePrepareCommandWhitelist.count(cmdName.toString())) { - return true; - } - - return false; + return prepareConflictBehavior == PrepareConflictBehavior::kIgnore; } } // namespace @@ -235,7 +225,7 @@ MONGO_REGISTER_SHIM(waitForReadConcern) (OperationContext* opCtx, const repl::ReadConcernArgs& readConcernArgs, bool allowAfterClusterTime, - StringData cmdName) + PrepareConflictBehavior prepareConflictBehavior) ->Status { // If we are in a direct client within a transaction, then we may be holding locks, so it is // illegal to wait for read concern. This is fine, since the outer operation should have handled @@ -372,7 +362,7 @@ MONGO_REGISTER_SHIM(waitForReadConcern) if (!opCtx->getClient()->isInDirectClient()) { // Set whether this command should ignore prepare conflicts or not. opCtx->recoveryUnit()->setIgnorePrepared(shouldIgnorePrepared( - cmdName, readConcernArgs.getLevel(), afterClusterTime, atClusterTime)); + prepareConflictBehavior, readConcernArgs.getLevel(), afterClusterTime, atClusterTime)); } return Status::OK(); |