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

@ -26,6 +26,7 @@ extern void test_p1_integration(void);
extern void test_repl_unit(void);
extern void test_repl_apply(void);
extern void test_persist_repl(void);
extern void test_repl_catchup(void);
void setUp(void) { return; }
@ -121,6 +122,7 @@ int main(int argc, char* argv[])
TEST(test_repl_unit);
TEST(test_repl_apply);
TEST(test_persist_repl);
TEST(test_repl_catchup);
return UNITY_END();
}