8000 fix(api): POST /{index}/_cache/clear releases the index's rebuildable caches (#950) by Vinz2168 · Pull Request #1009 · xerj-org/xerj · GitHub
[go: up one dir, main page]

Skip to content

fix(api): POST /{index}/_cache/clear releases the index's rebuildable caches (#950) - #1009

Merged
xerj-org merged 1 commit into
xerj-org:mainfrom
Vinz2168:fix/950-cache-clear-release-memory
Sep 21, 2026
Merged

xerj-org merged 1 commit into
xerj-org:mainfrom
Vinz2168:fix/950-cache-clear-release-memory

Conversation

@Vinz2168
Copy link
Copy Markdown
Collaborator

Refs #950 (does not close it).

What

POST /{index}/_cache/clear was a stub: it resolved the indices and returned the _shards block but cleared nothing. It now flushes each resolved index, calls Index::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.

Test plan

  • New xerj-api/tests/cache_clear_releases_memory.rs: hydrate via _search, write an unrefreshed doc, clear, assert total_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_ops and -p xerj-engine --test drain_releases_memory --test close_releases_index pass.
  • cargo clippy -p xerj-api -p xerj-engine --tests clean.
  • Not run: the full ES-YAML suite (response shape is unchanged).

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

… 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.
@cla-bot cla-bot Bot added the cla-signed label Sep 21, 2026
@xerj-org
xerj-org merged commit a13d5ee into xerj-org:main Sep 21, 2026
21 checks passed
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).
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.

2 participants

0