From 466e9ee8ef2fb9995fedad62a22903a50d6791cc Mon Sep 17 00:00:00 2001 From: Jeff Woo Date: Tue, 21 Dec 2021 12:35:14 +0900 Subject: [PATCH 1/2] fix: concurrent map read --- bin/v0.34.x/rpc/cache.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/v0.34.x/rpc/cache.go b/bin/v0.34.x/rpc/cache.go index c19e643..48b4b58 100644 --- a/bin/v0.34.x/rpc/cache.go +++ b/bin/v0.34.x/rpc/cache.go @@ -154,8 +154,8 @@ func (cb *CacheBackend) HandleCachedHTTP(writer http.ResponseWriter, request *ht // same query is processing but not cached yet. // subscribe for cache result here. cb.subscribeCount[uri]++ - cb.mtx.Unlock() response := <-cb.resultChan[uri] + cb.mtx.Unlock() writer.WriteHeader(response.status) writer.Write(response.body) From ec037dd722d3b1fceeaad7ce5716a7e6c66405ba Mon Sep 17 00:00:00 2001 From: Jeff Woo Date: Tue, 21 Dec 2021 12:54:16 +0900 Subject: [PATCH 2/2] fix: usd rlock --- bin/v0.34.x/rpc/cache.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bin/v0.34.x/rpc/cache.go b/bin/v0.34.x/rpc/cache.go index 48b4b58..1b1edea 100644 --- a/bin/v0.34.x/rpc/cache.go +++ b/bin/v0.34.x/rpc/cache.go @@ -154,9 +154,12 @@ func (cb *CacheBackend) HandleCachedHTTP(writer http.ResponseWriter, request *ht // same query is processing but not cached yet. // subscribe for cache result here. cb.subscribeCount[uri]++ - response := <-cb.resultChan[uri] cb.mtx.Unlock() + cb.mtx.RLock() + response := <-cb.resultChan[uri] + cb.mtx.RUnlock() + writer.WriteHeader(response.status) writer.Write(response.body) }