From 9009612a824ffa8b46e698fe3962d5ccd24c6b19 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Thu, 12 Jan 2023 16:29:39 +0300 Subject: [PATCH] [#2198] blobovniczatree: Properly handle concurrent active blobovnicza update Signed-off-by: Evgenii Stratonikov --- .../blobstor/blobovniczatree/put.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/pkg/local_object_storage/blobstor/blobovniczatree/put.go b/pkg/local_object_storage/blobstor/blobovniczatree/put.go index 01a026d4e..8da731d58 100644 --- a/pkg/local_object_storage/blobstor/blobovniczatree/put.go +++ b/pkg/local_object_storage/blobstor/blobovniczatree/put.go @@ -6,6 +6,7 @@ import ( "github.com/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobovnicza" "github.com/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor/common" + "go.etcd.io/bbolt" "go.uber.org/zap" ) @@ -45,11 +46,14 @@ func (b *Blobovniczas) Put(prm common.PutPrm) (common.PutRes, error) { } if _, err := active.blz.Put(putPrm); err != nil { - // check if blobovnicza is full - if errors.Is(err, blobovnicza.ErrFull) { - b.log.Debug("blobovnicza overflowed", - zap.String("path", filepath.Join(p, u64ToHexString(active.ind))), - ) + // Check if blobovnicza is full. We could either receive `blobovnicza.ErrFull` error + // or update active blobovnicza in other thread. In the latter case the database will be closed + // and `updateActive` takes care of not updating the active blobovnicza twice. + if isFull := errors.Is(err, blobovnicza.ErrFull); isFull || errors.Is(err, bbolt.ErrDatabaseNotOpen) { + if isFull { + b.log.Debug("blobovnicza overflowed", + zap.String("path", filepath.Join(p, u64ToHexString(active.ind)))) + } if err := b.updateActive(p, &active.ind); err != nil { if !isLogical(err) {