From 123328a2f4e0bb7dc6dcf6093a13e01cea95d235 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Fri, 8 Oct 2021 13:28:57 +0300 Subject: [PATCH] blobstor: close all opened blobovniczas Signed-off-by: Evgenii Stratonikov --- .../blobstor/blobovnicza.go | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/pkg/local_object_storage/blobstor/blobovnicza.go b/pkg/local_object_storage/blobstor/blobovnicza.go index 4808a0db7..c71ddd15d 100644 --- a/pkg/local_object_storage/blobstor/blobovnicza.go +++ b/pkg/local_object_storage/blobstor/blobovnicza.go @@ -829,8 +829,6 @@ func (b *blobovniczas) close() error { b.activeMtx.Lock() b.lruMtx.Lock() - b.opened.Purge() - b.lruMtx.Unlock() for p, v := range b.active { if err := v.blz.Close(); err != nil { @@ -839,9 +837,23 @@ func (b *blobovniczas) close() error { zap.String("error", err.Error()), ) } - - delete(b.active, p) + b.opened.Remove(p) } + for _, k := range b.opened.Keys() { + v, _ := b.opened.Get(k) + blz := v.(*blobovnicza.Blobovnicza) + if err := blz.Close(); err != nil { + b.log.Debug("could not close active blobovnicza", + zap.String("path", k.(string)), + zap.String("error", err.Error()), + ) + } + b.opened.Remove(k) + } + + b.active = make(map[string]blobovniczaWithIndex) + + b.lruMtx.Unlock() b.activeMtx.Unlock()