fix(server): lag is 0 when server not in stable state (#3010)

* fix server: lag is 0 when server not in stable state

Signed-off-by: adi_holden <adi@dragonflydb.io>
This commit is contained in:
adiholden 2024-05-06 10:17:11 +03:00 committed by GitHub
parent 816cec12ed
commit 135af96f2f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -688,13 +688,13 @@ std::vector<ReplicaRoleInfo> DflyCmd::GetReplicasRoleInfo() const {
// the same applies of course if its state is not STABLE_SYNC.
if (info->mu.try_lock()) {
state = info->replica_state;
// If the replica is not in stable sync, its lag is undefined, so we set it as max.
// If the replica is not in stable sync, its lag is undefined, so we set it to 0.
if (state != SyncState::STABLE_SYNC) {
lag = std::numeric_limits<LSN>::max();
lag = 0;
}
info->mu.unlock();
} else {
lag = std::numeric_limits<LSN>::max();
lag = 0;
}
vec.push_back(
ReplicaRoleInfo{info->id, info->address, info->listening_port, SyncStateName(state), lag});