diff --git a/fdbclient/Schemas.cpp b/fdbclient/Schemas.cpp index ec17d72418..69854f58b6 100644 --- a/fdbclient/Schemas.cpp +++ b/fdbclient/Schemas.cpp @@ -30,6 +30,7 @@ const KeyRef JSONSchemas::statusSchema = LiteralStringRef(R"statusSchema( "wiggle_server_addresses": ["127.0.0.1"], "primary": { "state": {"$enum":["running", "paused", "unknown"]}, + "last_state_change_datetime": "2022-04-02 00:05:05.123 +0000", "last_state_change_timestamp": 1648857905.123, "last_round_start_datetime": "2022-04-02 00:05:05.123 +0000", "last_round_start_timestamp": 1648857905.123, @@ -46,6 +47,7 @@ const KeyRef JSONSchemas::statusSchema = LiteralStringRef(R"statusSchema( }, "remote": { "state": {"$enum":["running", "paused", "unknown"]}, + "last_state_change_datetime": "2022-04-02 00:05:05.123 +0000", "last_state_change_timestamp": 1648857905.123, "last_round_start_datetime": "2022-04-02 00:05:05.123 +0000", "last_round_start_timestamp": 1648857905.123, diff --git a/fdbserver/DDTeamCollection.actor.cpp b/fdbserver/DDTeamCollection.actor.cpp index 0117cafb5b..8ccc7f6059 100644 --- a/fdbserver/DDTeamCollection.actor.cpp +++ b/fdbserver/DDTeamCollection.actor.cpp @@ -1954,7 +1954,7 @@ public: teamCollection->server_info.size() <= teamCollection->configuration.storageTeamSize || teamCollection->machine_info.size() < teamCollection->configuration.storageTeamSize; if (takeRest) { - teamCollection->storageWiggler->setState(StorageWiggler::PAUSE); + teamCollection->storageWiggler->setWiggleState(StorageWiggler::PAUSE); if (teamCollection->configuration.storageMigrationType == StorageMigrationType::GRADUAL) { TraceEvent(SevWarn, "PerpetualStorageWiggleSleep", teamCollection->distributorId) .suppressFor(SERVER_KNOBS->PERPETUAL_WIGGLE_DELAY * 4) @@ -2032,7 +2032,7 @@ public: TEST(true); // paused because cluster is unhealthy moveFinishFuture = Never(); self->includeStorageServersForWiggle(); - self->storageWiggler->setState(StorageWiggler::PAUSE); + self->storageWiggler->setWiggleState(StorageWiggler::PAUSE); TraceEvent(self->configuration.storageMigrationType == StorageMigrationType::AGGRESSIVE ? SevInfo : SevWarn, "PerpetualStorageWigglePause", @@ -2049,7 +2049,7 @@ public: wait(self->storageWiggler->startWiggle()); auto fv = self->excludeStorageServersForWiggle(id); moveFinishFuture = fv; - self->storageWiggler->setState(StorageWiggler::RUN); + self->storageWiggler->setWiggleState(StorageWiggler::RUN); TraceEvent("PerpetualStorageWiggleStart", self->distributorId) .detail("Primary", self->primary) .detail("ServerId", id) @@ -5078,7 +5078,7 @@ bool DDTeamCollection::exclusionSafetyCheck(std::vector& excludeServerIDs) std::pair DDTeamCollection::getStorageWigglerState() const { if (storageWiggler) { - return { storageWiggler->getState(), storageWiggler->lastStateChangeTs }; + return { storageWiggler->getWiggleState(), storageWiggler->lastStateChangeTs }; } return { StorageWiggler::INVALID, 0.0 }; } diff --git a/fdbserver/DataDistribution.actor.h b/fdbserver/DataDistribution.actor.h index 92f5ecea3e..51e6331678 100644 --- a/fdbserver/DataDistribution.actor.h +++ b/fdbserver/DataDistribution.actor.h @@ -390,7 +390,7 @@ struct StorageWiggleMetrics { }; struct StorageWiggler : ReferenceCounted { - enum State : uint8_t { INVALID = 0, RUN, PAUSE }; + enum State : uint8_t { INVALID = 0, RUN = 1, PAUSE = 2 }; AsyncVar nonEmpty; DDTeamCollection const* teamCollection; StorageWiggleMetrics metrics; @@ -401,7 +401,7 @@ struct StorageWiggler : ReferenceCounted { wiggle_pq; std::unordered_map pq_handles; - State _state = State::INVALID; + State wiggleState = State::INVALID; double lastStateChangeTs = 0.0; // timestamp describes when did the state change explicit StorageWiggler(DDTeamCollection* collection) : nonEmpty(false), teamCollection(collection){}; @@ -415,14 +415,14 @@ struct StorageWiggler : ReferenceCounted { bool empty() const { return wiggle_pq.empty(); } Optional getNextServerId(); - State getState() const { return _state; } - void setState(State s) { - if (_state != s) { - _state = s; + State getWiggleState() const { return wiggleState; } + void setWiggleState(State s) { + if (wiggleState != s) { + wiggleState = s; lastStateChangeTs = g_network->now(); } } - static std::string getStateStr(State s) { + static std::string getWiggleStateStr(State s) { switch (s) { case State::RUN: return "running"; diff --git a/fdbserver/Status.actor.cpp b/fdbserver/Status.actor.cpp index e07b39ffbc..1766cc98a9 100644 --- a/fdbserver/Status.actor.cpp +++ b/fdbserver/Status.actor.cpp @@ -2814,8 +2814,9 @@ ACTOR Future storageWigglerStatsFetcher(Optional(primaryV.get(), IncludeVersion()).toJSON(); if (stateFut.canGet() && stateFut.get().present()) { auto& reply = stateFut.get().get(); - obj["state"] = StorageWiggler::getStateStr(static_cast(reply.primary)); + obj["state"] = StorageWiggler::getWiggleStateStr(static_cast(reply.primary)); obj["last_state_change_timestamp"] = reply.lastStateChangePrimary; + obj["last_state_change_datetime"] = epochsToGMTString(reply.lastStateChangePrimary); } res["primary"] = obj; } @@ -2823,8 +2824,9 @@ ACTOR Future storageWigglerStatsFetcher(Optional(remoteV.get(), IncludeVersion()).toJSON(); if (stateFut.canGet() && stateFut.get().present()) { auto& reply = stateFut.get().get(); - obj["state"] = StorageWiggler::getStateStr(static_cast(reply.remote)); + obj["state"] = StorageWiggler::getWiggleStateStr(static_cast(reply.remote)); obj["last_state_change_timestamp"] = reply.lastStateChangeRemote; + obj["last_state_change_datetime"] = epochsToGMTString(reply.lastStateChangeRemote); } res["remote"] = obj; }