diff options
author | Jack Mulrow <jack.mulrow@mongodb.com> | 2022-05-05 18:15:33 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-05-05 19:59:18 +0000 |
commit | 883238375b56d7a4a11f48583a5f79a5f7192d87 (patch) | |
tree | de9aac6b45abc53c0fd37ecf14d4ed16954a5f7b /src/mongo/db/ops | |
parent | f9fe71c1ffbc95531ed010b5a8d2465d175956de (diff) | |
download | mongo-883238375b56d7a4a11f48583a5f79a5f7192d87.tar.gz |
SERVER-66222 Retryable transactions should reject multi writes with an initialized statement id
Diffstat (limited to 'src/mongo/db/ops')
-rw-r--r-- | src/mongo/db/ops/write_ops_exec.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/mongo/db/ops/write_ops_exec.cpp b/src/mongo/db/ops/write_ops_exec.cpp index cd808ce9dd7..315213a1948 100644 --- a/src/mongo/db/ops/write_ops_exec.cpp +++ b/src/mongo/db/ops/write_ops_exec.cpp @@ -923,7 +923,9 @@ static SingleWriteResult performSingleUpdateOpWithDupKeyRetry( uassert(ErrorCodes::InvalidOptions, "Cannot use (or request) retryable writes with multi=true", - opCtx->inMultiDocumentTransaction() || !opCtx->getTxnNumber() || !op.getMulti()); + !opCtx->isRetryableWrite() || !op.getMulti() || + // If the first stmtId is uninitialized, we assume all are. + (stmtIds.empty() || stmtIds.front() == kUninitializedStmtId)); UpdateRequest request(op); request.setNamespaceString(ns); @@ -1088,7 +1090,7 @@ static SingleWriteResult performSingleDeleteOp(OperationContext* opCtx, OperationSource source) { uassert(ErrorCodes::InvalidOptions, "Cannot use (or request) retryable writes with limit=0", - opCtx->inMultiDocumentTransaction() || !opCtx->getTxnNumber() || !op.getMulti()); + !opCtx->isRetryableWrite() || !op.getMulti() || stmtId == kUninitializedStmtId); globalOpCounters.gotDelete(); ServerWriteConcernMetrics::get(opCtx)->recordWriteConcernForDelete(opCtx->getWriteConcern()); |