From ada51ff12bc231269a7cd4e5dd09225b7214db5b Mon Sep 17 00:00:00 2001 From: Zhe Wu Date: Wed, 19 Oct 2022 22:09:04 -0700 Subject: [PATCH] Add a counter to track physical shard creation throuogh moves --- fdbserver/DDRelocationQueue.actor.cpp | 19 ++++++++++++++++++- fdbserver/DDShardTracker.actor.cpp | 4 ++++ .../fdbserver/DataDistribution.actor.h | 3 +++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/fdbserver/DDRelocationQueue.actor.cpp b/fdbserver/DDRelocationQueue.actor.cpp index 46bb435145..b460e53cf4 100644 --- a/fdbserver/DDRelocationQueue.actor.cpp +++ b/fdbserver/DDRelocationQueue.actor.cpp @@ -687,6 +687,9 @@ struct DDQueue : public IDDRelocationQueue { Reference movedKeyServersEventHolder; + int moveReusePhysicalShard; + int moveCreateNewPhysicalShard; + void startRelocation(int priority, int healthPriority) { // Although PRIORITY_TEAM_REDUNDANT has lower priority than split and merge shard movement, // we must count it into unhealthyRelocations; because team removers relies on unhealthyRelocations to @@ -750,7 +753,8 @@ struct DDQueue : public IDDRelocationQueue { output(output), input(input), getShardMetrics(getShardMetrics), getTopKMetrics(getTopKMetrics), lastInterval(0), suppressIntervals(0), rawProcessingUnhealthy(new AsyncVar(false)), rawProcessingWiggle(new AsyncVar(false)), unhealthyRelocations(0), - movedKeyServersEventHolder(makeReference("MovedKeyServers")) {} + movedKeyServersEventHolder(makeReference("MovedKeyServers")), moveReusePhysicalShard(0), + moveCreateNewPhysicalShard(0) {} DDQueue() = default; void validate() { @@ -1676,6 +1680,11 @@ ACTOR Future dataDistributionRelocator(DDQueue* self, // when !rd.isRestore(), dataMoveId is just decided as physicalShardIDCandidate // thus, update the physicalShardIDCandidate to related data structures ASSERT(physicalShardIDCandidate != UID().first()); + if (self->physicalShardCollection->physicalShardExists(physicalShardIDCandidate)) { + self->moveReusePhysicalShard++; + } else { + self->moveCreateNewPhysicalShard++; + } rd.dataMoveId = newShardId(physicalShardIDCandidate, AssignEmptyRange::False); auto inFlightRange = self->inFlight.rangeContaining(rd.keys.begin); inFlightRange.value().dataMoveId = rd.dataMoveId; @@ -2472,6 +2481,14 @@ ACTOR Future dataDistributionQueue(Reference db, .trackLatest("MovingData"); // This trace event's trackLatest lifetime is controlled by // DataDistributor::movingDataEventHolder. The track latest // key we use here must match the key used in the holder. + + if (SERVER_KNOBS->SHARD_ENCODE_LOCATION_METADATA && SERVER_KNOBS->ENABLE_DD_PHYSICAL_SHARD) { + TraceEvent("PhysicalShardMoveStats") + .detail("MoveCreateNewPhysicalShard", self.moveCreateNewPhysicalShard) + .detail("MoveReusePhysicalShard", self.moveReusePhysicalShard); + self.moveCreateNewPhysicalShard = 0; + self.moveReusePhysicalShard = 0; + } } when(wait(self.error.getFuture())) {} // Propagate errors from dataDistributionRelocator when(wait(waitForAll(ddQueueFutures))) {} diff --git a/fdbserver/DDShardTracker.actor.cpp b/fdbserver/DDShardTracker.actor.cpp index 5c17bc1ab5..be7343ba4c 100644 --- a/fdbserver/DDShardTracker.actor.cpp +++ b/fdbserver/DDShardTracker.actor.cpp @@ -2081,6 +2081,10 @@ void PhysicalShardCollection::logPhysicalShardCollection() { } } +bool PhysicalShardCollection::physicalShardExists(uint64_t physicalShardID) { + return physicalShardInstances.find(physicalShardID) != physicalShardInstances.end(); +} + // FIXME: complete this test with non-empty range TEST_CASE("/DataDistributor/Tracker/FetchTopK") { state DataDistributionTracker self; diff --git a/fdbserver/include/fdbserver/DataDistribution.actor.h b/fdbserver/include/fdbserver/DataDistribution.actor.h index e8016101e3..2389dc0ab6 100644 --- a/fdbserver/include/fdbserver/DataDistribution.actor.h +++ b/fdbserver/include/fdbserver/DataDistribution.actor.h @@ -322,6 +322,9 @@ public: // Log physicalShard void logPhysicalShardCollection(); + // Checks if a physical shard exists. + bool physicalShardExists(uint64_t physicalShardID); + private: // Track physicalShard metrics by tracking keyRange metrics void updatePhysicalShardMetricsByKeyRange(KeyRange keyRange,