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
|
|
@ -88,6 +88,7 @@ controller_unit_test_src = [
|
|||
'testsuite/test_ha_redirect.c',
|
||||
'testsuite/test_p1_integration.c',
|
||||
'testsuite/test_repl_unit.c',
|
||||
'testsuite/test_repl_apply.c',
|
||||
'persist.c',
|
||||
'ha.c',
|
||||
'repl.c',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue