Merge pull request #9903 from filecoin-project/fix/splitstore-compact-dlock

fix: splitstore: Don't deadlock in mpool protector
This commit is contained in:
Aayush Rajasekaran 2022-12-19 10:56:53 -05:00 committed by GitHub
commit 6388eca129
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 3 deletions

View File

@ -443,8 +443,12 @@ func New(ctx context.Context, api Provider, ds dtypes.MetadataDS, us stmgr.Upgra
return mp, nil return mp, nil
} }
func (mp *MessagePool) ForEachPendingMessage(f func(cid.Cid) error) error { func (mp *MessagePool) TryForEachPendingMessage(f func(cid.Cid) error) error {
mp.lk.Lock() // avoid deadlocks in splitstore compaction when something else needs to access the blockstore
// while holding the mpool lock
if !mp.lk.TryLock() {
return xerrors.Errorf("mpool TryForEachPendingMessage: could not acquire lock")
}
defer mp.lk.Unlock() defer mp.lk.Unlock()
for _, mset := range mp.pending { for _, mset := range mp.pending {

View File

@ -69,7 +69,7 @@ func MessagePool(lc fx.Lifecycle, mctx helpers.MetricsCtx, us stmgr.UpgradeSched
return mp.Close() return mp.Close()
}, },
}) })
protector.AddProtector(mp.ForEachPendingMessage) protector.AddProtector(mp.TryForEachPendingMessage)
return mp, nil return mp, nil
} }