summaryrefslogtreecommitdiff
path: root/src/mongo/db/commands
diff options
context:
space:
mode:
authorVesselina Ratcheva <vesselina.ratcheva@10gen.com>2019-07-24 17:27:07 -0400
committerVesselina Ratcheva <vesselina.ratcheva@10gen.com>2019-07-26 11:50:47 -0400
commit5f7471631d238fb3269fa0f2c3689ac62e93b61f (patch)
tree91198bf0149974aa7e991e1a6d63b99278690cbf /src/mongo/db/commands
parent7a4fce6cfde41529c447417318e9c79ae42e92f0 (diff)
downloadmongo-5f7471631d238fb3269fa0f2c3689ac62e93b61f.tar.gz
SERVER-42372 Ban findAndModify against capped collections in transactions
Diffstat (limited to 'src/mongo/db/commands')
-rw-r--r--src/mongo/db/commands/find_and_modify.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/mongo/db/commands/find_and_modify.cpp b/src/mongo/db/commands/find_and_modify.cpp
index ee2a87987d2..2e6af9a3f13 100644
--- a/src/mongo/db/commands/find_and_modify.cpp
+++ b/src/mongo/db/commands/find_and_modify.cpp
@@ -197,6 +197,17 @@ void recordStatsForTopCommand(OperationContext* opCtx) {
curOp->getReadWriteType());
}
+void checkIfTransactionOnCappedColl(Collection* coll, bool inTransaction) {
+ if (coll && coll->isCapped()) {
+ uassert(
+ ErrorCodes::OperationNotSupportedInTransaction,
+ str::stream() << "Collection '" << coll->ns()
+ << "' is a capped collection. Writes in transactions are not allowed on "
+ "capped collections.",
+ !inTransaction);
+ }
+}
+
class CmdFindAndModify : public BasicCommand {
public:
CmdFindAndModify() : BasicCommand("findAndModify", "findandmodify") {}
@@ -380,6 +391,8 @@ public:
assertCanWrite(opCtx, nsString);
Collection* const collection = autoColl.getCollection();
+ checkIfTransactionOnCappedColl(collection, inTransaction);
+
const auto exec =
uassertStatusOK(getExecutorDelete(opCtx, opDebug, collection, &parsedDelete));
@@ -478,6 +491,8 @@ public:
invariant(collection);
}
+ checkIfTransactionOnCappedColl(collection, inTransaction);
+
const auto exec =
uassertStatusOK(getExecutorUpdate(opCtx, opDebug, collection, &parsedUpdate));