Skip to content

gitindex: abort indexing after blob input errors - #1250

Merged
keegancsmith merged 2 commits into
sourcegraph:mainfrom
perfloop-oss:perfloop-pr-open-fr2zrh1e22
Nov 16, 2026
Merged

keegancsmith merged 2 commits into
sourcegraph:mainfrom
perfloop-oss:perfloop-pr-open-fr2zrh1e22

Conversation

@perfloop-agent

Copy link
Copy Markdown
Contributor

If git cat-file fails during zoekt-git-index, the deferred Finish can publish a partial or empty shard over the complete index. The command reports an error, but files—or the entire repository—then silently drop out of search.

This is the input-time sibling of merged #1227, which handles failures during shard publication. This change prevents failed blob ingestion from reaching publication in the first place, for both full and delta indexing.

Add Builder.Abort to discard buffered documents, wait for shard workers, and remove staged files without publishing them or retiring the prior index. Git indexing defers Abort and calls Finish explicitly after ingestion succeeds. Stored worker-error cleanup reuses the same path. Successful indexing and intentionally missing or size-filtered blobs keep their existing finalization behavior.

Go tests for index and gitindex passed, covering input-failure preservation and retry, abort lifecycle, worker errors, successful indexing, and publication failures. The tests in gitindex/index_test.go check unchanged index artifacts and old search results after reader-startup, header, body, and go-git blob errors, with buffered and staged prefixes; index/builder_test.go checks abort idempotency and terminal state. Repository protobuf lint passed.

Failure frequency and affected repository sizes remain unmeasured. Temporary-file cleanup is best-effort; publication remains non-atomic.

Case and evidence


Made by Perfloop. Human sponsor: Tomás Senart.

@keegancsmith
keegancsmith merged commit 3491d91 into sourcegraph:main Nov 16, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants