diff options
author | Justin Seyster <justin.seyster@mongodb.com> | 2023-01-31 16:55:05 -0500 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2023-02-01 07:32:04 +0000 |
commit | 923f10421df339783d3f1baeb60be5bac3180fa3 (patch) | |
tree | 8aa5a8c6173d442c7d268ab4b79beee5537e08cc | |
parent | 810bc652885578ab293680db7f475ebaf947599f (diff) | |
download | mongo-923f10421df339783d3f1baeb60be5bac3180fa3.tar.gz |
SERVER-73465 Updates during column store index build can result in no-op side writes
-rw-r--r-- | jstests/noPassthrough/resumable_index_build_drain_writes_phase.js | 15 | ||||
-rw-r--r-- | src/mongo/db/index/columns_access_method.cpp | 10 |
2 files changed, 23 insertions, 2 deletions
diff --git a/jstests/noPassthrough/resumable_index_build_drain_writes_phase.js b/jstests/noPassthrough/resumable_index_build_drain_writes_phase.js index 549ee93a63e..485abf0a758 100644 --- a/jstests/noPassthrough/resumable_index_build_drain_writes_phase.js +++ b/jstests/noPassthrough/resumable_index_build_drain_writes_phase.js @@ -69,6 +69,21 @@ if (columnstoreEnabled) { assert.commandWorked(collection.update({a: 4}, {a: 2})); }), "_columnstore"); + runTests({a: {b: 1}, c: 1}, + [{"a.$**": "columnstore"}, {h: 1}], + (function(collection) { + assert.commandWorked(collection.insert({a: 1})); + assert.commandWorked(collection.insert({a: {b: 2}})); + + // Updates that leave the indexed columns unmodified. + assert.commandWorked(collection.update({"a.b": 1}, {a: {b: 1}, c: 10})); + assert.commandWorked(collection.update({"a.b": 2}, {a: {b: 2}, c: 10})); + + // Insert and delete that do not involve any indexed columns. + assert.commandWorked(collection.insert({c: 20})); + assert.commandWorked(collection.deleteOne({c: 20})); + }), + "_subdocument_columnstore"); } rst.stopSet(); })(); diff --git a/src/mongo/db/index/columns_access_method.cpp b/src/mongo/db/index/columns_access_method.cpp index f894117fb97..9300f8fbc4d 100644 --- a/src/mongo/db/index/columns_access_method.cpp +++ b/src/mongo/db/index/columns_access_method.cpp @@ -398,10 +398,16 @@ Status ColumnStoreAccessMethod::update(OperationContext* opCtx, diffAction); }); + // Create a "side write" that records the changes made to this document during the bulk + // build, so that they can be applied when the bulk builder finishes. It is possible that an + // update does not result in any changes when there is a "columnstoreProjection" on the + // index that excludes all the changed fields. int64_t inserted = 0; int64_t deleted = 0; - Status status = _indexCatalogEntry->indexBuildInterceptor()->sideWrite( - opCtx, *columnChanges, &inserted, &deleted); + if (columnChanges->size() > 0) { + uassertStatusOK(_indexCatalogEntry->indexBuildInterceptor()->sideWrite( + opCtx, *columnChanges, &inserted, &deleted)); + } if (keysInsertedOut) { *keysInsertedOut += inserted; } |