Repository navigation
fix(es-compat): fan _delete_by_query/_update_by_query out to every alias member (#450) - #552
Conversation
…ias touches only the first member
Failing repro (WIP): a 3-member alias 'tri' with 12 docs; POST /tri/_delete_by_query
match_all returns {"total":4,"deleted":4,"failures":[]} — a silent partial success
that deletes only idx-a's share and leaves idx-b/idx-c intact. Both by-query write
handlers resolve the alias via Engine::get_index -> aliased.first(). Fix (fan out to
every member + apply alias filter) lands next.
…ias member (#450) Both by-query write handlers began with Engine::get_index, which resolves an alias to aliased.first() — one member. A destructive by-query through a multi-index alias therefore touched only the first member and answered a clean {deleted/updated: N} with failures:[], indistinguishable from a complete run: a silent partial delete the caller cannot detect (strictly worse than the #433/#449 read truncation — a short delete is unrecoverable). Resolve the selector the way the read paths do (resolve_index_selector, #433): expand to every member, AND in any alias filter exactly as search_impl does so a FILTERED alias deletes only its slice and not the whole backing index (the #524 hazard), then run the by-query on each member and aggregate. A single member (a plain index or one-member alias) is returned byte-for-byte unchanged, so the existing wire format never drifts; only genuine multi-member aliases aggregate. Adds by_query_through_alias_touches_every_member.rs covering both verbs.
Independent 3-skeptic verification (each REFUTES, own worktree, rustc 1.98.0)Verdict: 0 BLOCKING. correctness=nit, regression-risk=should-fix, evidence-holds=should-fix — all refuted=false. correctness (nit): Fan-out + aggregation correct. regression-risk (should-fix): Full evidence-holds (should-fix): Core #450 claim holds. Fail-before real: Gate: (a) 17/17 green, none pending; (b) 0 BLOCKING (should-fix/nit tracked as fast-follow); (c) CLEAN. Merging. Follow-up filed for the filtered-alias test + update-aggregate nit. |
Newest tag is now v1.0.0-rc.24 (includes xerj-org#552 fix xerj-org#450 data-loss + xerj-org#549 knn invariant tests). Footer XERJ.AI stamps and llms*.txt 'Current release' bumped rc.23 -> rc.24 across landing/; llms release date -> 2026-08-21. landing-constants-guard passes with VERSION=1.0.0-rc.24.
…_by_query aggregate deleted:0 (xerj-org#553) Fast-follow to xerj-org#450/xerj-org#552. The 3-skeptic verification confirmed the filtered-alias over-delete safety by code inspection but flagged it was untested. This adds the execution test: a match_all _delete_by_query through a filtered 2-member alias deletes only the 2 in-slice (active) docs and leaves the 2 out-of-slice (archived) docs — the xerj-org#524 hazard. Non-vacuous: without the filter, match_all would delete all 4 and empty both members. Also fixes the flagged nit: aggregate_by_query_results now includes deleted:0 for _update_by_query, matching the single-member update body (2+-member updates dropped it).
Closes #450.
The bug (silent partial delete — data integrity)
_delete_by_queryand_update_by_queryboth began withEngine::get_index(&index), which resolves an alias toaliased.first()— one member. A destructive by-query through a multi-index alias therefore touched only the first member and answered a clean{"deleted"/"updated": N, "failures": []}, indistinguishable from a complete run. Strictly worse than the #433/#449 read truncation: a short read is recoverable, a short delete leaves the caller believing the operation completed.Reproduced: 3-member alias
tri(12 docs),POST /tri/_delete_by_query {match_all}returned{"total":4,"deleted":4,"failures":[]}— idx-b/idx-c untouched.The fix
resolve_by_query_targets()resolves the selector the way the read paths do (resolve_index_selector, #433): expand to every member, and — crucially for a destructive path — AND in any aliasfilterexactly assearch_impldoes, so a filtered alias deletes only its slice, not the whole backing index (the #524 hazard). Each member runs the by-query;aggregate_by_query_results()sums the counts and concatenatesfailures. A single member (plain index or one-member alias) is returned byte-for-byte unchanged, so the existing wire format never drifts — only genuine multi-member aliases aggregate. If any member errors, that error is surfaced rather than a clean aggregate.Verification (rustc 1.98.0 — CI @stable)
by_query_through_alias_touches_every_member.rscovers both verbs; fail-before wasdeleted:4/12, now both pass.xerj-apisuite: 465 tests, 0 failed (the fix(engine): 400 a knn/semantic clause on a non-vector field, not empty 200 (#498) #529 lesson — not just the new test).cargo fmt --check,clippy --workspace --all-targets -D warnings,build --profile ci-test: all clean.