diff options
author | Dianna Hohensee <dianna.hohensee@mongodb.com> | 2021-10-05 19:24:00 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-10-05 20:00:50 +0000 |
commit | 0300f19cd738e58cdeaa88b7406a2f38718b0ad9 (patch) | |
tree | fbcb0abd7915fb9153dc5fc4d304d2343c89a79b | |
parent | af4fb25da73a43788ceac5e3f74091859dc90161 (diff) | |
download | mongo-0300f19cd738e58cdeaa88b7406a2f38718b0ad9.tar.gz |
SERVER-60451 Copy BSON before saving and restoring a cursor around index build side table writes
-rw-r--r-- | src/mongo/db/catalog/multi_index_block.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/mongo/db/catalog/multi_index_block.cpp b/src/mongo/db/catalog/multi_index_block.cpp index 978ed37cf25..0ce0203ad4d 100644 --- a/src/mongo/db/catalog/multi_index_block.cpp +++ b/src/mongo/db/catalog/multi_index_block.cpp @@ -615,7 +615,15 @@ void MultiIndexBlock::_doCollectionScan(OperationContext* opCtx, collection, objToIndex, loc, - /*saveCursorBeforeWrite*/ [&exec] { exec->saveState(); }, + /*saveCursorBeforeWrite*/ + [&exec, &objToIndex] { + // Update objToIndex so that it continues to point to valid data when the + // cursor is closed. A WCE may occur during a write to index A, and + // objToIndex must still be used when the write is retried or for a write to + // another index (if creating multiple indexes at once) + objToIndex = objToIndex.getOwned(); + exec->saveState(); + }, /*restoreCursorAfterWrite*/ [&] { exec->restoreState(&collection); })); _failPointHangDuringBuild(opCtx, |