fork of https://github.com/sourcegraph/zoekt
0

Configure Feed

Select the types of activity you want to include in your feed.

Fix no-shards-loaded being reported as crashes (#512)

Full debug context here: https://sourcegraph.slack.com/archives/C023ELQLV7F/p1672835804462349

Commit 9899a9b3f475ef066ed70c395f8b303268f5d00c changed what the
response looks like when Zoekt has never loaded a shard: it now reports
a `Crashes = 1`, even if everything's fine.

That leads to upstream errors where we show an error message in the
Sourcegraph admin UI because the customer hasn't added any repositories
to their instance yet.

The fix here changes the `loader` to also mark the `shardedSearcher` as
ready if there was nothing to load. Previously the `markReady` was
skipped, the searcher wasn't marked as "ready" and every search query
was replied to with a `Crashes = 1`

+6 -5
+6
shards/shards.go
··· 270 270 // finished running shardedSearcher will be ready. 271 271 defer tl.ss.markReady() 272 272 273 + if len(keys) == 0 { 274 + // If there's nothing to load, we exit early here, but we want to mark 275 + // ourselves as ready. 276 + return 277 + } 278 + 273 279 var ( 274 280 mu sync.Mutex // synchronizes writes to the shards map 275 281 wg sync.WaitGroup // used to wait for all shards to load
-5
shards/watcher.go
··· 181 181 } 182 182 183 183 s.loader.drop(toDrop...) 184 - 185 - if len(toLoad) == 0 { 186 - return nil 187 - } 188 - 189 184 s.loader.load(toLoad...) 190 185 191 186 return nil