From 706164d8ae3f60e33e76aa02d200f133e046fdfb Mon Sep 17 00:00:00 2001 From: Sreenath Bodagala Date: Thu, 21 Apr 2022 20:59:42 +0000 Subject: [PATCH] - Address seg fault in "storageRecruiter" actor --- fdbserver/DDTeamCollection.actor.cpp | 6 ++++++ fdbserver/DDTeamCollection.h | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/fdbserver/DDTeamCollection.actor.cpp b/fdbserver/DDTeamCollection.actor.cpp index 1ac13b5c83..95916ee7cd 100644 --- a/fdbserver/DDTeamCollection.actor.cpp +++ b/fdbserver/DDTeamCollection.actor.cpp @@ -2631,7 +2631,11 @@ public: .detail("TSSID", tssId) .detail("Reason", self->zeroHealthyTeams->get() ? "ZeroHealthyTeams" : "TooMany"); + Promise shutdown = self->shutdown; killPromise.send(Void()); + if (!shutdown.canBeSet()) { + return Void(); // "self" got destroyed, so return. + } } } } @@ -3582,6 +3586,8 @@ DDTeamCollection::DDTeamCollection(Database const& cx, DDTeamCollection::~DDTeamCollection() { TraceEvent("DDTeamCollectionDestructed", distributorId).detail("Primary", primary); + // Signal that the object is being destroyed. + shutdown.send(Void()); // Cancel the teamBuilder to avoid creating new teams after teams are cancelled. teamBuilder.cancel(); diff --git a/fdbserver/DDTeamCollection.h b/fdbserver/DDTeamCollection.h index bf5fda8b28..529d2ead93 100644 --- a/fdbserver/DDTeamCollection.h +++ b/fdbserver/DDTeamCollection.h @@ -272,6 +272,12 @@ class DDTeamCollection : public ReferenceCounted { LocalityMap machineLocalityMap; // locality info of machines + // A mechanism to tell actors that reference a DDTeamCollection object through a direct + // pointer (without doing reference counting) that the object is being destroyed. + // (Introduced to solve the problem of "self" getting destroyed from underneath the + // "storageRecruiter" actor). + Promise shutdown; + // Randomly choose one machine team that has chosenServer and has the correct size // When configuration is changed, we may have machine teams with old storageTeamSize Reference findOneRandomMachineTeam(TCServerInfo const& chosenServer) const;