summaryrefslogtreecommitdiff
path: root/src/mongo/db/commands
diff options
context:
space:
mode:
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));