feat: P2-1 repl.h/repl.c — replicator lifecycle, slot management, trim_lsn

Add replicator_t structure with per-standby connection slots (standby_conn_t),
lifecycle (repl_init/repl_fini), slot management (repl_add_standby,
repl_remove_standby, repl_expire_disconnect_slots), ACK tracking
(repl_on_ack), WAL trim guard (repl_trim_lsn), and stubs for
repl_broadcast/repl_wait_ack (wired in P2-3/P2-4).

Uses mylock_t (pthread_mutex_t alias) with mylock_lock/mylock_unlock.
snap_interval_s==0 in repl_expire_disconnect_slots forces immediate expiry
to support deterministic unit testing.

5 new Unity tests all pass; 115 pre-existing controller tests unchanged.
This commit is contained in:
Rongsong Shen 2026-05-07 16:25:03 +00:00
parent 05c00704d3
commit 8ef64a7ee7
5 changed files with 397 additions and 0 deletions

View file

@ -23,6 +23,7 @@ extern void test_ha_role(void);
extern void test_ha_cluster(void);
extern void test_ha_redirect(void);
extern void test_p1_integration(void);
extern void test_repl_unit(void);
void setUp(void) { return; }
@ -115,6 +116,7 @@ int main(int argc, char* argv[])
TEST(test_ha_cluster);
TEST(test_ha_redirect);
TEST(test_p1_integration);
TEST(test_repl_unit);
return UNITY_END();
}