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
|
|
@ -2593,8 +2593,13 @@ int ha_handle_snapshot_chunk(ha_state_t *ha, persist_t *p,
|
|||
return -err;
|
||||
}
|
||||
|
||||
/* Load the snapshot — sets p->checkpoint_lsn and p->current_lsn */
|
||||
int rc = persist_load_snapshot(p, final_path, chunk->snapshot_lsn);
|
||||
/* Load the snapshot — sets p->checkpoint_lsn and p->current_lsn.
|
||||
* ha-entity-snapshots task 5.1: call-site signature compat only for the
|
||||
* new out-param — entities_restored itself is not yet consumed here
|
||||
* (that is task 6.1's job, once 5.2 makes the flag meaningful). */
|
||||
bool entities_restored = false;
|
||||
int rc = persist_load_snapshot(p, final_path, chunk->snapshot_lsn,
|
||||
&entities_restored);
|
||||
if (rc != 0) {
|
||||
ERROR("ha_handle_snapshot_chunk: persist_load_snapshot failed rc=%d", rc);
|
||||
return rc;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue