feat(ha-repl-hardening): set committed_lsn from vote-derived safe point (task 4.2)

- In raft_cb_become_leader, after persist_truncate_wal_above(safe_lsn),
  store safe_lsn to ha->last_known_committed_lsn via atomic release
- Test: 3-node voters [100,150,200] → safe_lsn=150; asserts
  ha->last_known_committed_lsn == 150 after raft_cb_become_leader_for_test
This commit is contained in:
Rongsong Shen 2026-06-05 03:28:59 +00:00
parent e7919304c3
commit 5915150c3b
3 changed files with 118 additions and 1 deletions

View file

@ -468,6 +468,17 @@ static void raft_cb_become_leader(void *ctx, uint64_t term)
if (c) {
persist_truncate_wal_above(&c->persist, safe_lsn);
}
/* Task 4.2 (ha-repl-hardening): set committed_lsn = safe_lsn.
* persist_truncate_wal_above already sets c->persist.committed_lsn
* in the production path (c != NULL). Also update
* ha->last_known_committed_lsn so the test-mode decision loop
* (XCE_TESTING path in standby heartbeat reply handler) and any
* code reading ha->last_known_committed_lsn see the safe commit
* point immediately after promotion.
* Design §Flow 0 step 5: committed_lsn = safe_committed_lsn.
* Req 2.3 (ha-repl-hardening). */
atomic_store_explicit(&ha->last_known_committed_lsn, safe_lsn,
memory_order_release);
/* Update committed config tag baseline for the COMMITTING decision loop */
atomic_store_explicit(&ha->committed_config_tag, safe_tag,
memory_order_release);