Skip to content

Commit

Permalink
Merge pull request #5319 from filecoin-project/fix/fsm-startup-race
Browse files Browse the repository at this point in the history
storagefsm: Fix unsealedInfoMap.lk init race
  • Loading branch information
magik6k authored Jan 11, 2021
2 parents 3ce2964 + 299e724 commit 7d0296c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion extern/storage-sealing/fsm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions extern/storage-sealing/sealing.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 7d0296c

Please sign in to comment.