From 376f03a445ca9c708b84110a4dbd3ec1ca560ab9 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)