summaryrefslogtreecommitdiff
path: root/src/mongo/db/repl/storage_interface_impl.cpp
diff options
context:
space:
mode:
authorJudah Schvimer <judah@mongodb.com>2018-03-14 17:20:31 -0400
committerJudah Schvimer <judah@mongodb.com>2018-03-29 15:24:35 -0400
commitd3aa30ddc4456422b1adeec437abb8efe3d4cfec (patch)
treeb7674984b1ee0bf898c41149d3c2bc35d7919c56 /src/mongo/db/repl/storage_interface_impl.cpp
parente5f6c368bd34bb9122c0085401d2ead3d4d3f78c (diff)
downloadmongo-d3aa30ddc4456422b1adeec437abb8efe3d4cfec.tar.gz
SERVER-33493 Have WT RTT rollback keep correct counts
Diffstat (limited to 'src/mongo/db/repl/storage_interface_impl.cpp')
-rw-r--r--src/mongo/db/repl/storage_interface_impl.cpp26
1 files changed, 23 insertions, 3 deletions
diff --git a/src/mongo/db/repl/storage_interface_impl.cpp b/src/mongo/db/repl/storage_interface_impl.cpp
index 3591dd25bce..3ccdfbb6d69 100644
--- a/src/mongo/db/repl/storage_interface_impl.cpp
+++ b/src/mongo/db/repl/storage_interface_impl.cpp
@@ -986,11 +986,11 @@ StatusWith<StorageInterface::CollectionSize> StorageInterfaceImpl::getCollection
}
StatusWith<StorageInterface::CollectionCount> StorageInterfaceImpl::getCollectionCount(
- OperationContext* opCtx, const NamespaceString& nss) {
- AutoGetCollectionForRead autoColl(opCtx, nss);
+ OperationContext* opCtx, const NamespaceStringOrUUID& nsOrUUID) {
+ AutoGetCollectionForRead autoColl(opCtx, nsOrUUID);
auto collectionResult =
- getCollection(autoColl, nss, "Unable to get number of documents in collection.");
+ getCollection(autoColl, nsOrUUID, "Unable to get number of documents in collection.");
if (!collectionResult.isOK()) {
return collectionResult.getStatus();
}
@@ -999,6 +999,26 @@ StatusWith<StorageInterface::CollectionCount> StorageInterfaceImpl::getCollectio
return collection->numRecords(opCtx);
}
+Status StorageInterfaceImpl::setCollectionCount(OperationContext* opCtx,
+ const NamespaceStringOrUUID& nsOrUUID,
+ long long newCount) {
+ AutoGetCollection autoColl(opCtx, nsOrUUID, LockMode::MODE_X);
+
+ auto collectionResult =
+ getCollection(autoColl, nsOrUUID, "Unable to set number of documents in collection.");
+ if (!collectionResult.isOK()) {
+ return collectionResult.getStatus();
+ }
+ auto collection = collectionResult.getValue();
+
+ auto rs = collection->getRecordStore();
+ // We cannot fix the data size correctly, so we just get the current cached value and keep it
+ // the same.
+ long long dataSize = rs->dataSize(opCtx);
+ rs->updateStatsAfterRepair(opCtx, newCount, dataSize);
+ return Status::OK();
+}
+
StatusWith<OptionalCollectionUUID> StorageInterfaceImpl::getCollectionUUID(
OperationContext* opCtx, const NamespaceString& nss) {
AutoGetCollectionForRead autoColl(opCtx, nss);