diff --git a/store/iavl/store.go b/store/iavl/store.go index d27473651973..7734066269c8 100644 --- a/store/iavl/store.go +++ b/store/iavl/store.go @@ -363,7 +363,9 @@ func (st *Store) Query(req *types.RequestQuery) (res *types.ResponseQuery, err e for ; iterator.Valid(); iterator.Next() { pairs.Pairs = append(pairs.Pairs, kv.Pair{Key: iterator.Key(), Value: iterator.Value()}) } - iterator.Close() + if err := iterator.Close(); err != nil { + panic(fmt.Errorf("failed to close iterator: %w", err)) + } bz, err := pairs.Marshal() if err != nil { diff --git a/store/rootmulti/store.go b/store/rootmulti/store.go index 2734fe5b83e3..7b2c05ff7761 100644 --- a/store/rootmulti/store.go +++ b/store/rootmulti/store.go @@ -314,7 +314,9 @@ func deleteKVStore(kv types.KVStore) error { keys = append(keys, itr.Key()) itr.Next() } - itr.Close() + if err := itr.Close(); err != nil { + return err + } for _, k := range keys { kv.Delete(k) @@ -330,7 +332,9 @@ func moveKVStoreData(oldDB, newDB types.KVStore) error { newDB.Set(itr.Key(), itr.Value()) itr.Next() } - itr.Close() + if err := itr.Close(); err != nil { + return err + } // then delete the old store return deleteKVStore(oldDB) @@ -1106,7 +1110,9 @@ func (rs *Store) GetCommitInfo(ver int64) (*types.CommitInfo, error) { func (rs *Store) flushMetadata(db dbm.DB, version int64, cInfo *types.CommitInfo) { rs.logger.Debug("flushing metadata", "height", version) batch := db.NewBatch() - defer batch.Close() + defer func() { + _ = batch.Close() + }() if cInfo != nil { flushCommitInfo(batch, version, cInfo) diff --git a/store/tracekv/store.go b/store/tracekv/store.go index 8e3a14e1f97c..ba6df431da16 100644 --- a/store/tracekv/store.go +++ b/store/tracekv/store.go @@ -197,6 +197,6 @@ func writeOperation(w io.Writer, op operation, tc types.TraceContext, key, value _, err = io.WriteString(w, "\n") if err != nil { - panic(err) + panic(errors.Wrap(err, "failed to write newline")) } }