diff options
author | Maria van Keulen <maria.vankeulen@mongodb.com> | 2020-01-24 16:41:52 +0000 |
---|---|---|
committer | evergreen <evergreen@mongodb.com> | 2020-01-24 16:41:52 +0000 |
commit | cc39f69e7b2d79a3074a546ca33d30a0307bc238 (patch) | |
tree | d6a6dfd7a89ebbc7b3a2704269df384113748fa7 /src | |
parent | 925c5bffbae524a9415c84897ae7ef3a7a798fed (diff) | |
download | mongo-cc39f69e7b2d79a3074a546ca33d30a0307bc238.tar.gz |
SERVER-45370 Fix oplog hole and test parallel createCollection txns
Testing parallel transactions with createCollections found a hang
scenario caused by reserving oplog slots before transaction commit.
This patch adds this testing and fixes this bug.
Diffstat (limited to 'src')
-rw-r--r-- | src/mongo/db/catalog/database_impl.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/mongo/db/catalog/database_impl.cpp b/src/mongo/db/catalog/database_impl.cpp index efb175b079b..46f2b931f26 100644 --- a/src/mongo/db/catalog/database_impl.cpp +++ b/src/mongo/db/catalog/database_impl.cpp @@ -634,9 +634,13 @@ Collection* DatabaseImpl::createCollection(OperationContext* opCtx, // collection create always correct even when other operations are present in the same storage // transaction, we reserve an opTime before the collection creation, then pass it to the // opObserver. Reserving the optime automatically sets the storage timestamp. + // In order to ensure isolation of multi-document transactions, createCollection should only + // reserve oplog slots here if it is run outside of a multi-document transaction. Multi- + // document transactions reserve the appropriate oplog slots at commit time. OplogSlot createOplogSlot; Timestamp createTime; - if (canAcceptWrites && supportsDocLocking() && !coordinator->isOplogDisabledFor(opCtx, nss)) { + if (canAcceptWrites && supportsDocLocking() && !coordinator->isOplogDisabledFor(opCtx, nss) && + !opCtx->inMultiDocumentTransaction()) { createOplogSlot = repl::getNextOpTime(opCtx); createTime = createOplogSlot.getTimestamp(); } else { |