summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjannaerin <golden.janna@gmail.com>2018-01-31 17:41:29 -0500
committerjannaerin <golden.janna@gmail.com>2018-02-05 16:09:34 -0500
commit2e1f172bc139adce256ada5675f0197bb2949ddc (patch)
tree7b04ee0a57f00b1a6c62c2971759eafad47887d5 /src
parentde68ddc251d6d0d8b2ba1162f9798e8fb9ff3f0a (diff)
downloadmongo-2e1f172bc139adce256ada5675f0197bb2949ddc.tar.gz
SERVER-31979 Include chunk migration stats in `moveChunk.commit` changelog entries
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/s/migration_chunk_cloner_source.h2
-rw-r--r--src/mongo/db/s/migration_chunk_cloner_source_legacy.cpp5
-rw-r--r--src/mongo/db/s/migration_chunk_cloner_source_legacy.h2
-rw-r--r--src/mongo/db/s/migration_source_manager.cpp12
-rw-r--r--src/mongo/db/s/migration_source_manager.h3
5 files changed, 17 insertions, 7 deletions
diff --git a/src/mongo/db/s/migration_chunk_cloner_source.h b/src/mongo/db/s/migration_chunk_cloner_source.h
index ff3d31132fa..65b2a6d23f6 100644
--- a/src/mongo/db/s/migration_chunk_cloner_source.h
+++ b/src/mongo/db/s/migration_chunk_cloner_source.h
@@ -95,7 +95,7 @@ public:
*
* NOTE: Must be called without any locks.
*/
- virtual Status commitClone(OperationContext* opCtx) = 0;
+ virtual StatusWith<BSONObj> commitClone(OperationContext* opCtx) = 0;
/**
* Tells the recipient to abort the clone and cleanup any unused data. This method's
diff --git a/src/mongo/db/s/migration_chunk_cloner_source_legacy.cpp b/src/mongo/db/s/migration_chunk_cloner_source_legacy.cpp
index 95914f9c4b0..78cf1102ef4 100644
--- a/src/mongo/db/s/migration_chunk_cloner_source_legacy.cpp
+++ b/src/mongo/db/s/migration_chunk_cloner_source_legacy.cpp
@@ -332,7 +332,7 @@ Status MigrationChunkClonerSourceLegacy::awaitUntilCriticalSectionIsAppropriate(
return {ErrorCodes::ExceededTimeLimit, "Timed out waiting for the cloner to catch up"};
}
-Status MigrationChunkClonerSourceLegacy::commitClone(OperationContext* opCtx) {
+StatusWith<BSONObj> MigrationChunkClonerSourceLegacy::commitClone(OperationContext* opCtx) {
invariant(_state == kCloning);
invariant(!opCtx->lockState()->isLocked());
@@ -346,7 +346,8 @@ Status MigrationChunkClonerSourceLegacy::commitClone(OperationContext* opCtx) {
"destination shard finished committing but there are still some session "
"metadata that needs to be transferred"};
}
- return Status::OK();
+
+ return responseStatus;
}
cancelClone(opCtx);
diff --git a/src/mongo/db/s/migration_chunk_cloner_source_legacy.h b/src/mongo/db/s/migration_chunk_cloner_source_legacy.h
index 28981b21c15..17979a5c2ef 100644
--- a/src/mongo/db/s/migration_chunk_cloner_source_legacy.h
+++ b/src/mongo/db/s/migration_chunk_cloner_source_legacy.h
@@ -68,7 +68,7 @@ public:
Status awaitUntilCriticalSectionIsAppropriate(OperationContext* opCtx,
Milliseconds maxTimeToWait) override;
- Status commitClone(OperationContext* opCtx) override;
+ StatusWith<BSONObj> commitClone(OperationContext* opCtx) override;
void cancelClone(OperationContext* opCtx) override;
diff --git a/src/mongo/db/s/migration_source_manager.cpp b/src/mongo/db/s/migration_source_manager.cpp
index fb1ebee0293..558e32f667a 100644
--- a/src/mongo/db/s/migration_source_manager.cpp
+++ b/src/mongo/db/s/migration_source_manager.cpp
@@ -358,7 +358,7 @@ Status MigrationSourceManager::commitChunkOnRecipient(OperationContext* opCtx) {
auto scopedGuard = MakeGuard([&] { cleanupOnError(opCtx); });
// Tell the recipient shard to fetch the latest changes.
- Status commitCloneStatus = _cloneDriver->commitClone(opCtx);
+ auto commitCloneStatus = _cloneDriver->commitClone(opCtx);
if (MONGO_FAIL_POINT(failMigrationCommit) && commitCloneStatus.isOK()) {
commitCloneStatus = {ErrorCodes::InternalError,
@@ -366,7 +366,11 @@ Status MigrationSourceManager::commitChunkOnRecipient(OperationContext* opCtx) {
}
if (!commitCloneStatus.isOK()) {
- return commitCloneStatus.withContext("commit clone failed");
+ return commitCloneStatus.getStatus().withContext("commit clone failed");
+ }
+
+ if (commitCloneStatus.getValue()["counts"].type() == BSONType::Object) {
+ _recipientCloneCounts = commitCloneStatus.getValue()["counts"].Obj().getOwned();
}
_state = kCloneCompleted;
@@ -571,7 +575,9 @@ Status MigrationSourceManager::commitChunkMetadataOnConfig(OperationContext* opC
BSON("min" << _args.getMinKey() << "max" << _args.getMaxKey() << "from"
<< _args.getFromShardId()
<< "to"
- << _args.getToShardId()),
+ << _args.getToShardId()
+ << "counts"
+ << _recipientCloneCounts),
ShardingCatalogClient::kMajorityWriteConcern)
.ignore();
diff --git a/src/mongo/db/s/migration_source_manager.h b/src/mongo/db/s/migration_source_manager.h
index 050fd8e43bf..cb24599e519 100644
--- a/src/mongo/db/s/migration_source_manager.h
+++ b/src/mongo/db/s/migration_source_manager.h
@@ -250,6 +250,9 @@ private:
// The transition from false to true is protected by the collection X-lock, which happens just
// before the config server metadata commit is scheduled.
bool _readsShouldWaitOnCritSec{false};
+
+ // The statistics about a chunk migration to be included in moveChunk.commit
+ BSONObj _recipientCloneCounts;
};
} // namespace mongo