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.
Rust agent-memoryai-agentsbm25claude-codeclicode-searchcursordatabaseelasticsearchfull-text-searchhybrid-searchjsonllocal-firstmcpmcp-servermodel-context-protocolragrustsearch-enginevector-search
diag(#1023): temporary runner-side interleaving instrumentation, WILL BE REVERTED
xerj-org8501dc4f4478
diff --git a/engine/crates/xerj-api/src/es_compat.rs b/engine/crates/xerj-api/src/es_compat.rsindex d1dc4656d..d59cac29e 100644--- a/engine/crates/xerj-api/src/es_compat.rs+++ b/engine/crates/xerj-api/src/es_compat.rs@@ -26400,6 +26400,12 @@ async fn run_delete_by_query(// publications (#1023), so a purge storm cannot collect an empty set out// of another call's drain→publish window and report a clean no-op.if let Some(mut ids) = idx.matching_ids_sorted(&parsed_query).await {+ eprintln!(+ "[DIAG2] dbq ids-collected n={} first={:?} dir={}",+ ids.len(),+ &ids[..ids.len().min(3)],+ idx.data_dir().display()+ );// ES `max_docs`: stop after N documents; `total` then reports the// processed count (the same rule the paged arm applies).let matched = ids.len() as u64;@@ -26809,6 +26815,7 @@ async fn run_update_by_query(// precondition of the run being complete, so a failed flush must not be// followed by an update that reports a `total` over an index it could not// read consistently.+ eprintln!("[DIAG2] ubq entry-flush start dir={}", idx.data_dir().display());if let Err(e) = idx.flush().await {return ApiError::new(xerj_common::XerjError::internal(format!("update_by_query was not attempted: flushing the index failed ({e}); the update \@@ -26816,6 +26823,7 @@ async fn run_update_by_query())).into_value();}+ eprintln!("[DIAG2] ubq entry-flush done dir={}", idx.data_dir().display());// Parse once for the single-pass eligibility check below. The handler// already validated the (page-1-shaped) query, so this cannot fail for a@@ -26859,6 +26867,12 @@ async fn run_update_by_query(// reported total:0/updated:0/failures:[] — a silent no-op.if script.is_some() {if let Some(mut ids) = idx.matching_ids_sorted(&parsed_query).await {+ eprintln!(+ "[DIAG2] ubq ids-collected n={} first={:?} dir={}",+ ids.len(),+ &ids[..ids.len().min(3)],+ idx.data_dir().display()+ );// ES `max_docs`: stop after N documents; `total` then// reports the processed count (the same rule the paged// arm applies).@@ -26904,6 +26918,10 @@ async fn run_update_by_query(};return Ok((total, updated, batches, failures, timed_out));}+ eprintln!(+ "[DIAG2] ubq ids-collected NONE -> paged arm dir={}",+ idx.data_dir().display()+ );}// ── Paged arm: every other shape ─────────────────────────────────@@ -27149,6 +27167,7 @@ async fn transform_one(}let result = idx.transform_document_serialized(id, None, |mut current| {+ let read_n = current.get("n").cloned();apply_painless_update(&mut current, src, params)?;// ES runs `?pipeline=` on the result of the script, and so do we —// inside the same serialized transform, so the pipeline sees@@ -27156,12 +27175,19 @@ async fn transform_one(if let Some((engine, name)) = pipeline.as_ref() {current = apply_pipeline_or_fail(engine, name, id, current)?;}+ eprintln!(+ "[DIAG2] transform_one id={id} read_n={read_n:?} write_n={:?}",+ current.get("n")+ );Ok::<_, String>(current)}).await;match result {Ok(Ok(Some(_))) => Some(Ok(())),- Ok(Ok(None)) => None,+ Ok(Ok(None)) => {+ eprintln!("[DIAG2] transform_one id={id} VANISHED (get_document None)");+ None+ }Ok(Err(error)) => Some(Err(error)),Err(error) => Some(Err(error.to_string())),}diff --git a/engine/crates/xerj-engine/src/index.rs b/engine/crates/xerj-engine/src/index.rsindex 07d936f6d..81c066c0c 100644--- a/engine/crates/xerj-engine/src/index.rs+++ b/engine/crates/xerj-engine/src/index.rs@@ -17857,8 +17857,17 @@ impl Index {notified.as_mut().enable();match self.collection_publication.try_admit_reader() {ReadAdmission::Admitted(token) => break token,- ReadAdmission::Poisoned => return None,- ReadAdmission::WriterActive => notified.await,+ ReadAdmission::Poisoned => {+ eprintln!("[DIAG2] mis admit POISONED dir={}", self.data_dir.display());+ return None;+ }+ ReadAdmission::WriterActive => {+ eprintln!(+ "[DIAG2] mis admit wait-writer dir={}",+ self.data_dir.display()+ );+ notified.await;+ }}};let snap = self.store.snapshot();@@ -17888,16 +17897,40 @@ impl Index {}}if unsupported {+ eprintln!(+ "[DIAG2] mis UNSUPPORTED id-map dir={}",+ self.data_dir.display()+ );return None;}ids.sort_unstable();// Same contract as the paged loop's `seen_ids`: an id resolves to one// delete even if a legacy multi-segment layout lists it twice.ids.dedup();+ eprintln!(+ "[DIAG2] mis attempt segs={} ids={} memtbl_docs={} first={:?} dir={}",+ snap.segments.len(),+ ids.len(),+ self.memtable.doc_count(),+ &ids[..ids.len().min(3)],+ self.data_dir.display()+ );match self.collection_publication.validate_reader(token) {ReadAdmission::Admitted(_) => break ids,- ReadAdmission::Poisoned => return None,- ReadAdmission::WriterActive => continue,+ ReadAdmission::Poisoned => {+ eprintln!(+ "[DIAG2] mis validate POISONED dir={}",+ self.data_dir.display()+ );+ return None;+ }+ ReadAdmission::WriterActive => {+ eprintln!(+ "[DIAG2] mis validate-retry dir={}",+ self.data_dir.display()+ );+ continue;+ }}};Some(ids)@@ -31402,10 +31435,24 @@ async fn do_flush_shard(// caller observed it as non-empty. No collection state changed in// this attempt, so this is a clean cancellation rather than a// failed publication.+ eprintln!("[DIAG2] flush drain-empty shard={} dir={}", shard_idx, data_dir.display());collection_publication_guard.cancel();return Ok(());}};+ {+ let drained_ids: Vec<String> = drained_fts+ .iter()+ .map(|(id, _, _)| id.clone())+ .collect();+ eprintln!(+ "[DIAG2] flush drained shard={} docs={} ids={:?} dir={}",+ shard_idx,+ drained_ids.len(),+ &drained_ids[..drained_ids.len().min(4)],+ data_dir.display()+ );+ }let drained_fts = Arc::new(drained_fts);let storage_drained = Arc::new(storage_drained);@@ -31580,6 +31627,8 @@ async fn do_flush_shard(let memtable_for_finalize = Arc::clone(&memtable);let drained_fts_for_restore = Arc::clone(&drained_fts);let version_map_for_restore = Arc::clone(&store.version_map);+ let diag_dir = data_dir.display().to_string();+ let diag_shard = shard_idx;// A dedicated async coordinator owns and awaits the queued blocking job.// Dropping/cancelling the API caller merely detaches this coordinator;// it continues to own the blocking JoinHandle and the worker-captured@@ -31628,8 +31677,22 @@ async fn do_flush_shard(xerj_storage::index_store::FlushFinalizeOutcome::Published { .. }))) {+ let seg = match &result {+ Ok(Ok(+ xerj_storage::index_store::FlushFinalizeOutcome::Published { meta, .. },+ )) => meta.id.as_str().to_string(),+ _ => String::new(),+ };+ eprintln!(+ "[DIAG2] flush commit shard={} seg={} dir={}",+ diag_shard, seg, diag_dir+ );collection_publication_guard.commit();} else {+ eprintln!(+ "[DIAG2] flush CANCEL+RESTORE shard={} dir={}",+ diag_shard, diag_dir+ );collection_publication_guard.cancel();}let result = match result {