From 0dc262a84a58e5a341b250ea8957636751a2bf74 Mon Sep 17 00:00:00 2001 From: Arthur Petukhovsky Date: Tue, 29 Aug 2023 14:11:04 +0000 Subject: [PATCH] Fix bug in walproposer voting --- pgxn/neon/walproposer.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pgxn/neon/walproposer.c b/pgxn/neon/walproposer.c index a858c5cdea..ae1587ca34 100644 --- a/pgxn/neon/walproposer.c +++ b/pgxn/neon/walproposer.c @@ -1455,6 +1455,7 @@ static void DetermineEpochStartLsn(void) { TermHistory *dth; + int n_ready = 0; propEpochStartLsn = InvalidXLogRecPtr; donorEpoch = 0; @@ -1465,6 +1466,8 @@ DetermineEpochStartLsn(void) { if (safekeeper[i].state == SS_IDLE) { + n_ready++; + if (GetEpoch(&safekeeper[i]) > donorEpoch || (GetEpoch(&safekeeper[i]) == donorEpoch && safekeeper[i].voteResponse.flushLsn > propEpochStartLsn)) @@ -1491,6 +1494,9 @@ DetermineEpochStartLsn(void) } } + if (n_ready < quorum) + walprop_log(FATAL, "missing majority of votes, expected %d, got %d", n_votes, n_ready); + /* * If propEpochStartLsn is 0 everywhere, we are bootstrapping -- nothing * was committed yet. Start streaming then from the basebackup LSN.