Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed
- Cleaned up orphaned zoekt `.tmp` shard files on every indexing attempt, not just on failure, so leftovers from previously interrupted runs are removed. [#1214](https://github.com/sourcebot-dev/sourcebot/pull/1214)

## [4.17.2] - 2026-05-16

### Added
Expand Down
1 change: 1 addition & 0 deletions packages/backend/src/repoIndexManager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ vi.mock('./git.js', () => ({

vi.mock('./zoekt.js', () => ({
indexGitRepository: vi.fn().mockResolvedValue({ stdout: '', stderr: '' }),
cleanupTempShards: vi.fn().mockResolvedValue(undefined),
}));

vi.mock('./posthog.js', () => ({
Expand Down
12 changes: 8 additions & 4 deletions packages/backend/src/repoIndexManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -516,11 +516,15 @@ export class RepoIndexManager {
const indexDuration_s = durationMs / 1000;
logger.debug(`Indexed ${repo.name} (id: ${repo.id}) in ${indexDuration_s}s`);
} catch (error) {
// Clean up any temporary shard files left behind by the failed indexing operation.
// Zoekt creates .tmp files during indexing which can accumulate if indexing fails repeatedly.
logger.warn(`Indexing failed for ${repo.name} (id: ${repo.id}), cleaning up temp shard files...`);
await cleanupTempShards(repo);
logger.warn(`Indexing failed for ${repo.name} (id: ${repo.id}).`);
throw error;
} finally {
// Zoekt writes shards to a .tmp file first, then atomically renames them to their final
// name. If the process is killed or interrupted during the rename loop, some .tmp files
// may be left behind that zoekt won't clean up on the next run (it only tracks temp
// files from the current build). Running cleanup here ensures orphans from previous
// interrupted runs are removed.
await cleanupTempShards(repo);
Comment thread
brendan-kellam marked this conversation as resolved.
}

return revisions;
Expand Down
Loading