summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBilly Donahue <billy.donahue@mongodb.com>2022-09-29 22:09:27 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-09-30 04:32:13 +0000
commitd04ce74fae19b2b02af63a6ac2a669f37426658b (patch)
tree12641c2f8f452a0c687a2badcf2fef037a46e5b6
parent1cd29a0d7b554614df88de02935677fe582e2c8e (diff)
downloadmongo-d04ce74fae19b2b02af63a6ac2a669f37426658b.tar.gz
SERVER-69704 clean up one recent use of .transform
-rw-r--r--src/mongo/db/catalog/collection_impl.cpp69
1 files changed, 34 insertions, 35 deletions
diff --git a/src/mongo/db/catalog/collection_impl.cpp b/src/mongo/db/catalog/collection_impl.cpp
index a15c2276aaf..010bb1eccf0 100644
--- a/src/mongo/db/catalog/collection_impl.cpp
+++ b/src/mongo/db/catalog/collection_impl.cpp
@@ -1050,44 +1050,43 @@ StatusWith<BSONObj> CollectionImpl::updateDocumentWithDamages(
}
RecordData oldRecordData(oldDoc.value().objdata(), oldDoc.value().objsize());
- StatusWith<BSONObj> newDocStatus =
- _shared->_recordStore->updateWithDamages(opCtx, loc, oldRecordData, damageSource, damages)
- .transform(
- [](RecordData&& recordData) { return recordData.releaseToBson().getOwned(); });
-
- if (newDocStatus.isOK()) {
- args->updatedDoc = newDocStatus.getValue();
- args->changeStreamPreAndPostImagesEnabledForCollection =
- isChangeStreamPreAndPostImagesEnabled();
-
- if (indexesAffected) {
- int64_t keysInserted = 0;
- int64_t keysDeleted = 0;
-
- uassertStatusOK(_indexCatalog->updateRecord(opCtx,
- {this, CollectionPtr::NoYieldTag{}},
- oldDoc.value(),
- args->updatedDoc,
- loc,
- &keysInserted,
- &keysDeleted));
-
- if (opDebug) {
- opDebug->additiveMetrics.incrementKeysInserted(keysInserted);
- opDebug->additiveMetrics.incrementKeysDeleted(keysDeleted);
- // 'opDebug' may be deleted at rollback time in case of multi-document transaction.
- if (!opCtx->inMultiDocumentTransaction()) {
- opCtx->recoveryUnit()->onRollback([opDebug, keysInserted, keysDeleted]() {
- opDebug->additiveMetrics.incrementKeysInserted(-keysInserted);
- opDebug->additiveMetrics.incrementKeysDeleted(-keysDeleted);
- });
- }
+ StatusWith<RecordData> recordData =
+ _shared->_recordStore->updateWithDamages(opCtx, loc, oldRecordData, damageSource, damages);
+ if (!recordData.isOK())
+ return recordData.getStatus();
+ BSONObj newDoc = std::move(recordData.getValue()).releaseToBson().getOwned();
+
+ args->updatedDoc = newDoc;
+ args->changeStreamPreAndPostImagesEnabledForCollection =
+ isChangeStreamPreAndPostImagesEnabled();
+
+ if (indexesAffected) {
+ int64_t keysInserted = 0;
+ int64_t keysDeleted = 0;
+
+ uassertStatusOK(_indexCatalog->updateRecord(opCtx,
+ {this, CollectionPtr::NoYieldTag{}},
+ oldDoc.value(),
+ args->updatedDoc,
+ loc,
+ &keysInserted,
+ &keysDeleted));
+
+ if (opDebug) {
+ opDebug->additiveMetrics.incrementKeysInserted(keysInserted);
+ opDebug->additiveMetrics.incrementKeysDeleted(keysDeleted);
+ // 'opDebug' may be deleted at rollback time in case of multi-document transaction.
+ if (!opCtx->inMultiDocumentTransaction()) {
+ opCtx->recoveryUnit()->onRollback([opDebug, keysInserted, keysDeleted]() {
+ opDebug->additiveMetrics.incrementKeysInserted(-keysInserted);
+ opDebug->additiveMetrics.incrementKeysDeleted(-keysDeleted);
+ });
}
}
-
- opCtx->getServiceContext()->getOpObserver()->onUpdate(opCtx, onUpdateArgs);
}
- return newDocStatus;
+
+ opCtx->getServiceContext()->getOpObserver()->onUpdate(opCtx, onUpdateArgs);
+ return newDoc;
}
bool CollectionImpl::isTemporary() const {