diff --git a/CHANGELOG.md b/CHANGELOG.md index a2a8c053da..0b1a6d4ca9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,7 @@ - [#1087](https://github.com/crypto-org-chain/cronos/pull/1087) memiavl fix LastCommitID when memiavl db not loaded. - [#1088](https://github.com/crypto-org-chain/cronos/pull/1088) memiavl fix empty value in write-ahead-log replaying. - [#1102](https://github.com/crypto-org-chain/cronos/pull/1102) avoid duplicate cache events emitted from ibc and gravity hook. +- [#]() Fix memiavl snapshot switching ### Features diff --git a/memiavl/db.go b/memiavl/db.go index aedd14648c..ffeef1b1e3 100644 --- a/memiavl/db.go +++ b/memiavl/db.go @@ -341,6 +341,11 @@ func (db *DB) checkBackgroundSnapshotRewrite() error { return fmt.Errorf("background snapshot rewriting failed: %w", result.err) } + // wait for pending wal writings to finish, to make sure catching up to latest state + if err := db.WaitAsyncCommit(); err != nil { + return fmt.Errorf("wait async commit failed: %w", err) + } + // catchup the remaining wal if err := result.mtree.CatchupWAL(db.wal, 0); err != nil { return fmt.Errorf("catchup failed: %w", err)