diff options
author | Alberto Massari <alberto.massari@mongodb.com> | 2022-12-21 19:56:54 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-12-21 21:14:53 +0000 |
commit | 5977e706431fd5705b59115ec0e0d2d7a2203246 (patch) | |
tree | 2161b9d853c2e7453a19d12b88bd39bc9bf87dd5 /src/mongo/db/ops | |
parent | 9ac3279cc3459b31a597ed4659e07ad93f073d8f (diff) | |
download | mongo-5977e706431fd5705b59115ec0e0d2d7a2203246.tar.gz |
SERVER-65364 Allow fine-grained selection of indexes to update
Diffstat (limited to 'src/mongo/db/ops')
-rw-r--r-- | src/mongo/db/ops/write_ops_exec.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/mongo/db/ops/write_ops_exec.cpp b/src/mongo/db/ops/write_ops_exec.cpp index 49fb1dd32fb..49286f8019d 100644 --- a/src/mongo/db/ops/write_ops_exec.cpp +++ b/src/mongo/db/ops/write_ops_exec.cpp @@ -1444,15 +1444,19 @@ Status performAtomicTimeseriesWrites( args.source = OperationSource::kTimeseriesInsert; BSONObj updated; - bool indexesAffected = true; + BSONObj diffFromUpdate; + const BSONObj* diffOnIndexes = + collection_internal::kUpdateAllIndexes; // Assume all indexes are affected. if (update.getU().type() == write_ops::UpdateModification::Type::kDelta) { + diffFromUpdate = update.getU().getDiff(); auto result = doc_diff::applyDiff(original.value(), - update.getU().getDiff(), + diffFromUpdate, &CollectionQueryInfo::get(*coll).getIndexKeys(opCtx), static_cast<bool>(repl::tenantMigrationInfo(opCtx))); updated = result.postImage; - indexesAffected = result.indexesAffected; - args.update = update_oplog_entry::makeDeltaOplogEntry(update.getU().getDiff()); + diffOnIndexes = + result.indexesAffected ? &diffFromUpdate : collection_internal::kUpdateNoIndexes; + args.update = update_oplog_entry::makeDeltaOplogEntry(diffFromUpdate); } else if (update.getU().type() == write_ops::UpdateModification::Type::kTransform) { const auto& transform = update.getU().getTransform(); auto transformed = transform(original.value()); @@ -1472,7 +1476,7 @@ Status performAtomicTimeseriesWrites( } collection_internal::updateDocument( - opCtx, *coll, recordId, original, updated, indexesAffected, &curOp->debug(), &args); + opCtx, *coll, recordId, original, updated, diffOnIndexes, &curOp->debug(), &args); if (slot) { if (participant) { // Manually sets the timestamp so that the "prevOpTime" field in the oplog entry is |