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(autoindex): name the journal dir when a new data dir is empty (#1616)

xerj-org6ee2753b1a97
diff --git a/engine/crates/xerj-autoindex/src/failure_resume_http_tests.rs b/engine/crates/xerj-autoindex/src/failure_resume_http_tests.rs
index 6c43a1048..f543a96f5 100644
--- a/engine/crates/xerj-autoindex/src/failure_resume_http_tests.rs
+++ b/engine/crates/xerj-autoindex/src/failure_resume_http_tests.rs
@@ -3021,6 +3021,15 @@ fn zero_live_documents_after_journaled_records_fails_the_run() {
assert!(error.contains("verification failed"), "{error}");
assert!(error.contains("0 documents are live"), "{error}");
assert!(error.contains("--fresh"), "{error}");
+ let state = state_dir.path().display().to_string();
+ assert!(
+ error.contains(&format!("Journal state dir: {state}")),
+ "the refusal must name the journal directory: {error}"
+ );
+ assert!(
+ error.contains("may belong to another data dir"),
+ "a reused journal must say it may belong to another data dir: {error}"
+ );
}
/// #241 regression: a run must never be silent.
diff --git a/engine/crates/xerj-autoindex/src/lib.rs b/engine/crates/xerj-autoindex/src/lib.rs
index 6d3c0113d..b18a2348c 100644
--- a/engine/crates/xerj-autoindex/src/lib.rs
+++ b/engine/crates/xerj-autoindex/src/lib.rs
@@ -4302,6 +4302,10 @@ pub struct ZeroLiveVerificationError {
pub files_done_journaled: usize,
/// Dataset indices that answered with zero live documents.
pub dataset_indices: usize,
+ /// Directory the resume journal was read from. A new `--data-dir` does
+ /// not move this directory: the default is keyed by folder, URL, and
+ /// prefix, so a journal left by an earlier node is reused as-is.
+ pub state_dir: String,
}
impl std::fmt::Display for ZeroLiveVerificationError {
@@ -4310,12 +4314,14 @@ impl std::fmt::Display for ZeroLiveVerificationError {
formatter,
"autoindex verification failed: the resume journal records {} \
record(s) from {} completed file(s), but 0 documents are \
- live across the {} dataset index(es). The indices exist and look healthy but \
+ live across the {} dataset index(es). Journal state dir: {}. \
+ This journal may belong to another data dir (a new --data-dir \
+ reuses it). The indices exist and look healthy but \
hold nothing — a server-side write rejection (e.g. a disk flood-stage or \
- index write block), deleted indices, or an unreadable server can all cause \
+ index write block), deleted indices, or an unreadable server can also cause \
this. Fix the server-side condition, then rerun with --fresh to re-index \
from scratch",
- self.journal_records, self.files_done_journaled, self.dataset_indices
+ self.journal_records, self.files_done_journaled, self.dataset_indices, self.state_dir
)
}
}
@@ -8579,6 +8585,7 @@ fn run_index_report_inner(
journal_records,
files_done_journaled,
dataset_indices: plan.datasets.len(),
+ state_dir: state_dir.display().to_string(),
}
.into());
}
diff --git a/engine/crates/xerj-server/src/brain.rs b/engine/crates/xerj-server/src/brain.rs
index 3331f56d0..686bc9b0a 100644
--- a/engine/crates/xerj-server/src/brain.rs
+++ b/engine/crates/xerj-server/src/brain.rs
@@ -1003,6 +1003,7 @@ mod tests {
journal_records: 42,
files_done_journaled: 7,
dataset_indices: 2,
+ state_dir: "/tmp/xerj-state".to_string(),
}
.into();
assert!(zero_live_is_journal_server_disagreement(
@@ -1040,6 +1041,7 @@ mod tests {
journal_records: 3,
files_done_journaled: 1,
dataset_indices: 1,
+ state_dir: "/tmp/xerj-state".to_string(),
}
.to_string();
assert!(