An unchanged restart re-parses ~743 files and re-resolves for 3–4 minutes (zammad-dev: every idle restart) #358
Labels
No labels
code-review
correctness
dos
performance
security
severity/high
severity/low
severity/medium
tech-debt
Kind/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
h-dv/code-index#358
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Field report (zammad-dev, 2026-10-12, 0.36.1 /
876b78b5, de.h-dv.ruby 0.10.0, de.h-dv.vue 0.1.0)idle_timeout_min = 30, and the daemon has shut down for idle 29 times since 2026-10-06, which is a normal working day with pauses. After each restart the initial reconciliation re-parses the same ~743 files, all of them "reclassified", and resolves again:The 06:05 and 13:34 runs had no file changes at all, yet each re-parsed 743 files and spent over 4 minutes in resolution. Log:
/opt/zammad-dev/.code-index/daemon.loglines 10570, 10628, 10723 and 10903 ("index stage complete: reference resolution").The disclosure works as intended: every answer carries
index_state: reconcilingand "a zero is not absence". In practice, though, every return after a pause means 3–4 minutes where all counts are floors and have to be checked by hand.Hypothesis (unverified)
743 is close to the project's 761
.vuefiles (de.h-dv.vue/vue). The reclassification of package-claimed files may not be persisted, so a restart sees each one as "claimed differently than recorded" and re-extracts it, which then invalidates and re-resolves its references.To check
.vuefiles and the vue package, stop the daemon, restart with no changes, and countreclassifiedand parsed files. The expectation is 0 and 0.Workaround given to the reporter
[daemon] idle_timeout_minwith a large value, e.g. 480. Note that0means the 30-minute default, not "never" (crates/daemon/src/main.rs,IDLE_TIMEOUT).🤖 Generated with Claude Code
The workaround in this issue does not work:
[daemon] idle_timeout_minis a dead config keyThe reporter tested it (2026-10-12): they set
idle_timeout_min = 480at 17:07Z, and a daemon spawned bycode-index-mcpat 17:27Z still loggedidle timeout reached; shutting down idle=1800sat 17:57:18Z.Verified in the tree (train-037, same on 0.36.1):
DaemonConfig::idle_timeout_min(crates/indexer/src/config.rs) is parsed and read by nothing in production. Its only other occurrences are a config test and the CLI's config template.--idle-min(crates/daemon/src/main.rs, default 30;0falls back to the same 30-minuteIDLE_TIMEOUT).lifecycle::daemon_command, which passes only--rootand--dband no environment.code-index doctorreports "no dead keys" for[watcher]only, so it says nothing about this one.Fix together with the re-parse, in the next train:
[daemon] idle_timeout_min(the CLI flag wins when given). Say what0means and keep it consistent across both.doctorcovers[daemon]keys.daemon_commandwithidle_timeout_minset in the manifest honours it. Run the mutation that ignores the key.Interim workaround sent to the reporter (not tested on their setup): start the daemon by hand with
--idle-min 480before the MCP client attaches.🤖 Generated with Claude Code
Root-cause candidate (read from the code, not yet reproduced)
Found by dogfooding code-index 0.36.1 on train-037 (
search_text "reclassified"→reconcile::classify_stat→snapshot::FileSnapshot::producer_moved→snapshot::load).crates/indexer/src/snapshot.rs::loadreads the snapshot withSELECT f.path, …, p.package_key, c.lang FROM {PRODUCER_FROM}.PRODUCER_FROMisfiles f LEFT JOIN file_contributions fc ON fc.file_id = f.id AND fc.generation_id = ?1 …, so a file with several live contributions yields several rows.out.insert(path, FileSnapshot { … producer }), so the last row wins..vuefile with a<script>region has (at least) two live contributions:lang de.h-dv.vue/vue=files.lang;writer::write_delegated→contributions::ensure_delegated_component,lang typescript.informative_producer(lang = "de.h-dv.vue/vue", key = "de.h-dv.vue", component_lang = "typescript")returnsNone, becauserow_lang("typescript") != files.lang.producer_moved("de.h-dv.vue")readsNoneasbuiltin, so it returnstrue.classify_statthen answersReclassified, and the file is fully re-extracted, which invalidates and re-resolves its refs.That fits the field numbers: about 743 of 761
.vuefiles (those with a script region) are reclassified on every start with zero changes. Which row SQLite returns last is plan-dependent, so it may vary between files and builds.The watcher's per-event lookup shares
PRODUCER_FROM(doc comment above it), so the same ambiguity may affect watcher events on.vuefiles.Fix direction (generic, any package with regions)
files.lang, not "any contribution". Select that row (e.g. filterrow_lang(c.lang) = f.langin SQL, or fold the rows so one informative producer wins overNone), never last-row-wins..vuefixture with a script region, indexed, daemon restarted with no change, assertsreclassified == 0and parsed== 0. Run the mutation that restores last-row-wins.🤖 Generated with Claude Code
Released in v0.40.0 (https://git.h-dv.de/h-dv/code-index/releases/tag/v0.40.0, PR #388, merge
a48fb945): a restart with nothing changed parses nothing, including with the Vue package, and[daemon] idle_timeout_minis honoured.