Repository navigation
Conversation
…ress as stalled Root cause: run_rust_indexing_phase sets the Rust-pipeline flag, releases the database and awaits the native pipeline.run in a thread, with no ceiling and no cancellation; the flag clears only when the call returns. The initial scan runs with no resync pending, so if its Rust run hangs (a deadlocked parse worker, for example) the live state reads idle (empty backlog) or busy, daemon_status stays initializing, and the hang is reported nowhere. No progress callback was passed at all without a progress display. Design: - SerialDatabaseExecutor keeps a heartbeat for the hold: the monotonic time and phase of the last progress callback, stamped when the flag is set and cleared with it. note_rust_pipeline_progress writes the two attributes directly, never through execute/submit (they fast-fail while the flag is set). rust_pipeline_progress returns (idle seconds, last phase) during a hold. SerialDatabaseProvider and the DatabaseProvider protocol delegate both. The callback writes off the event loop and the status read happens on it; the two stores are unlocked because a torn read can only pair a new time with the previous phase, which changes the ceiling of that one read. - run_rust_indexing_phase always passes a callback taking write-data's four arguments; it notes progress on the database, then forwards to the progress bridge when one exists. - The status read computes the stalled hold once and passes it to both the state and the hint, so they cannot disagree. The state checks it after degraded and uninitialized and before busy/idle: a hold idle past its ceiling reads stalled even with an empty backlog, which the aggregate daemon status reports as degraded. The ceiling is 600 s, or 2 x the compaction timeout (1320 s) when the last phase is write-compact or write-index, single native steps with no callback until write-done. The hint names the idle time and the last phase, or says no progress has arrived since the run started. - _COMPACTION_OPERATION_TIMEOUT_SECONDS becomes the public COMPACTION_OPERATION_TIMEOUT_SECONDS, since the realtime service now reads it; its test users are updated. - Rejected: releasing parked writes to the budgeted retry path. That turns a visible stall into per-file retry-budget failures while the database is still held, so they cannot succeed anyway. - Not done: stopping a hung native run, which Python cannot interrupt. Tests: - test_hung_rust_hold_reads_stalled: real DuckDB provider and executor, read through daemon_status; an empty backlog under a hold idle 601 s reads stalled with the hold hint and aggregate degraded; 590 s, and write-compact at 700 s, do not. Reads idle without the fix. - test_rust_run_progress_is_noted_without_progress_display: with no progress display, the phase is None when the hold starts and is write-data after a write-data callback, read through rust_pipeline_progress. Fails without the fix (no callback) and with a no-op note. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…s step Root cause The serial executor kept one (time, phase) heartbeat for a Rust hold, written by whichever Rust thread reported last, and the realtime service picked the stall ceiling from that last phase (22 minutes for write-compact/write-index, else 10). The phases come from different threads in src/pipeline/pipeline.rs: diff, parse, embed and done from the main, parse and embed threads; every write-* phase only from the store thread. So the last phase does not say what the store thread is doing: 1. The store thread opens the database first (backend.open(), pipeline.rs ~650), which rebuilds any missing HNSW index with no callback (src/db/duckdb_backend/mod.rs:101). The last phase is then parse, embed or None, so a 10-22 minute rebuild read stalled at 10. 2. After a disk-limit trip the store thread drops store_rx (pipeline.rs:833-835) and emits write-index (pipeline.rs:893) before building the HNSW indexes, while the parse and embed threads can still report their in-flight batch (the parse thread emits at pipeline.rs:619 before its send at :621; embed likewise before store_tx.send). That late report overwrote the phase and dropped the ceiling to 10 minutes while the single native step ran. The main thread's own final reports (pipeline.rs:1139-1142) come after it joins all three stages (:1084-1086), so they cannot land during compact or index. Design The executor keeps one heartbeat per stage: the main stage (main, parse and embed threads) and the store stage (the store thread, the only one that reports write-* phases), plus the hold's start time. Each stage's report is one attribute store of a (time, phase) tuple, written by that stage's threads and read on the event loop, so its time and phase never tear; no lock is needed, and a read can at worst combine one stage's newer report with the other's previous one. The readers load the attributes before checking the hold flag, and the hold's end clears the flag before the attributes, so a read that still sees the flag set got this hold's values; otherwise a hold ending mid-read (the status can be built on the watchdog observer thread) could pair a live start time with cleared reports and report the whole hold as idle. rust_pipeline_progress() keeps its shape, (seconds since the last report from any stage, its phase) or None outside a hold, so its callers and the status hint are unchanged. A new rust_pipeline_store_phase() returns the store stage's latest phase, or None outside a hold or before its first report. The service reads the store phase first, then the progress. A report landing between the two reads then only refreshes the idle time, a hold ending between them reads None, and a hold starting between them reads the long ceiling, so every interleaving is safe. In the other order a store report between the reads could pair an old long idle time with a new short ceiling and read a false stall. Ceiling rule: no store report yet, or the store stage in write-compact or write-index, gets 22 minutes; any other store phase gets 10. Stalled when the idle time exceeds the ceiling. Trade-off A hang before the store thread's first report (the diff phase, or the store's open, HNSW rebuild, HNSW drop and orphan deletes; write-prepare is emitted right after those and before any batch) reads stalled after 22 minutes instead of 10. This is not gated on HNSW being enabled: there is no switch for it, and the native open path rebuilds whatever HNSW indexes the schema expects. Residual not fixed On a store error after the HNSW drop, the error path's backend.close() rebuilds every HNSW index (hnsw_bulk_mode, mod.rs:107-111) with no callback under the last write-data or write-prepare phase, so a long rebuild can still read stalled at 10 minutes before the run fails. That needs a native emit. Rejected - Emitting write-index from Rust before the open-time rebuild: needs a native release. - One heartbeat that ignores main-stage reports once the store has reported: loses the main threads' heartbeat. Tests tests/realtime/test_realtime_status_read.py, through the public progress methods and a daemon_status read with time.monotonic advanced: - test_hung_rust_hold_reads_stalled, rewritten off the private attributes: write-data at +601 s reads stalled (aggregate degraded), at +590 s idle; write-compact at +700 s idle. - test_late_main_report_keeps_the_store_step_ceiling: write-index then parse, +700 s reads idle. Read stalled before this change. - test_hold_before_the_store_reports_uses_the_long_ceiling: parse and embed with no store report, +700 s reads idle and +1321 s stalled. Read stalled at +700 s before this change. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Brings in chunkhound#489, chunkhound#474, chunkhound#488, chunkhound#521, chunkhound#510, chunkhound#504 and chunkhound#534. No conflicts. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Nov 17, 2026
Collaborator
|
@fstrasz can you resolve the merge issue? |
Main is at e776eba (v6.2.0). The only conflict was CHANGELOG.md: 6.2.0 is released, so this PR's "A hung Rust indexing run is reported" entry moves to [Unreleased] -> Fixed, and the 6.2.0 section is upstream's unchanged. The other files merged cleanly, and the PR's diff against main in its nine code and test files is line-for-line the same as before the merge. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Contributor
Author
|
Resolved: I merged current main (e776eba, v6.2.0) into the branch. The only conflict was in CHANGELOG.md: 6.2.0 is now released, so this PR's entry moved to [Unreleased] → Fixed. The other files merged cleanly, and the PR's diff against main is unchanged in all nine code and test files. 🤖 Generated with Claude Code, reviewed by FStrasz |
chunkhound#509's overflow test builds the realtime service with no database provider and reads its health. The status read computed the stalled Rust hold before deriving the live state, so every read touched the provider, and that test failed with "'NoneType' object has no attribute 'rust_pipeline_store_phase'". The state derivation now reads the hold itself, after the degraded and uninitialized checks, and returns it with the state, so the state and its hint still come from one read. A degraded or uninitialized service no longer touches the provider. The hint uses the hold only for a stalled state, so no reported state or hint changes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Contributor
Author
|
The shard 1 failure came from #509's overflow test, which builds the realtime service with no database provider; this PR's status read touched the provider on every read. be854ab reads the Rust hold only after the degraded and uninitialized checks, so that test passes and no reported state changes. 🤖 Generated with Claude Code, reviewed by FStrasz |
Resolves the CHANGELOG.md conflict under [Unreleased]: upstream's Added,
Changed, Fixed and Removed sections are kept as they are, and this PR's
Fixed entry ("A hung Rust indexing run is reported") is added at the end
of upstream's Fixed list, so there is one Fixed heading, in Keep a
Changelog order. No other file conflicted.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
While a Rust indexing run holds the database, nothing reports that the run has hung.
run_rust_indexing_phasesets the Rust-pipeline flag, releases the database and awaits the nativepipeline.runin a thread. There is no ceiling and no cancellation, and the flag clears only when the call returns. The initial scan runs with no resync pending.So if that Rust run hangs (a deadlocked parse worker, for example):
idle(empty backlog) orbusy;daemon_statusstaysinitializing;Without a progress display, no progress callback was passed at all.
Fix
Two commits.
1. Report a hold with no progress as stalled.
SerialDatabaseExecutorkeeps a heartbeat for the hold: the monotonic time and phase of the latest progress callback. It is stamped when the flag is set and cleared with it.note_rust_pipeline_progresswrites it directly, never throughexecute/submit, which fail fast while the flag is set.rust_pipeline_progress()returns(idle seconds, last phase)during a hold.SerialDatabaseProviderand theDatabaseProviderprotocol delegate both.run_rust_indexing_phasealways passes a progress callback. It notes progress on the database, then forwards to the progress bridge when there is one.stalledeven with an empty backlog. The aggregate daemon status then reportsdegraded._COMPACTION_OPERATION_TIMEOUT_SECONDSbecomes public (COMPACTION_OPERATION_TIMEOUT_SECONDS), because the realtime service now reads it. Its test users are updated.2. Pick the ceiling from the store stage's step. The phases come from different Rust threads (
src/pipeline/pipeline.rs):diff,parse,embedanddonecome from the main, parse and embed threads;write-*phase comes only from the store thread.So "the last phase from any thread" doesn't say what the store is doing:
write-indexand drop the ceiling to 10 minutes while that single native step ran.The executor now keeps one heartbeat per stage: the main stage (main, parse and embed threads) and the store stage (the store thread). Each stage's report is a single attribute store of a
(time, phase)tuple, so it never tears.write-compact/write-index, which are single native steps with no callback untilwrite-done;rust_pipeline_progress()keeps its shape.rust_pipeline_store_phase()returns the store stage's latest phase.Trade-off: a hang before the store thread's first report reads stalled after 22 minutes instead of 10. That covers the diff phase and the store's open, HNSW rebuild, HNSW drop and orphan deletes.
Not fixed, needs a native change:
backend.close()rebuilds the HNSW indexes with no callback, under the lastwrite-data/write-preparephase. A long rebuild there can still read stalled at 10 minutes before the run fails.Rejected:
write-indexfrom Rust before the open-time rebuild. That needs a native release.Tests
tests/realtime/test_realtime_status_read.pyuses the public progress methods and adaemon_statusread withtime.monotonicadvanced:test_hung_rust_hold_reads_stalled(real DuckDB provider and executor)write-datareadsstalled, with the hold hint and aggregatedegraded; 590 s, andwrite-compactat 700 s, do notidletest_late_main_report_keeps_the_store_step_ceilingwrite-index, then a lateparse; at +700 s readsidlestalledtest_hold_before_the_store_reports_uses_the_long_ceilingparseandembedwith no store report; at +700 s readsidle, at +1321 sstalledstalledat +700 stests/unit/test_rust_pipeline_runner.py:test_rust_run_progress_is_noted_without_progress_displaychecks that, with no progress display, awrite-datacallback is noted. It fails with no callback, and also with a callback that notes nothing.Each of four mutations of the stage logic made a test fail.
These were run serially on a merge of this branch with current main (24752d0):
tests/realtime, the realtime functional and failure tests,tests/contracts, and the compaction, execute-timeout, runner and compaction-retry unit tests. Results: 429 passed / 38 skipped on main, 433 / 38 merged.ruff and mypy report the same findings as main on the changed files. Upstream's CI workflow on our fork at this head (3a14141) was green on every job on 2026-11-11, under Rust 1.99.1: https://github.com/fstrasz/chunkhound/actions/runs/43083267969
This PR changes no Rust code.
Not reproduced end to end: a real hung native run can't be induced from Python. The tests drive the heartbeat through the public methods instead.
Overlap
This PR is standalone on main and depends on no open PR.
These merge cleanly with main today and conflict mechanically with this PR. Whichever merges second rebases:
interfaces/database_provider.pyandserial_database_provider.py. fix(realtime): wait out a known database hold instead of spending the retry budget #519 addsis_compaction_in_progressnext to the new methods; keep both.services/realtime/service.py.These already conflict with main, and also edit files this PR changes:
serial_database_provider.py,rust_pipeline_runner.py,test_duckdb_compaction.py,test_db_execute_timeout_config.pyandtest_rust_pipeline_runner.py. Feat/hub client #442 also editsserial_executor.py; fix(duckdb): leverage HNSW index in semantic search by decoupling filters from ANN scan and add toggle to disable #392 also editsservices/realtime/service.py.serial_database_provider.py,serial_executor.pyandtest_duckdb_compaction.py.CHANGELOG.md:[Unreleased]→ Fixed.🤖 Generated with Claude Code, reviewed by FStrasz