feat(ha-repl-hardening): audit safe commit point and snapshot transfer tests (tasks 6.3, 6.4)

6.3: Fix single-node bug — ha_compute_safe_committed_lsn now returns
self_lsn instead of 0 for n_peers=0 (prevents WAL truncation on
single-node re-election). Add self_lsn/self_tag to ha_elect_ctx_t,
populated unconditionally in ha_start_election_async. All 3 test
scenarios pass under ASAN.

6.4: Add test_snapshot_recv_128kb_two_chunks (128KB snapshot in
2x64KB chunks, verifies size and applied_lsn); 4 other test cases
already existed from tasks 3.5c/3.5d. All ASAN-clean.
This commit is contained in:
Rongsong Shen 2026-06-05 06:21:00 +00:00
parent d41cfc5813
commit 345d51dd61
5 changed files with 160 additions and 23 deletions

View file

@ -219,14 +219,14 @@
- All tests pass under ASAN
- _Requirements: 3.1, 3.3, 3.4, 3.5, 5.3, 5.5_
- [ ] 6.3 Unit tests for safe commit point from vote replies
- [x] 6.3 Unit tests for safe commit point from vote replies
- Test: voters at LSNs `[99, 100]`, self at `100` → `safe_committed_lsn=100`
- Test: voters at LSNs `[50, 51]`, self at `50` → `safe_committed_lsn=51` (majority has 51)
- Test: single node → `safe_committed_lsn = self.applied_lsn`
- All tests pass under ASAN
- _Requirements: 2.3_
- [ ] 6.4 Unit tests for snapshot chunk transfer
- [x] 6.4 Unit tests for snapshot chunk transfer
- Test: 128KB snapshot in 2 chunks → standby receives, verifies total size, atomically renames, loads; `applied_lsn = checkpoint_lsn`
- Test: mid-transfer reconnect → standby discards `snap.part`, primary restarts from chunk 0 on reconnect
- Test: snapshot transfer only triggered when `standby_lsn < oldest_wal_lsn`