Skip to content

Commit 22f3261

Browse files
authored
refactor: add error log when iavl set failed (#13803)
* add error log when iavl set failed Ref: #12012 * Update CHANGELOG.md * play safe
1 parent a785bf5 commit 22f3261

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
8585
* [#13236](https://github.com/cosmos/cosmos-sdk/pull/13236) Integrate Filter Logging
8686
* [#13528](https://github.com/cosmos/cosmos-sdk/pull/13528) Update `ValidateMemoDecorator` to only check memo against `MaxMemoCharacters` param when a memo is present.
8787
* [#13651](https://github.com/cosmos/cosmos-sdk/pull/13651) Update `server/config/config.GetConfig` function.
88+
* [#13803](https://github.com/cosmos/cosmos-sdk/pull/13803) Add an error log if iavl set operation failed.
8889

8990
### State Machine Breaking
9091

store/iavl/store.go

+8-3
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ var (
3737

3838
// Store Implements types.KVStore and CommitKVStore.
3939
type Store struct {
40-
tree Tree
40+
tree Tree
41+
logger log.Logger
4142
}
4243

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

8990
return &Store{
90-
tree: tree,
91+
tree: tree,
92+
logger: logger,
9193
}, nil
9294
}
9395

@@ -198,7 +200,10 @@ func (st *Store) CacheWrapWithListeners(storeKey types.StoreKey, listeners []typ
198200
func (st *Store) Set(key, value []byte) {
199201
types.AssertValidKey(key)
200202
types.AssertValidValue(value)
201-
st.tree.Set(key, value)
203+
_, err := st.tree.Set(key, value)
204+
if err != nil && st.logger != nil {
205+
st.logger.Error("iavl set error", "error", err.Error())
206+
}
202207
}
203208

204209
// Implements types.KVStore.

0 commit comments

Comments
 (0)