forked from lei.chen/myxce
test(ha-entity-snapshots): RED tests for load_snapshot restore contract (task 5.1)
Extends persist_load_snapshot's public signature with an
out_entities_restored bool*, per design.md's documented contract. The
static load_snapshot function -- the real restore logic -- is completely
untouched (still today's watermark-only implementation, byte-identical
to before this task); only a thin wrapper was added that naively maps
*out_entities_restored = (rc==0), deliberately scaffolding so the 3 new
RED tests fail for genuine reasons rather than accidentally passing.
ha_handle_snapshot_chunk's sole call site gets a mechanical
declare-and-pass update -- confirmed inert, never reads the new
out-param (task 6.1's job).
Three tests against persist_load_snapshot directly (unlike prior tasks'
tests, which deliberately stayed on the raw-byte-parsing side to avoid
this exact function): restore-before-advance (fails at the job-lookup
assertion -- nothing is ever restored today), corrupted-entity-leaves-
position-unchanged (fails at rc!=0 -- today's code ignores the corrupted
section entirely, since load_snapshot never reads past the legacy
header), legacy-file-reports-position-only (fails at entities_restored==
false -- the naive wrapper claims restoration for every rc==0 case,
including legacy files).
This is the exact function/call site that caused task 2.2's rejection
(a live position-advances-before-restore-validates hazard). Independent
review verified load_snapshot's body is byte-identical to commit
d52eb94, the wrapper does nothing beyond the naive mapping, and ha.c's
change never reads the new out-param anywhere -- no repeat of that
mistake here.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JDYFbrgyDHbvNYcxApKhrX
This commit is contained in:
parent
d52eb944c2
commit
a8e300d96a
5 changed files with 336 additions and 7 deletions
|
|
@ -650,8 +650,19 @@ int apply_wal_entry(persist_t* p, uint32_t type, uint64_t lsn,
|
|||
|
||||
/* Load a snapshot file from path, set p->checkpoint_lsn and p->current_lsn.
|
||||
* lsn hint is informational — the actual LSN is read from the file header.
|
||||
*
|
||||
* ha-entity-snapshots (task 5.2 owns the restore-before-advance
|
||||
* implementation; this is the public signature it will fill in):
|
||||
* out_entities_restored reports whether this call actually restored
|
||||
* job/queue entity state (true) or only observed a legacy position marker
|
||||
* (false) — set ONLY when this function returns 0. On a non-zero return,
|
||||
* p->checkpoint_lsn/p->current_lsn are left completely unchanged and
|
||||
* *out_entities_restored is left untouched (undefined) — callers must not
|
||||
* read it in that case.
|
||||
*
|
||||
* Returns 0 on success, -errno or -EINVAL/-EIO on error. */
|
||||
int persist_load_snapshot(persist_t* p, const char* path, uint64_t lsn);
|
||||
int persist_load_snapshot(persist_t* p, const char* path, uint64_t lsn,
|
||||
bool* out_entities_restored);
|
||||
|
||||
/* GC retention predicates (P0-5a / P0-8 / P0-13) */
|
||||
#include <stdbool.h>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue