From 5ff9c2609bda32ce18fbc2078619c33310edcb71 Mon Sep 17 00:00:00 2001 From: Dev Ojha Date: Wed, 3 Jul 2024 12:17:51 +0100 Subject: [PATCH] Backport #20817 --- store/cachemulti/store.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/store/cachemulti/store.go b/store/cachemulti/store.go index a162910fe5a5..58fc5738bf10 100644 --- a/store/cachemulti/store.go +++ b/store/cachemulti/store.go @@ -3,6 +3,7 @@ package cachemulti import ( "fmt" "io" + "sync" dbm "github.com/cometbft/cometbft-db" @@ -122,9 +123,15 @@ func (cms Store) GetStoreType() types.StoreType { // Write calls Write on each underlying store. func (cms Store) Write() { cms.db.Write() + wg := sync.WaitGroup{} + wg.Add(len(cms.stores)) for _, store := range cms.stores { - store.Write() + go func(s types.CacheWrap) { + defer wg.Done() + store.Write() + }(store) } + wg.Wait() } // Implements CacheWrapper.