Bound Hermes import and FTS merge WAL growth#124
Conversation
|
One process question for future contributions: is it generally okay to open a focused PR like this directly, without filing a preliminary issue first? I do not want to overuse maintainers’ trust or create review work in the wrong form. Happy to follow whichever issue-first vs. PR-first workflow you prefer. |
10a164f to
a132682
Compare
|
Benchmark update: the initial batching approach is not sufficient, so please do not review the current draft yet. On a 206–260 MB Hermes database, WAL still reached multiple GiB even with one capture per transaction. The root cause is FTS5 merge work performed inside the INSERT itself (including crisis/incremental merges), which checkpoints cannot bound mid-statement. I am revising the PR toward deferring search projection during bulk ingest and rebuilding/merging it in bounded transactions, then will replace the draft implementation and update the measurements. |
a132682 to
40543b2
Compare
|
Real-corpus follow-up after merge (corrected after tracing the setup call path):
So the bounded partial implementation works very well for the isolated Hermes import, while the clean full-setup path still exposes a real-corpus WAL spike somewhere in the surrounding bulk/FTS workflow. This is separate from the product-semantics question in my following comment about whether source-atomic/non-partial import should remain supported. |
|
@luca-ctx one product-semantics question before I prepare any follow-up. Should source-atomic/non-partial provider import remain a supported mode at all? For a disposable, idempotently rebuildable local index, it seems useful to separate two concerns that
The non-partial Hermes path preserves true all-or-nothing source atomicity, but on the real 206 MiB corpus it produced a 7 GiB WAL before rollback. Conversely, the batched partial path imported all 250 sessions / 11,922 events / 83 edges in 38.35s with zero failures, no final WAL, and an idempotent replay. Would you prefer to:
This is your product decision, so I would rather follow your intended semantics than infer it from the current CLI shape. |
What changed
Why
The original transaction-batching draft did not fully solve the reported failure. On the contributor's 206–260 MB Hermes corpus, FTS5 could still perform a crisis/incremental merge inside a single INSERT and grow the WAL by multiple GiB, even with one capture per transaction. A checkpoint cannot bound work performed inside that statement.
This replacement prevents those automatic merges during ingest and performs the merge work explicitly in bounded, recoverable transactions.
Validation
cargo test -p ctx-history-store -p ctx-history-capture -p ctx --no-fail-fastcargo clippy -p ctx-history-store -p ctx-history-capture -p ctx --tests -- -D warningscargo fmt --all -- --checkscripts/check-loc.shThe contributor's private 206–260 MB corpus was not available for direct reproduction.