Skip to content

armgit / xerj

Public Imported from GitHub
0

AI search engine and MCP server for bots and agents. One Rust binary indexes code, docs, logs, JSONL/CSV and PDFs for BM25 full-text, vector and hybrid search, code search without grep, agent memory and RAG. Elasticsearch-compatible API; Corpus Hub serves hundreds of reference memory corpora.

fix(engine): reconcile #203 cluster-state persistence with the #247 lifecycle engine

xerj-orgf22f7b20cbee
diff --git a/engine/crates/xerj-api/src/es_compat.rs b/engine/crates/xerj-api/src/es_compat.rs
index 2d7cf9d92..578ba2e90 100644
--- a/engine/crates/xerj-api/src/es_compat.rs
+++ b/engine/crates/xerj-api/src/es_compat.rs
@@ -24150,11 +24150,23 @@ pub async fn delete_ilm_policy(
State(state): State<AppState>,
Path(name): Path<String>,
) -> impl IntoResponse {
- // Remove the verbatim document first: that is the guarded, persisted
- // path, so a failure there is a 500 with nothing removed anywhere. Only
- // once it is gone from `cluster_state.json` is the translated executor
- // policy dropped, so the two files can never disagree in the direction
- // that keeps running a policy `GET _ilm/policy` reports as deleted.
+ // Two files now back this one request — the verbatim document in
+ // `cluster_state.json` (issue #203) and the translated executor policy in
+ // `ism_policies.json` (issue #199) — so the order matters. The verbatim
+ // document goes first because that is the guarded, persisted, *fallible*
+ // step: if it cannot be written the request is a 500 and nothing has been
+ // removed from either file, rather than an executor policy already
+ // dropped for a document that is still on disk and still served by GET.
+ //
+ // That leaves one window this does not close, stated rather than implied:
+ // a crash between the two calls leaves an `ism_policies.json` entry no
+ // `_ilm/policy` path can reach any more (the retry answers 404, because
+ // the verbatim document really is gone) and the executor keeps driving
+ // any index still attached to it. It is reachable and removable through
+ // the ISM door it was written by — `DELETE /_plugins/_ism/policies/{id}`,
+ // which `GET /_plugins/_ism/explain/{index}` still names — and closing it
+ // properly means one write covering both files, which is a change to the
+ // lifecycle engine's storage rather than to this handler.
match state.engine.delete_ilm_policy(&name) {
Ok(true) => {
state.engine.remove_ism_policy(&name);