From a6d1eefeff1aec00d5318b98e71b4a9218026cec Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Mon, 27 Jun 2022 14:06:28 +0300 Subject: [PATCH] [#1549] shard: Always close metabase Make `meta.DB` to call `Close` method on `bbolt.DB` instance if it is non-nil only. Call `meta.DB.Close` in `shard.Shard.Close` anyway. Signed-off-by: Leonard Lyubich --- pkg/local_object_storage/metabase/control.go | 6 +++++- pkg/local_object_storage/shard/control.go | 6 +----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/local_object_storage/metabase/control.go b/pkg/local_object_storage/metabase/control.go index 42f60d2c4..e689824fd 100644 --- a/pkg/local_object_storage/metabase/control.go +++ b/pkg/local_object_storage/metabase/control.go @@ -114,5 +114,9 @@ func (db *DB) init(reset bool) error { // Close closes boltDB instance. func (db *DB) Close() error { - return db.boltDB.Close() + if db.boltDB != nil { + return db.boltDB.Close() + } + + return nil } diff --git a/pkg/local_object_storage/shard/control.go b/pkg/local_object_storage/shard/control.go index 930e5e8e2..f1b44c7e3 100644 --- a/pkg/local_object_storage/shard/control.go +++ b/pkg/local_object_storage/shard/control.go @@ -204,11 +204,7 @@ func (s *Shard) Close() error { components = append(components, s.writeCache) } - components = append(components, s.pilorama, s.blobStor) - - if s.GetMode() != ModeDegraded { - components = append(components, s.metaBase) - } + components = append(components, s.pilorama, s.blobStor, s.metaBase) for _, component := range components { if err := component.Close(); err != nil {