- Address seg fault in "storageRecruiter" actor

This commit is contained in:
Sreenath Bodagala 2022-04-21 20:59:42 +00:00 committed by Jingyu Zhou
parent b8fbd18199
commit 706164d8ae
2 changed files with 12 additions and 0 deletions

View File

@ -2631,7 +2631,11 @@ public:
.detail("TSSID", tssId)
.detail("Reason",
self->zeroHealthyTeams->get() ? "ZeroHealthyTeams" : "TooMany");
Promise<Void> 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();

View File

@ -272,6 +272,12 @@ class DDTeamCollection : public ReferenceCounted<DDTeamCollection> {
LocalityMap<UID> 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<Void> 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<TCMachineTeamInfo> findOneRandomMachineTeam(TCServerInfo const& chosenServer) const;