mirror of
https://github.com/sourcegraph/sourcegraph.git
synced 2026-02-06 17:51:57 +00:00
symbols: avoid spamming handleParseRequest on context cancelation (#61732)
Understanding how Parse works (and its callers) with respect to goroutines and channels is a sure path to the asylum. This is a short term fix around how it behaves when the context is canceled. From what I can tell we can have a large number of parse requests go through handleParseRequest even once the context has been canceled, leading to large amounts of logging of errors which all amount to context canceled. This is a short term fix which drains the channel if we know we are just gonna fail our call to handleParseRequest. Test Plan: go test. Didn't manual test, but the code change is minor enough that I trust it (famous last words).
This commit is contained in:
parent
f674124ec1
commit
a0b74fb665
@ -115,6 +115,12 @@ func (p *parser) Parse(ctx context.Context, args search.SymbolsParameters, paths
|
||||
break
|
||||
}
|
||||
|
||||
// Drain channel if our context has been canceled. Otherwise
|
||||
// we just logspam on handleParseRequest.
|
||||
if ctx.Err() != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
atomic.AddUint32(&totalRequests, 1)
|
||||
if err := p.handleParseRequest(ctx, symbolOrErrors, parseRequestOrError.ParseRequest, &totalSymbols); err != nil {
|
||||
log15.Error("error handling parse request", "error", err, "path", parseRequestOrError.ParseRequest.Path)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user