feat: P2-5 repl_start/complete_catchup, repl_needs_snapshot — standby catch-up state

Implement the catch-up state machine as testable pure-logic functions:

- repl_start_catchup(): marks standby in_catch_up=1, stores join_applied_lsn
- repl_complete_catchup(): clears in_catch_up=0, broadcasts ack_cond so any
  blocked repl_wait_ack() re-checks the ACK condition immediately
- repl_needs_snapshot(): pure predicate — returns 1 when standby LSN predates
  oldest surviving WAL segment (snapshot transfer required), 0 otherwise

Also fixes pre-existing linker error: repl.c was missing from controller_src
(xce_controller production binary), causing undefined references to repl_*
symbols introduced in P2-4.

7 new TDD tests in test_repl_catchup.c — all pass. Existing tests green.
This commit is contained in:
Rongsong Shen 2026-05-07 18:14:12 +00:00
parent 3563d7387b
commit 6e4fd1aa81
5 changed files with 196 additions and 0 deletions

View file

@ -18,6 +18,7 @@ controller_src = [
'apiserver.c',
'myconf.c',
'persist.c',
'repl.c',
]
incdir = include_directories('.', '../include', '../lib',
@ -90,6 +91,7 @@ controller_unit_test_src = [
'testsuite/test_repl_unit.c',
'testsuite/test_repl_apply.c',
'testsuite/test_persist_repl.c',
'testsuite/test_repl_catchup.c',
'persist.c',
'ha.c',
'repl.c',