8000 fix(autoindex): re-walk the catalog read-back while it falls short of the projection (#1212) by xerj-org · Pull Request #1216 · xerj-org/xerj · GitHub
[go: up one dir, main page]

Skip to content

fix(autoindex): re-walk the catalog read-back while it falls short of the projection (#1212) - #1216

Merged
xerj-org merged 1 commit into
mainfrom
fix/catalog-readback-rewalk
Oct 7, 2026
Merged

xerj-org merged 1 commit into
mainfrom
fix/catalog-readback-rewalk

Conversation

@xerj-org
@xerj-org xerj-org commented Oct 7, 2026
Copy link
Copy Markdown
Owner

What

The finalize read-back barrier now re-walks the catalog while its observation falls short of the sealed projection, bounded at 3 attempts, instead of judging a starved walk with exact equality.

Why (#1212, second live shape)

The standing xerj-search resume (2026-10-06) died at the read-back barrier with:

error: catalog read-back contains 9000 documents; expected 58568

The walk had read 9 full 1,000-hit pages, then an empty page with timed_out absent. No flag, HTTP 200, no error. Minutes later:

  • a plain term query on the same field/value returned 0 hits (engine unknown_value hint), while
  • a terms aggregation counted the full 58,568, and
  • the same sorted walk on an idle node read all 59 pages clean at ~1.5 s/page.

So the engine intermittently truncates sorted scans and term queries under load while aggregations see the full set (engine half tracked on #1212, which stays open).

Neither existing defense can see this shape:

The only distinguishing signal is observed-count-versus-expected, which the barrier already has: the projection's document count.

Change

  • EsSyncBackend::catalog_generation_complete(run_id, expected) — walk once; while short of expected with attempts remaining, refresh the catalog and walk again (READBACK_WALK_ATTEMPTS = 3).
  • Every attempt short returns the last observation, so validate_observed's exact-equality error names the final walk's counts, not a stale one.
  • The autoindex: a one-file change costs O(corpus) twice — a full snapshot and a full catalog rewrite per generation #971 prior-run stray sweep is deliberately NOT re-walked: it is a subset check, so truncation can only under-report strays — a false pass is impossible there.
  • The loop is isolated as rewalk_while_short over closures; 4 new unit tests pin: complete-first-walk (no refresh), short-then-complete (one refresh, two walks), short-every-time (exactly the budget, last observation returned), transport error propagates without a retry.

Tests

cargo test -p xerj-autoindex --lib → 1290 passed, 0 failed (was 1286). fmt + clippy -D warnings clean.

Reference-code mandate: skipped — confined to this repository's own client/runner logic (autoindex read-back barrier); the engine defect stays on #1212.

… the projection (#1212)

The live failure (standing xerj-search resume, 2026-10-06): finalize's
run_id-scoped read-back walk read 9 full 1,000-hit pages, then an EMPTY
page with timed_out absent — 9,000 of 58,568 documents, no flag, no
error. validate_observed's exact-equality check then aborted the run
after a 26-minute finalize, and the same walk on an idle node minutes
later read all 59 pages clean at ~1.5 s/page. A terms aggregation on
the same field counted 58,568; a plain term query moments after the
empty page returned 0 hits with an "unknown_value" hint. So the engine
(#1212, engine half still open) intermittently truncates sorted scans
and term queries under load while aggregations see the full set.

Neither existing defense can see this shape:

- the Es client's bounded 5xx retry only re-sends failed requests —
  this answer was HTTP 200;
- #1213's page-level deadline check (branch fix/autoindex-partial-page-
  truncation) retried pages that admit timed_out=true — this answer
  carried no flag;
- page answers report total {value: 10000, relation: "gte"} under the
  track_total_hits cap, so a walker cannot use total to validate a
  short page either.

The only signal that distinguishes a starved walk from a complete one
is observed-count-versus-expected, which the barrier already computes:
the sealed projection's document count.

Change: catalog_generation_complete() walks once and, while the
observation is short of the projection's document count and attempts
remain, refreshes the catalog and walks again — bounded at 3 attempts
(READBACK_WALK_ATTEMPTS). One intermittent engine answer no longer
costs the whole finalize. When every attempt falls short, the LAST
observation is returned so validate_observed produces its loud,
precise mismatch error over the final walk's counts, not a stale one.

The #971 prior-run stray sweep (catalog_generation(prior_run_id)) is
deliberately NOT re-walked: it is a subset check, so an unflagged
truncated page can only under-report strays — a false pass is
impossible, and a re-walk would only re-run the sweep's deletes.

The retry loop is isolated as EsSyncBackend::rewalk_while_short over
closures so its contract is pinnable without a node; four unit tests
cover it: a complete first walk returns without refreshing, a short
walk is refreshed and re-walked until complete, a walk short every
time costs exactly the attempt budget and returns the last
observation, and a transport error propagates without a retry (an
error is not a short walk).

Scoped run: cargo test -p xerj-autoindex --lib → 1290 passed, 0
failed. fmt + clippy -D warnings clean.

Reference-code mandate: skipped — this change is confined to this
repository's own client/runner logic (the read-back barrier in the
autoindex executor); the engine-side defect is tracked on #1212.

Files:
- engine/crates/xerj-autoindex/src/sync_executor.rs:
  catalog_generation_complete, rewalk_while_short, READBACK_WALK_ATTEMPTS,
  publish_generation_catalog read-back call site, tests
@cla-bot cla-bot Bot added the cla-signed label Oct 7, 2026
@xerj-org
xerj-org merged commit 58006b3 into main Oct 7, 2026
22 checks passed
neoneye pushed a commit to agent-memory-atlas-archive/xerj-org--xerj that referenced this pull request Oct 10, 2026
Workspace version + Cargo.lock (17 member entries). Release window:
xerj-org#1211, xerj-org#1213, xerj-org#1215, xerj-org#1216, xerj-org#1217, xerj-org#1218.
neoneye pushed a commit to agent-memory-atlas-archive/xerj-org--xerj that referenced this pull request Oct 10, 2026
Six window entries: xerj-org#1211 (blog guest post), xerj-org#1217 (kNN exact-scan
column ranking, its Unreleased entry carried verbatim under
Performance), xerj-org#1213/xerj-org#1216 (the two xerj-org#1212 client legs: explicit page
timeouts + observed-vs-projection re-walk), xerj-org#1215 (xerj-org#1214: corpus
index refuses an unresumable run over a recorded build), xerj-org#1218 (the
xerj-org#1212 engine half: capture-scoped version-map reads). Every xerj-org#1212
entry says the issue stays open — it closes only on a released,
verified standing rebuild. xerj-org#1220 cited as the follow-up the xerj-org#1217
review surfaced.
neoneye pushed a commit to agent-memory-atlas-archive/xerj-org--xerj that referenced this pull request Oct 10, 2026
…ntry

The read-back re-walk entry cites xerj-org#1212, which stays open until the
released engine fix is verified by a full standing rebuild; the notes
gate correctly refused the entry without that said.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

0