From 45109cba56677d056f457e36825273ec80cc1593 Mon Sep 17 00:00:00 2001 From: Matheus Nogueira Date: Thu, 14 Sep 2023 16:15:58 -0300 Subject: [PATCH] fix: use mutex --- server/traces/caching.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/server/traces/caching.go b/server/traces/caching.go index dbc7657801..e53271ea71 100644 --- a/server/traces/caching.go +++ b/server/traces/caching.go @@ -8,6 +8,9 @@ var cache spanCache = nil var cacheMutex sync.Mutex func getCache() spanCache { + cacheMutex.Lock() + defer cacheMutex.Unlock() + if cache == nil { cache = spanCache{} } @@ -16,6 +19,9 @@ func getCache() spanCache { } func resetCache() { + cacheMutex.Lock() + defer cacheMutex.Unlock() + cache = nil }