Skip to content

Commit

Permalink
fix nil resp panic, deadlock on cache marshal err (#453)
Browse files Browse the repository at this point in the history
  • Loading branch information
James Ranson authored Jun 3, 2020
1 parent d18465a commit cee6faf
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/proxy/engines/deltaproxycache.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ func DeltaProxyCacheRequest(w http.ResponseWriter, r *http.Request) {
defer span.End()
}
body, resp, isHit := FetchViaObjectProxyCache(ffReq)
if resp.StatusCode == http.StatusOK && len(body) > 0 {
if resp != nil && resp.StatusCode == http.StatusOK && len(body) > 0 {
ffts, err = client.UnmarshalInstantaneous(body)
if err != nil {
ffStatus = "err"
Expand Down Expand Up @@ -386,6 +386,7 @@ func DeltaProxyCacheRequest(w http.ResponseWriter, r *http.Request) {
if writeLock != nil {
// if the mutex is still locked, it means we need to write the time series to cache
go func() {
defer writeLock.Release()
// Crop the Cache Object down to the Sample Size or Age Retention Policy and the
// Backfill Tolerance before storing to cache
switch oc.TimeseriesEvictionMethod {
Expand Down Expand Up @@ -421,7 +422,6 @@ func DeltaProxyCacheRequest(w http.ResponseWriter, r *http.Request) {
)
}
}
writeLock.Release()
}()
}

Expand Down

0 comments on commit cee6faf

Please sign in to comment.