From 745c9be4c93a4de35ed4a5ab2552b52695af7519 Mon Sep 17 00:00:00 2001 From: Alejandro Lopez Date: Fri, 11 Aug 2023 16:43:23 +0300 Subject: [PATCH] [#598] Hold mode mutex when setting mode Signed-off-by: Alejandro Lopez --- pkg/local_object_storage/writecache/writecachebadger/mode.go | 3 +++ pkg/local_object_storage/writecache/writecachebbolt/mode.go | 3 +++ 2 files changed, 6 insertions(+) diff --git a/pkg/local_object_storage/writecache/writecachebadger/mode.go b/pkg/local_object_storage/writecache/writecachebadger/mode.go index 9a39fa41a..03d861831 100644 --- a/pkg/local_object_storage/writecache/writecachebadger/mode.go +++ b/pkg/local_object_storage/writecache/writecachebadger/mode.go @@ -22,6 +22,9 @@ func (c *cache) SetMode(m mode.Mode) error { )) defer span.End() + c.modeMtx.Lock() + defer c.modeMtx.Unlock() + err := c.setMode(ctx, m) if err == nil { c.metrics.SetMode(m) diff --git a/pkg/local_object_storage/writecache/writecachebbolt/mode.go b/pkg/local_object_storage/writecache/writecachebbolt/mode.go index f7a9fffa3..b187996a1 100644 --- a/pkg/local_object_storage/writecache/writecachebbolt/mode.go +++ b/pkg/local_object_storage/writecache/writecachebbolt/mode.go @@ -22,6 +22,9 @@ func (c *cache) SetMode(m mode.Mode) error { )) defer span.End() + c.modeMtx.Lock() + defer c.modeMtx.Unlock() + err := c.setMode(ctx, m) if err == nil { c.metrics.SetMode(m)