From 4e4149b070a3ac021361e3567cba542ad7c81bc0 Mon Sep 17 00:00:00 2001 From: Evan Tschannen Date: Mon, 15 Mar 2021 10:43:06 -0700 Subject: [PATCH] exclude failed shuts down data distribution while the server is being removed to avoid two processes making changes to the key servers at the same time --- fdbserver/DataDistribution.actor.cpp | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/fdbserver/DataDistribution.actor.cpp b/fdbserver/DataDistribution.actor.cpp index 00fa458916..7509fd6bb9 100644 --- a/fdbserver/DataDistribution.actor.cpp +++ b/fdbserver/DataDistribution.actor.cpp @@ -658,6 +658,7 @@ struct DDTeamCollection : ReferenceCounted { AsyncTrigger printDetailedTeamsInfo; PromiseStream getShardMetrics; + Promise removeFailedServer; void resetLocalitySet() { storageServerSet = Reference(new LocalityMap()); @@ -695,7 +696,8 @@ struct DDTeamCollection : ReferenceCounted { Reference> zeroHealthyTeams, bool primary, Reference> processingUnhealthy, - PromiseStream getShardMetrics) + PromiseStream getShardMetrics, + Promise removeFailedServer) : cx(cx), distributorId(distributorId), lock(lock), output(output), shardsAffectedByTeamFailure(shardsAffectedByTeamFailure), doBuildTeams(true), lastBuildTeamsFailed(false), teamBuilder(Void()), badTeamRemover(Void()), checkInvalidLocalities(Void()), wrongStoreTypeRemover(Void()), @@ -710,7 +712,7 @@ struct DDTeamCollection : ReferenceCounted { zeroHealthyTeams(zeroHealthyTeams), zeroOptimalTeams(true), primary(primary), medianAvailableSpace(SERVER_KNOBS->MIN_AVAILABLE_SPACE_RATIO), lastMedianAvailableSpaceUpdate(0), processingUnhealthy(processingUnhealthy), lowestUtilizationTeam(0), highestUtilizationTeam(0), - getShardMetrics(getShardMetrics) { + getShardMetrics(getShardMetrics), removeFailedServer(removeFailedServer) { if (!primary || configuration.usableRegions == 1) { TraceEvent("DDTrackerStarting", distributorId).detail("State", "Inactive").trackLatest("DDTrackerStarting"); } @@ -4142,13 +4144,16 @@ ACTOR Future storageServerTracker( status.isUndesired = true; status.isWrongConfiguration = true; if (worstStatus == DDTeamCollection::Status::FAILED) { + while (!ddEnabledState->isDDEnabled()) { + wait(delay(1.0)); + } TraceEvent(SevWarn, "FailedServerRemoveKeys", self->distributorId) .detail("Server", server->id) .detail("Excluded", worstAddr.toString()); - wait(removeKeysFromFailedServer(cx, server->id, self->lock, ddEnabledState)); - if (BUGGIFY) - wait(delay(5.0)); - self->shardsAffectedByTeamFailure->eraseServer(server->id); + if (self->removeFailedServer.canBeSet()) { + self->removeFailedServer.send(server->id); + } + throw movekeys_conflict(); } } @@ -4973,7 +4978,7 @@ ACTOR Future dataDistribution(Reference self, // Stored outside of data distribution tracker to avoid slow tasks // when tracker is cancelled state KeyRangeMap shards; - + state Promise removeFailedServer; try { loop { TraceEvent("DDInitTakingMoveKeysLock", self->ddId); @@ -5204,7 +5209,8 @@ ACTOR Future dataDistribution(Reference self, zeroHealthyTeams[0], true, processingUnhealthy, - getShardMetrics); + getShardMetrics, + removeFailedServer); teamCollectionsPtrs.push_back(primaryTeamCollection.getPtr()); if (configuration.usableRegions > 1) { remoteTeamCollection = @@ -5220,7 +5226,8 @@ ACTOR Future dataDistribution(Reference self, zeroHealthyTeams[1], false, processingUnhealthy, - getShardMetrics); + getShardMetrics, + removeFailedServer); teamCollectionsPtrs.push_back(remoteTeamCollection.getPtr()); remoteTeamCollection->teamCollections = teamCollectionsPtrs; actors.push_back( @@ -5252,6 +5259,9 @@ ACTOR Future dataDistribution(Reference self, primaryTeamCollection = Reference(); remoteTeamCollection = Reference(); wait(shards.clearAsync()); + if (removeFailedServer.getFuture().isReady() && !removeFailedServer.getFuture().isError()) { + wait(removeKeysFromFailedServer(cx, removeFailedServer.getFuture().get(), lock, ddEnabledState)); + } if (err.code() != error_code_movekeys_conflict) throw err; bool ddEnabled = wait(isDataDistributionEnabled(cx, ddEnabledState));