Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: waiting channel in lock causes halt #17

Merged
merged 1 commit into from
Dec 21, 2021
Merged
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
6 changes: 2 additions & 4 deletions bin/v0.34.x/rpc/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func (cb *CacheBackend) HandleCachedHTTP(writer http.ResponseWriter, request *ht
}

cb.mtx.Lock()
_, isInTransit := cb.resultChan[uri]
resChan, isInTransit := cb.resultChan[uri]

// if isInTransit is false, this is the first time we're processing this query
// run actual querier
Expand Down Expand Up @@ -156,9 +156,7 @@ func (cb *CacheBackend) HandleCachedHTTP(writer http.ResponseWriter, request *ht
cb.subscribeCount[uri]++
cb.mtx.Unlock()

cb.mtx.RLock()
response := <-cb.resultChan[uri]
cb.mtx.RUnlock()
response := <-resChan

writer.WriteHeader(response.status)
writer.Write(response.body)
Expand Down