From 60c4f5c7bc58f88906f5d68780ec0a8d1e9cec7f Mon Sep 17 00:00:00 2001 From: Alexander Bezobchuk Date: Wed, 6 Nov 2019 06:52:22 -0700 Subject: [PATCH] Merge PR #5279: Fix IAVL Iterator Race Condition --- CHANGELOG.md | 1 + store/iavl/store.go | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bd952370cd..30cc4e23f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -182,6 +182,7 @@ to detail this new feature and how state transitions occur. ### Bug Fixes +* (iavl) [\#5276](https://github.com/cosmos/cosmos-sdk/issues/5276) Fix potential race condition in `iavlIterator#Close`. * (cli) [\#4763](https://github.com/cosmos/cosmos-sdk/issues/4763) Fix flag `--min-self-delegation` for staking `EditValidator` * (keys) Fix ledger custom coin type support bug * (x/gov) [\#5107](https://github.com/cosmos/cosmos-sdk/pull/5107) Sum validator operator's all voting power when tally votes diff --git a/store/iavl/store.go b/store/iavl/store.go index 917d4e4343..b7b94307bb 100644 --- a/store/iavl/store.go +++ b/store/iavl/store.go @@ -421,9 +421,13 @@ func (iter *iavlIterator) Value() []byte { return val } -// Implements types.Iterator. +// Close closes the IAVL iterator by closing the quit channel and waiting for +// the iterCh to finish/close. func (iter *iavlIterator) Close() { close(iter.quitCh) + // wait iterCh to close + for range iter.iterCh { + } } //----------------------------------------