feat(ha-entity-snapshots): log legacy-vs-entity fallback in local boot recovery (task 8.1)

persist_recover's local snapshot load passed NULL for out_entities_restored,
so a rolling-upgrade restart against a pre-feature checkpoint had no
observability parity with the wire receive path's (task 6.1) INFO log.
Mirror the same conditional logging here; no behavior change, WAL replay
in Step 3 still applies unconditionally either way.

Live-verified in a 3-node cluster: planted a hand-crafted 16-byte legacy
sentinel as ctrl-1's own checkpoint file, restarted all 3 — no crash, INFO
log fired, ctrl-1 was elected primary serving the full 37-job list, and
walcompare confirmed all 3 members' committed prefixes (LSN 1..49) are
byte-identical.
This commit is contained in:
Rongsong Shen 2026-07-01 09:20:09 +00:00
parent 3fab29114f
commit 02dfedfbe8
2 changed files with 32 additions and 6 deletions

View file

@ -2789,16 +2789,30 @@ int persist_recover(persist_t* p)
/* --- Step 2: load snapshot (if any) --- */
if (snap_lsn > 0 && snap_file[0] != '\0') {
/* Local recovery doesn't need the entities-restored indicator: the
* WAL replay in Step 3 applies everything above checkpoint_lsn
* regardless, unchanged by ha-entity-snapshots. */
int rc = load_snapshot(p, snap_file, snap_lsn, NULL);
/* Local recovery doesn't need the entities-restored indicator to
* decide behavior: the WAL replay in Step 3 applies everything
* above checkpoint_lsn regardless, unchanged by ha-entity-snapshots.
* It IS consumed for observability parity with the wire receive
* path (ha_handle_snapshot_chunk, task 6.1) — a rolling-upgrade
* restart against a pre-feature (legacy, position-only) local
* checkpoint is an expected rollout state, not an error. */
bool entities_restored = false;
int rc = load_snapshot(p, snap_file, snap_lsn, &entities_restored);
if (rc != 0) {
ERROR("persist_recover: failed to load snapshot %s: %s",
snap_file, strerror(-rc));
return rc;
}
/* checkpoint_lsn and current_lsn set by load_snapshot */
if (entities_restored) {
INFO("persist_recover: snapshot %s loaded lsn=%" PRIu64
" with full job/queue entity restoration", snap_file,
p->checkpoint_lsn);
} else {
INFO("persist_recover: snapshot %s lsn=%" PRIu64 " is a legacy "
"position-only checkpoint (no entity content) — continuing "
"via normal WAL replay", snap_file, p->checkpoint_lsn);
}
}
/* --- Step 3: replay WAL entries after checkpoint_lsn --- */