Skip to content

fix(search): contain faults while copying results - #1126

Open
aaaaaandrew wants to merge 2 commits into
sourcegraph:mainfrom
aaaaaandrew:fix/result-copy-fault
Open

fix(search): contain faults while copying results#1126
aaaaaandrew wants to merge 2 commits into
sourcegraph:mainfrom
aaaaaandrew:fix/result-copy-fault

Conversation

@aaaaaandrew

@aaaaaandrew aaaaaandrew commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Summary

  • guard the final FileMatch copy after the per-shard search guard has returned
  • drop only matches whose copy faults and keep the response incomplete
  • preserve exact shard provenance through aggregation
  • count each faulted shard once and schedule the repair path from fix(search): repair shards after recovered faults #1125

This is stacked on #1125. The guard stays at the delayed-copy boundary, after global result limiting. A limited-result benchmark remained within low-single-digit percentage overhead.

Test plan

  • go test ./...
  • go test -race ./search
  • go vet ./search
  • Linux late-copy fault coverage for search, streaming, limiting, and ambiguous provenance

@keegancsmith keegancsmith left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've never seen this happen in practice. Are you seeing it cause of NFS? I wonder if there is a more fundamental change we can make such that we can treat the shards as proper immutable blobs that we can do a bit of validation on when we load it up.

I have a feeling for a normal FS if we successfully find a match, this part of the code should continue to work.

Comment thread search/shards.go Outdated

logShardCrash("copy", shard, q, recovered, stack)
ss.shardRepairs.schedule(shard)
return

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a repo can be in multiple shards.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. I removed repository-based attribution. Each shard result now records one range covering its mmap-backed match pointers; the final copy resolves the exact searched shard after aggregation. Overlapping ranges are treated as ambiguous and do not repair either shard. There is a regression with the same repository present in two shards.

Comment thread search/shards.go Outdated
Comment on lines +975 to +980
sr.Stats.Crashes++
metricSearchCrashesTotal.Inc()
if onFault != nil {
onFault(file, recovered, stack)
}
continue

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

definition of Stats.Crashes is the number of shards that crashed, this will increment per file that failed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. Crash deduplication now lives in the request-scoped provenance tracker, so multiple bad matches and multiple StreamSearch repository events from one shard contribute exactly one crash and one metric increment. Both cases are covered.

@aaaaaandrew
aaaaaandrew force-pushed the fix/result-copy-fault branch from 95b2a54 to 6b4b6c4 Compare August 12, 2026 18:11
@aaaaaandrew

aaaaaandrew commented Aug 12, 2026

Copy link
Copy Markdown
Contributor Author

Yes, the observed failure is on AWS EFS over NFSv4.1; #1109 has the sequence and two-client control. I agree immutable generation paths are the root fix. Load-time validation cannot catch a shard whose backing object is invalidated later. This PR only contains the remaining copy window while publication lifetime is handled separately.

@aaaaaandrew
aaaaaandrew force-pushed the fix/result-copy-fault branch from 6b4b6c4 to 8c40515 Compare August 21, 2026 16:36
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