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: add error log when iavl set failed (backport #13803) #13804

Merged
merged 2 commits into from
Nov 9, 2022
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
### Bug Fixes

* (x/gov) [#13728](https://github.com/cosmos/cosmos-sdk/pull/13728) Fix propagation of message events to the current context in `EndBlocker`.
* (store) [#13803](https://github.com/cosmos/cosmos-sdk/pull/13803) Add an error log if iavl set operation failed.

## [v0.46.4](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.46.4) - 2022-11-01

Expand Down
11 changes: 8 additions & 3 deletions store/iavl/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ var (

// Store Implements types.KVStore and CommitKVStore.
type Store struct {
tree Tree
tree Tree
logger log.Logger
}

// LoadStore returns an IAVL Store as a CommitKVStore. Internally, it will load the
Expand Down Expand Up @@ -87,7 +88,8 @@ func LoadStoreWithInitialVersion(db dbm.DB, logger log.Logger, key types.StoreKe
}

return &Store{
tree: tree,
tree: tree,
logger: logger,
}, nil
}

Expand Down Expand Up @@ -198,7 +200,10 @@ func (st *Store) CacheWrapWithListeners(storeKey types.StoreKey, listeners []typ
func (st *Store) Set(key, value []byte) {
types.AssertValidKey(key)
types.AssertValidValue(value)
st.tree.Set(key, value)
_, err := st.tree.Set(key, value)
if err != nil && st.logger != nil {
st.logger.Error("iavl set error", "error", err.Error())
}
}

// Implements types.KVStore.
Expand Down