diff options
author | Vishnu Kaushik <vishnu.kaushik@mongodb.com> | 2021-04-20 16:45:17 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-04-21 16:09:26 +0000 |
commit | 87488185ced2c3035a8df51eaf22b03fc980b555 (patch) | |
tree | 6e8eb5edbb10393437a099ff9c083a68b25be5d9 /src/mongo/db/repl/tenant_database_cloner.cpp | |
parent | ded506addbb8e3821eb84604bd5c4a7458cabb45 (diff) | |
download | mongo-87488185ced2c3035a8df51eaf22b03fc980b555.tar.gz |
SERVER-55229 Implement and test recipient cloner stats after failover
Diffstat (limited to 'src/mongo/db/repl/tenant_database_cloner.cpp')
-rw-r--r-- | src/mongo/db/repl/tenant_database_cloner.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/mongo/db/repl/tenant_database_cloner.cpp b/src/mongo/db/repl/tenant_database_cloner.cpp index a955b15e973..5258e335151 100644 --- a/src/mongo/db/repl/tenant_database_cloner.cpp +++ b/src/mongo/db/repl/tenant_database_cloner.cpp @@ -178,6 +178,9 @@ BaseCloner::AfterStageBehavior TenantDatabaseCloner::listExistingCollectionsStag tenantMigrationRecipientInfo(opCtx.get()) = boost::make_optional<TenantMigrationRecipientInfo>(getSharedData()->getMigrationId()); + long long sizeOfCurrCollOnDisk = 0; + long long approxTotalDBSizeOnDisk = 0; + std::vector<UUID> clonedCollectionUUIDs; auto collectionInfos = client.getCollectionInfos(_dbName, ListCollectionsFilter::makeTypeCollectionFilter()); @@ -204,6 +207,22 @@ BaseCloner::AfterStageBehavior TenantDatabaseCloner::listExistingCollectionsStag continue; } clonedCollectionUUIDs.emplace_back(result.getInfo().getUuid()); + + BSONObj res; + client.runCommand(_dbName, BSON("collStats" << result.getName()), res); + if (auto status = getStatusFromCommandResult(res); !status.isOK()) { + LOGV2_WARNING(5522901, + "Skipping recording of data size metrics for database due to failure " + "in the 'collStats' command, tenant migration stats may be inaccurate.", + "db"_attr = _dbName, + "coll"_attr = result.getName(), + "migrationId"_attr = getSharedData()->getMigrationId(), + "tenantId"_attr = _tenantId, + "status"_attr = status); + } else { + sizeOfCurrCollOnDisk = res.getField("size").safeNumberLong(); + approxTotalDBSizeOnDisk += sizeOfCurrCollOnDisk; + } } if (!getSharedData()->isResuming()) { @@ -228,8 +247,14 @@ BaseCloner::AfterStageBehavior TenantDatabaseCloner::listExistingCollectionsStag if (startingCollection != _collections.end() && startingCollection->second.uuid == lastClonedCollectionUUID) { _stats.clonedCollectionsBeforeFailover = clonedCollectionUUIDs.size() - 1; + + // When the last collection is partially cloned, we exclude it from the total size + // on disk, as the partially cloned collections stats will be added by the cloner + // on demand. + _stats.approxTotalBytesCopied = approxTotalDBSizeOnDisk - sizeOfCurrCollOnDisk; } else { _stats.clonedCollectionsBeforeFailover = clonedCollectionUUIDs.size(); + _stats.approxTotalBytesCopied = approxTotalDBSizeOnDisk; } } _collections.erase(_collections.begin(), startingCollection); |