8000 fix(es-compat): shared index-selector resolver + migrate the get_index->first read endpoints (#451 class B) by xerj-org · Pull Request #555 · xerj-org/xerj · GitHub
[go: up one dir, main page]

Skip to content

fix(es-compat): shared index-selector resolver + migrate the get_index->first read endpoints (#451 class B) - #555

Merged
xerj-org merged 6 commits into
mainfrom
fix/451-alias-op-resolver
Aug 21, 2026
Merged

xerj-org merged 6 commits into
mainfrom
fix/451-alias-op-resolver

Conversation

@xerj-org
Copy link
Copy Markdown
Owner

Advances #451 (does not close it — see Scope). Introduces the single selector resolver the issue asks for and migrates the trivially-mergeable class-B read endpoints onto it, deleting their per-site get_index copies.

The defect (class B)

Several read endpoints resolved the path index with Engine::get_index, which collapses an alias to aliased.first() — one member. So over a multi-index alias they silently answered from the first member only: a doc in another member was invisible.

The shape (what the issue asked for)

resolve_selector_with_filters(state, spec) -> (Vec<(name, Arc<Index>)>, Vec<alias_filter>) — one resolver that expands _all/*/glob/alias/comma uniformly (via resolve_index_selector, #433) and carries any alias filter (mirroring search_impl, as resolve_by_query_targets does on the write path, #450). Every migrated site calls it; the per-site get_index is gone.

Migrated this PR (each with a fail-before→pass repro test)

  • _mget — a doc in a non-first member reported found:false; now searches every member.
  • _explain — a non-first member's doc reported matched:false/"document not found"; now explains against the member that holds it, reporting the concrete member in _index.
  • _cat/segments — an alias showed one row under the alias name (and globs matched nothing); now one row per member.
  • _segments (/{index}/_segments) — one indices entry under the alias name; now one entry per member.

Scope / tracked follow-up (why #451 stays open)

  • eql_search — also get_index→first, but fanning it out needs proper search-result merging (sort + size across members), not per-member iteration; a naive concat would mis-order EQL events. Wants a decision on routing it through the shared multi-index search path.
  • Class C (alias-filter injection on msearch/search_with_scroll/msearch_template/_cat/count) — the resolver now returns the filters; wiring them in is a separate change.
  • async_search_submit is already alias-safe (delegates to search_impl).

Verification (rustc 1.98.0)

Full xerj-api suite 469 passed, 0 failed; fmt --check, clippy --workspace --all-targets -D warnings, build --profile ci-test all clean.

… alias only sees the first member

Failing repro (WIP): a 2-member alias 'tri' with id 1 in idx-a and id 2 in idx-b;
POST /tri/_mget {docs:[{_id:1},{_id:2}]} returns id 1 found:true but id 2 found:false —
mget_index resolves each entry via Engine::get_index, which collapses an alias to
aliased.first() (es_compat.rs:18406). Read-side twin of #450.

NOTE: #451 class A (resolve_indices_for_op 404ing on aliases for _refresh/_close/etc.)
is ALREADY fixed on main — that resolver now has an alias branch. Remaining: class B
(get_index->first on _mget/_explain/_flush/...) and class C (alias filters ignored on
msearch/scroll). The proper fix is one shared (concrete_indices, alias_filters) resolver
every site calls, per the issue — not a per-site branch; this test is what it must satisfy.
…class B, WIP)

Adds resolve_selector_with_filters(state, spec) -> (Vec<(name, Arc<Index>)>, Vec<filter>):
the single resolver #451 asks for (an alias expands to every member, #433; carries alias
filters like resolve_by_query_targets on the write path, #450). Migrates _mget: each entry
now searches every alias member for the id and reports the concrete member in _index, so a
doc in a non-first member is found. Repro mget_through_alias_sees_every_member now passes
under 1.98.0 (was found:false for id 2).

WIP — remaining class-B sites (_explain/_segments/_cat-segments/_eql/_async_search/_flush)
migrate onto the same resolver, then per-site get_index copies deleted, before the PR opens.
…class B)

_explain used Engine::get_index -> aliased.first(), so explaining a doc that lives
in a non-first alias member returned matched:false / 'document not found'. Now resolves
via resolve_selector_with_filters, finds the member that actually holds the doc, and
explains against it (reporting the concrete member in _index). Fail-before: doc 2 in
idx-b through alias tri -> matched:false; now matched:true. Repro test added.

Second class-B site migrated (after _mget); remaining: _segments/_cat-segments/_eql/
_async_search, then the class-C filter sites, before the PR opens.
…451 class B)

_cat/segments listed only [index] and resolved it via get_index -> aliased.first(),
so a multi-index alias showed one row under the alias name (first member's stats) and
a glob matched nothing. Now resolves via resolve_selector_with_filters, listing a row
per concrete member and handling _all/glob/comma uniformly. Fail-before: alias tri ->
one 'tri' row; now one row each for idx-a and idx-b. Repro test added.

Third class-B site migrated (_mget, _explain, _cat/segments). Remaining: verify
_eql/_async_search actually need it (they may delegate to search_impl), then class-C.
…class B)

GET /{index}/_segments used get_index -> aliased.first(), returning one 'indices'
entry under the alias name (first member's segments). Now resolves via
resolve_selector_with_filters and emits one indices entry per concrete member,
with _shards counting one shard per member. Fail-before: alias tri -> {tri:...};
now {idx-a:..., idx-b:...}. Repro test added.

Fourth class-B site migrated (_mget, _explain, _cat/segments, _segments).
cargo fmt wrapped a method chain in mget_through_alias_sees_every_member.rs that
exceeded the line width. No behavior change.
@cla-bot cla-bot Bot added the cla-signed label Aug 21, 2026
@xerj-org
Copy link
Copy Markdown
Owner Author

Independent 3-skeptic verification (each REFUTES, own worktree, rustc 1.98.0)

Verdict: 0 BLOCKING — all three refuted=false / severity=none.

correctness (none): resolve_selector_with_filters delegates to resolve_index_selector (#433) which pushes every backing index, dedups, and propagates get_index errors. All 4 endpoints fan out to every member and report the concrete member, not the alias: _mget labels _index with mname (18432); _explain rebinds index=mname on hit (33302), keeps the selector name only on the not-found arm; _cat/segments rows keyed by member (29260); _segments keys indices_map + counts _shards per member (35808/35827). Plain-index path is byte-identical. Non-blocking notes: a single-member alias now reports the member in _index (a correct move toward ES, not a regression); alias filters intentionally discarded here (class-C follow-up).

regression-risk (none): Full cargo test -p xerj-api — 43 binaries, 469 passed, 0 failed, exit 0. All adjacent alias/scroll tests pass. Clippy -p xerj-api --all-targets -D warnings: zero warnings. Could not prove any regression. Non-migration of eql_search/class-C is a documented scoping decision.

evidence-holds (none): Empirically confirmed the fail-before — reverting _explain back to get_index makes its test FAIL with matched:false / "document not found" (doc "2" lives in idx-b, the non-first member). No migration is vacuous; scoping is honest (eql_search still get_index at 32970, confirmed by grep + read).

Gate: (a) all checks green, none pending; (b) 0 BLOCKING; (c) CLEAN. Merging.

@xerj-org
xerj-org merged commit 054dea1 into main Aug 21, 2026
18 checks passed
buger pushed a commit to probelabs/xerj that referenced this pull request Aug 22, 2026
Newest tag is now v1.0.0-rc.25 (includes xerj-org#555 fix xerj-org#451 class-B alias fan-out + xerj-org#556 fix xerj-org#553
filtered-alias over-delete safety lock). Footer XERJ.AI stamps + llms*.txt 'Current release'
bumped rc.24 -> rc.25 across landing/ (48 files). landing-constants-guard passes with
VERSION=1.0.0-rc.25.
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