Merge pull request #3374 from IPFSMain-Official/fix-packing-sector
ignore resend SectorStartPacking event. and fix StartPacking's unsealedInfoMap lock
This commit is contained in:
commit
a7ef61279c
12
extern/storage-sealing/sealing.go
vendored
12
extern/storage-sealing/sealing.go
vendored
@ -224,15 +224,23 @@ func (m *Sealing) Remove(ctx context.Context, sid abi.SectorNumber) error {
|
|||||||
|
|
||||||
// Caller should NOT hold m.unsealedInfoMap.lk
|
// Caller should NOT hold m.unsealedInfoMap.lk
|
||||||
func (m *Sealing) StartPacking(sectorID abi.SectorNumber) error {
|
func (m *Sealing) StartPacking(sectorID abi.SectorNumber) error {
|
||||||
|
// locking here ensures that when the SectorStartPacking event is sent, the sector won't be picked up anywhere else
|
||||||
|
m.unsealedInfoMap.lk.Lock()
|
||||||
|
defer m.unsealedInfoMap.lk.Unlock()
|
||||||
|
|
||||||
|
// cannot send SectorStartPacking to sectors that have already been packed, otherwise it will cause the state machine to exit
|
||||||
|
if _, ok := m.unsealedInfoMap.infos[sectorID]; !ok {
|
||||||
|
log.Warnf("call start packing, but sector %v not in unsealedInfoMap.infos, maybe have called", sectorID)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
log.Infof("Starting packing sector %d", sectorID)
|
log.Infof("Starting packing sector %d", sectorID)
|
||||||
err := m.sectors.Send(uint64(sectorID), SectorStartPacking{})
|
err := m.sectors.Send(uint64(sectorID), SectorStartPacking{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
log.Infof("send Starting packing event success sector %d", sectorID)
|
||||||
|
|
||||||
m.unsealedInfoMap.lk.Lock()
|
|
||||||
delete(m.unsealedInfoMap.infos, sectorID)
|
delete(m.unsealedInfoMap.infos, sectorID)
|
||||||
m.unsealedInfoMap.lk.Unlock()
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user