[#1085] shard: Close components in reverse order

Write-cache should be closed before blobstor and metabase.

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
Evgenii Stratonikov 2022-01-18 17:26:30 +03:00 committed by LeL
parent b432ec3a03
commit 3215210d0c

View file

@ -127,14 +127,14 @@ func (s *Shard) refillMetabase() error {
// Close releases all Shard's components.
func (s *Shard) Close() error {
components := []interface{ Close() error }{
s.blobStor, s.metaBase,
}
components := []interface{ Close() error }{}
if s.hasWriteCache() {
components = append(components, s.writeCache)
}
components = append(components, s.blobStor, s.metaBase)
for _, component := range components {
if err := component.Close(); err != nil {
return fmt.Errorf("could not close %s: %w", component, err)