forked from lei.chen/myxce
feat: P2-2 apply_wal_entry — standby WAL replay with LSN advance and type guards
Upgrade apply_wal_entry() from P0 static no-op stub to the real public standby replay path: - Reject oversized payloads (> MAX_WAL_PAYLOAD_BYTES) with -EMSGSIZE - Skip WAL_CHECKPOINT (100) entries silently — local-only markers, never replicated to standbys; current_lsn is NOT advanced on skip - Skip unknown types (> WAL_ENTRY_TYPE_MAX) with WARN log and rc=0 for forward compatibility with WAL written by newer controller versions - Advance current_lsn to hdr->lsn+1 and update last_crc under p->lock for all accepted known entries - Gate restore_job()/worker_from_capnp() calls on p->cluster != NULL so unit tests work without a full cluster wired in - Add NULL guard returning -EINVAL for missing p or hdr Add public declaration in persist.h with forward-declare stubs for restore_job/worker_from_capnp in persist.c (avoids heavy cluster.h chain). Test suite: 5 new Unity tests in test_repl_apply.c covering all branches. Weak stubs for restore_job/worker_from_capnp in the test file satisfy the linker without linking job.c/worker.c's heavy dependency graph. All 5 new tests pass; full controller suite green.
This commit is contained in:
parent
8ef64a7ee7
commit
abefc8a128
5 changed files with 275 additions and 7 deletions
|
|
@ -24,6 +24,7 @@ extern void test_ha_cluster(void);
|
|||
extern void test_ha_redirect(void);
|
||||
extern void test_p1_integration(void);
|
||||
extern void test_repl_unit(void);
|
||||
extern void test_repl_apply(void);
|
||||
|
||||
void setUp(void) { return; }
|
||||
|
||||
|
|
@ -117,6 +118,7 @@ int main(int argc, char* argv[])
|
|||
TEST(test_ha_redirect);
|
||||
TEST(test_p1_integration);
|
||||
TEST(test_repl_unit);
|
||||
TEST(test_repl_apply);
|
||||
|
||||
return UNITY_END();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue