summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--jstests/noPassthrough/resumable_index_build_drain_writes_phase.js15
-rw-r--r--src/mongo/db/index/columns_access_method.cpp10
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;
}