Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(store): keep batch.Close error handle logic consistance #21812

Merged
merged 3 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion store/rootmulti/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 2 additions & 3 deletions store/v2/commitment/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package commitment

import (
"bytes"
"errors"
"fmt"

corestore "cosmossdk.io/core/store"
Expand Down Expand Up @@ -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 {
Expand Down
Loading