diff --git a/store/rootmulti/store.go b/store/rootmulti/store.go index 0c8a1ef3a3b0..d23bcc57b090 100644 --- a/store/rootmulti/store.go +++ b/store/rootmulti/store.go @@ -1147,7 +1147,9 @@ func (rs *Store) flushMetadata(db corestore.KVStoreWithBatch, version int64, cIn rs.logger.Debug("flushing metadata", "height", version) batch := db.NewBatch() defer func() { - _ = batch.Close() + if err := batch.Close(); err != nil { + rs.logger.Error("call flushMetadata error on batch close", "err", err) + } }() if cInfo != nil { diff --git a/store/v2/commitment/metadata.go b/store/v2/commitment/metadata.go index d7aea487c706..8c1e7f1f8a9d 100644 --- a/store/v2/commitment/metadata.go +++ b/store/v2/commitment/metadata.go @@ -2,6 +2,7 @@ package commitment import ( "bytes" + "errors" "fmt" corestore "cosmossdk.io/core/store" @@ -158,9 +159,7 @@ func (m *MetadataStore) deleteRemovedStoreKeys(version uint64, removeStore func( batch := m.kv.NewBatch() defer func() { - if berr := batch.Close(); berr != nil { - err = berr - } + err = errors.Join(err, batch.Close()) }() for _, storeKey := range removedStoreKeys { if err := removeStore(storeKey, version); err != nil {