feat(ha-commit-durability): durable-backed vote/PreVote freshness floor + bare-durable candidate advertise (task 4.2)

This commit is contained in:
Rongsong Shen 2026-06-18 09:02:11 +00:00
parent 4b7457144c
commit 3049b620f3
7 changed files with 282 additions and 26 deletions

View file

@ -546,11 +546,19 @@ static void test_rdhup_candidate_advertises_freshness_floor_not_stale_committed(
/* Standby state after applying WAL + learning commits from the (now-dead)
* primary: applied_lsn and last_known_committed_lsn advanced to 10, but
* persist.committed_lsn is still 0 — a standby never advances it. */
* persist.committed_lsn is still 0 — a standby never advances it.
*
* ha-commit-durability task 4.2: the candidate now advertises the BARE
* DURABLE WAL tip (persist_durable_floor), not the folded
* max(applied_lsn, learned_committed). Model the standby holding its log
* durably up to LSN 10 by priming the durable watermark — this is the
* durable-backed analog of the original "advertise the freshness floor, not
* the stale committed_lsn" guarantee (still NOT 0). */
atomic_store_explicit(&c.ha.applied_lsn, 10ULL, memory_order_release);
atomic_store_explicit(&c.ha.last_known_committed_lsn, 10ULL,
memory_order_release);
atomic_store_explicit(&c.persist.committed_lsn, 0ULL, memory_order_release);
atomic_store_explicit(&c.persist.durable_lsn, 10ULL, memory_order_release);
ha_rdhup_election_hook = capture_lsn_hook;
@ -564,9 +572,10 @@ static void test_rdhup_candidate_advertises_freshness_floor_not_stale_committed(
close(sv[1]);
TEST_ASSERT_EQUAL_UINT64_MESSAGE(10ULL, g_captured_my_lsn,
"RDHUP candidate must advertise effective freshness floor "
"(applied/learned-committed = 10), not stale persist.committed_lsn (0); "
"otherwise surviving standbys mutually deny votes -> infinite election loop");
"RDHUP candidate must advertise its DURABLE WAL tip (durable_floor = 10), "
"not the stale persist.committed_lsn (0); otherwise surviving standbys "
"mutually deny votes -> infinite election loop (bug-339; task 4.2 makes "
"this the durable tip, not max(applied,learned))");
TEST_ASSERT_EQUAL_UINT64_MESSAGE((uint64_t)TEST_CONFIG_TAG, g_captured_my_tag,
"RDHUP candidate must advertise its config_version_tag");