Repository navigation
fix(api): POST /{index}/_cache/clear releases the index's rebuildable caches (#950) - #1009
Merged
xerj-org merged 1 commit intoSep 21, 2026
Merged
Conversation
… caches (xerj-org#950) `_cache/clear` was a stub: it resolved the indices and returned an honest `_shards` block but cleared nothing, so the one operator lever for a node pinned above its memory watermark was not connected to `Index::release_memory` (whose only other callers are `close_index` and the xerj-org#948 memory-pressure drain). The handler now flushes each resolved index, releases its hydrated per-segment caches and purges the allocator. Flush comes first, the same ordering as `close_index`, so a not-yet-published document is never lost; the next read re-hydrates from disk. The response body is unchanged. The flush+release+purge body is extracted from `Engine::drain_rebuildable_memory` into `Engine::release_rebuildable_memory` so the operator-facing clear and the breaker's drain share one path and cannot drift apart. The drain's behaviour is unchanged. Test: cache_clear_releases_memory hydrates the caches with a size>0 search, writes an unrefreshed doc, clears, and asserts total cache entries go to 0, the response shape is byte-identical and all 41 docs survive. It fails on the stub (caches stay at 17). The xerj-org#948/xerj-org#463 drain and close tests still pass. Refs xerj-org#950. This does not close it: the ~11.7 GB of anonymous memory outside every accounted budget still needs a jemalloc heap profile to attribute.
This was referenced Sep 26, 2026
Merged
Amakurai
pushed a commit
to Amakurai/xerj
that referenced
this pull request
Sep 27, 2026
…, rc.78 queue The 2026-09-21 review of this file was stale within hours: xerj-org#950 closed 19:33, xerj-org#941 19:38, xerj-org#1015 20:49 (all 2026-09-21), xerj-org#874 2026-09-22, and the stage-1 gating trio xerj-org#937/xerj-org#938/xerj-org#939 closed the same evening — every one recorded here as open or "under way". This pass re-checks every status claim against live tracker state and rolls the file forward: - Next release: the two "in flight" items (xerj-org#1015, xerj-org#950) are closed with fixes on main riding to rc.78 — the section now records what actually landed since the rc.77 tag (xerj-org#1009, xerj-org#1017, xerj-org#1018, xerj-org#1020, xerj-org#1021, xerj-org#1023, xerj-org#1025, xerj-org#1026, xerj-org#1033, xerj-org#1034) with PR links, including xerj-org#874's budget met at ~3x margin (206 -> 64 kB per idle index) and discussion xerj-org#1012's email-labelling measurement (1.000 templated tier / 0.625 at 0.902 confidence on the hard tier — wrong-and-confident). - Open defects: now xerj-org#1031 and xerj-org#1032 only; xerj-org#1015/xerj-org#950 removed (closed); trackers sentence corrected (xerj-org#941, xerj-org#874 closed — only xerj-org#298 remains by design). - GA gate: "Close the CHANGELOG gap" marked closed 2026-09-26 (the rc.19-rc.70 backfill, PR xerj-org#1035); the record-complete note replaces the gap warning under "Shipping today". - Zero-token: stage-1 gating trio recorded as fixed (xerj-org#991, xerj-org#995, xerj-org#979) with the old measured costs kept as the before-state; the xerj-org#940 hash-seed spread annotated as a pre-fix measurement; stage-2 object storage marked done (xerj-org#965 wired in rc.77 — the old bullet contradicted this file's own "Shipping today" section); mail ingest "unreleased" corrected to "shipped in rc.75"; three stale "In flight:" labels on landed stage-1 items relabelled "History:". - Mail-ingest memory line: xerj-org#948's runaway is fixed (xerj-org#1002) — the line now carries the fixed numbers and points at xerj-org#1032 for the residual. Review line updated to 2026-09-26 (machine-checked format), scoped honestly as a desk review. The milestones line is true again: rc.78 milestone created, all four open issues triaged (xerj-org#1030/xerj-org#1031/xerj-org#1032 -> rc.78, xerj-org#298 -> GA).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #950 (does not close it).
What
POST /{index}/_cache/clearwas a stub: it resolved the indices and returned the_shardsblock but cleared nothing. It now flushes each resolved index, callsIndex::release_memory, and purges the allocator, so an operator has a working release lever on a node pinned above its watermark. This is the PR offered in the triage comment on #950.Engine::close_index, so no unpublished document is lost. Reads re-hydrate from disk.drain_rebuildable_memory(engine: ingesting a 1 GB mailbox (107k docs, 760 MB index) needs 26.5 GB RSS under the 16 GiB auto cap (run never completes) and 68.5 GB uncapped #948) intoEngine::release_rebuildable_memory, so the clear and the breaker's drain share one path. The drain's behaviour is unchanged.Test plan
xerj-api/tests/cache_clear_releases_memory.rs: hydrate via_search, write an unrefreshed doc, clear, asserttotal_cache_entries() == 0, response{"_shards":{"total":1,"successful":1,"failed":0}}, and all 41 docs still counted. Fails on the stub (caches stay at 17).cargo test -p xerj-api --test alias_is_a_valid_selector_for_maintenance_opsand-p xerj-engine --test drain_releases_memory --test close_releases_indexpass.cargo clippy -p xerj-api -p xerj-engine --testsclean.Not in this PR
The ~11.7 GB of anonymous memory outside every accounted budget is still unattributed; that needs the jemalloc heap profile described in the triage comment.
🤖 Generated with Claude Code