[bug/rfe] Rebuild or mark repos stale when zoekt shard files are missing but DB marks repos indexed
Maintainer antworten meist innerhalb von 1 Tag
@reddynitish arbeitet bereits daran.
Seit 30.8.2026.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 58/100
- Issue-Typ
- Bug
- Klarheit
- Größtenteils klar
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- typescript
Rechercherichtung
Start in packages/backend/src/repoIndexManager.ts with scheduleIndexJobs() and cleanupOrphanedDiskResources(), then inspect startup directory handling in packages/backend/src/index.ts and shard creation in packages/backend/src/zoekt.ts. Reproduce by deleting the shard files and restarting with a long reindex interval; done means missing shards trigger recovery and search returns the repository contents again.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Summary
If the zoekt index directory is deleted while the Sourcebot database and repo clones remain intact, Sourcebot starts successfully but does not automatically rebuild the missing shards. Repos remain marked as indexed in the DB, while zoekt has no shard files to search, so search returns incomplete or empty results from an otherwise healthy instance.
This matters for Kubernetes deployments that want to place only .sourcebot/index on more performant ephemeral/local storage while keeping DB/repos on durable storage.
Version
Observed on:
- Sourcebot image:
ghcr.io/sourcebot-dev/sourcebot:v4.17.1
Background / Use Case
For performance reasons, we are evaluating a hybrid storage layout:
- durable PVC for
/data - node-local / ephemeral storage for
/data/.sourcebot/index
The zoekt index is derived/rebuildable, while the DB and repo clones should remain durable. This can improve cold/random read performance for large zoekt indexes, but pod replacement would delete only the index directory.
In that scenario, Sourcebot should ideally detect that indexed repos no longer have shard files and enqueue rebuilds, or otherwise mark those repos as not indexed.
Current Behavior
When /data/.sourcebot/index is empty but the DB still has repos with fresh indexedAt values:
- Sourcebot starts normally.
- zoekt tolerates the empty index directory.
- The repo remains marked as indexed/completed in the DB.
- No new indexing job is scheduled.
- Search returns zero/incomplete results.
- Manual reindex through
/api/index-reposuccessfully rebuilds the missing shard.
Expected Behavior
On startup, or during repo-index scheduling, Sourcebot should detect repos that are marked indexed in the DB but have no corresponding zoekt shard files.
Possible expected behaviors:
- enqueue index jobs for affected repos,
- set
indexedAt = nullfor affected repos so the existing scheduler picks them up, - or expose a supported startup/recovery command that rebuilds all missing index shards.
Relevant Code Paths
From a quick read of the code:
-
packages/backend/src/constants.tsREPOS_CACHE_DIR = DATA_CACHE_DIR/reposINDEX_CACHE_DIR = DATA_CACHE_DIR/index
-
packages/backend/src/index.ts- creates the repos and index directories at startup if absent
-
packages/backend/src/repoIndexManager.tsscheduleIndexJobs()selects repos whereindexedAtisnullor older thanreindexIntervalMscleanupOrphanedDiskResources()removes shard files with no corresponding DB repo, but does not detect the inverse: DB repo exists and is marked indexed, but shard files are missing
-
packages/backend/src/zoekt.tsindexGitRepository()invokeszoekt-git-index -index ${INDEX_CACHE_DIR}
Suggested Fix
Add startup or scheduler reconciliation that compares DB repo state with shard files in INDEX_CACHE_DIR.
For each repo with indexedAt != null, verify that at least one shard exists with that repo's shard prefix. If no shard exists, either:
- enqueue an index job for that repo, or
- mark the repo as stale by clearing
indexedAt, allowing the existing scheduler to enqueue it.
This would make derived/ephemeral index storage safe to use with durable DB/repos.
To reproduce
Reproduction
Use a small Sourcebot instance with a local file:// repo.
Example config:
{
"connections": {
"local-repos": {
"type": "git",
"url": "file:///data/local-repos/*"
}
},
"settings": {
"reindexIntervalMs": 86400000,
"reindexRepoPollingIntervalMs": 1000,
"maxRepoIndexingJobConcurrency": 1
}
}
The long reindexIntervalMs is intentional so we can distinguish immediate missing-shard recovery from the normal periodic reindex.
Steps:
- Create a local git repo under
/data/local-repos/testrepo. - Start Sourcebot.
- Wait for the repo to index successfully.
- Confirm:
- a shard exists under
/data/.sourcebot/index - the repo has
indexedAtset - search returns a result from the repo
- a shard exists under
- Delete only the zoekt shard files:
rm -f /data/.sourcebot/index/*.zoekt \
/data/.sourcebot/index/*.zoekt.meta \
/data/.sourcebot/index/*.tmp
- Restart Sourcebot with the same DB and repo data.
- Observe that no new index job is created and search returns no results.
Manual recovery works:
curl -s -X POST http://localhost:3060/api/index-repo \
-H "Content-Type: application/json" \
-d '{"repoId":1}'
After this, the shard is rebuilt and search works again.
Sourcebot deployment information
ghcr.io/sourcebot-dev/sourcebot:v4.17.1
Additional information
No response
- Vorherrschende Sprache
- TypeScript
- Sterne
- 3.9k
- Forks
- 374
- Ø Merge
- 2 T. 21 Std.
- Gemergte PRs (30 T.)
- 43
Entwicklungsumgebung
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus sourcebot-dev/sourcebot
-
[bug] Search result hydration performs duplicate repository lookups within the same chunkEvtl. wieder frei @Abhishek-Sonje hat das vor 21 Tagen übernommen, und es ist kein Pull Request offen. Offenbug triage needed
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
sourcebot-dev/sourcebot#1681 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Linux ctags build instructions in CONTRIBUTING.md are missing build dependenciesEvtl. wieder frei Ein Pull Request dazu wurde ohne Merge geschlossen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
sourcebot-dev/sourcebot#1633 ·
Maintainer antworten meist innerhalb von 1 Tag
-
MCP ask_codebase rejects explicit languageModel: getLanguageModelKey includes displayName which the MCP schema doesn't exposeEvtl. wieder frei @Harsh23Kashyap hat das vor 103 Tagen übernommen, und es ist kein Pull Request offen. Offenask_sb bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
sourcebot-dev/sourcebot#1137 · 4 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
[FR] Support file-based and Azure Key Vault token sources alongside env and googleCloudSecretEvtl. wieder frei Ein Pull Request dazu wurde ohne Merge geschlossen. Offen
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 64/100
sourcebot-dev/sourcebot#1704 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
[bug] Local repositories with a space or non-ASCII character in the path cannot be indexedEvtl. wieder frei Ein Pull Request dazu wurde ohne Merge geschlossen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 35/100
sourcebot-dev/sourcebot#1689 ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in sourcebot-dev/sourcebot
Ähnliche Issues
-
Documentation Link TypoOffen
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 83/100
Zettlr/Zettlr#6610 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Feil lovtekst i bekreftelsen når leder melder unntak fra oppfølgingsplanEvtl. vergeben @AudunSorheim hat das heute übernommen. Offen
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 92/100
navikt/syfo-oppfolgingsplan-frontend#1110 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
db-ux-design-system/core-web#8461 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Maintainer antworten meist innerhalb von 1 Tag
-
Cannot run an integration on windows when power shell is selected as the default profile terminalOffenPriority/Blocker Type/Bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
wso2/product-integrator#2767 ·
Maintainer antworten meist innerhalb von 1 Tag