[#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 <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2022-06-27 14:06:28 +03:00 committed by Evgenii Stratonikov
parent 596d877a44
commit a6d1eefeff
2 changed files with 6 additions and 6 deletions

View file

@ -114,5 +114,9 @@ func (db *DB) init(reset bool) error {
// Close closes boltDB instance.
func (db *DB) Close() error {
if db.boltDB != nil {
return db.boltDB.Close()
}
return nil
}

View file

@ -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 {