Merge pull request #5319 from filecoin-project/fix/fsm-startup-race

storagefsm: Fix unsealedInfoMap.lk init race
This commit is contained in:
Łukasz Magiera 2021-01-11 16:43:01 +01:00 committed by GitHub
commit 7d0296c409
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

View File

@ -409,8 +409,9 @@ func (m *Sealing) restartSectors(ctx context.Context) error {
return err
}
m.unsealedInfoMap.lk.Lock()
// m.unsealedInfoMap.lk.Lock() taken early in .New to prevent races
defer m.unsealedInfoMap.lk.Unlock()
for _, sector := range trackedSectors {
if err := m.sectors.Send(uint64(sector.SectorNumber), SectorRestart{}); err != nil {
log.Errorf("restarting sector %d: %+v", sector.SectorNumber, err)

View File

@ -145,6 +145,8 @@ func New(api SealingAPI, fc FeeConfig, events Events, maddr address.Address, ds
s.sectors = statemachine.New(namespace.Wrap(ds, datastore.NewKey(SectorStorePrefix)), s, SectorInfo{})
s.unsealedInfoMap.lk.Lock() // released after initialized in .Run()
return s
}