Skip to content

Commit

Permalink
fix: deadlock in miner market handler
Browse files Browse the repository at this point in the history
  • Loading branch information
frrist committed Aug 26, 2020
1 parent 2cde485 commit 3f165cc
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 20 deletions.
6 changes: 0 additions & 6 deletions cmd/lotus-chainwatch/processor/market.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,6 @@ func (p *Processor) HandleMarketChanges(ctx context.Context, marketTips ActorTip
log.Fatalw("Failed to persist market actors", "error", err)
}

// we persist the dealID <--> minerID,sectorID here since the dealID needs to be stored above first
if err := p.storePreCommitDealInfo(p.sectorDealEvents); err != nil {
close(p.sectorDealEvents)
return err
}

if err := p.updateMarket(ctx, marketChanges); err != nil {
log.Fatalw("Failed to update market actors", "error", err)
}
Expand Down
13 changes: 2 additions & 11 deletions cmd/lotus-chainwatch/processor/miner.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,6 @@ func (p *Processor) persistMiners(ctx context.Context, miners []minerActorInfo)
preCommitEvents := make(chan *MinerSectorsEvent, 8)
sectorEvents := make(chan *MinerSectorsEvent, 8)
partitionEvents := make(chan *MinerSectorsEvent, 8)
p.sectorDealEvents = make(chan *SectorDealEvent, 8)

grp.Go(func() error {
return p.storeMinerSectorEvents(ctx, sectorEvents, preCommitEvents, partitionEvents)
Expand All @@ -280,9 +279,8 @@ func (p *Processor) persistMiners(ctx context.Context, miners []minerActorInfo)
grp.Go(func() error {
defer func() {
close(preCommitEvents)
close(p.sectorDealEvents)
}()
return p.storeMinerPreCommitInfo(ctx, miners, preCommitEvents, p.sectorDealEvents)
return p.storeMinerPreCommitInfo(ctx, miners, preCommitEvents)
})

grp.Go(func() error {
Expand All @@ -298,7 +296,7 @@ func (p *Processor) persistMiners(ctx context.Context, miners []minerActorInfo)
return grp.Wait()
}

func (p *Processor) storeMinerPreCommitInfo(ctx context.Context, miners []minerActorInfo, sectorEvents chan<- *MinerSectorsEvent, sectorDeals chan<- *SectorDealEvent) error {
func (p *Processor) storeMinerPreCommitInfo(ctx context.Context, miners []minerActorInfo, sectorEvents chan<- *MinerSectorsEvent) error {
tx, err := p.db.Begin()
if err != nil {
return err
Expand Down Expand Up @@ -334,13 +332,6 @@ func (p *Processor) storeMinerPreCommitInfo(ctx context.Context, miners []minerA

preCommitAdded := make([]uint64, len(changes.Added))
for i, added := range changes.Added {
if len(added.Info.DealIDs) > 0 {
sectorDeals <- &SectorDealEvent{
MinerID: m.common.addr,
SectorID: uint64(added.Info.SectorNumber),
DealIDs: added.Info.DealIDs,
}
}
if added.Info.ReplaceCapacity {
if _, err := stmt.Exec(
m.common.addr.String(),
Expand Down
3 changes: 0 additions & 3 deletions cmd/lotus-chainwatch/processor/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ type Processor struct {

// number of blocks processed at a time
batch int

// process communication channels
sectorDealEvents chan *SectorDealEvent
}

type ActorTips map[types.TipSetKey][]actorInfo
Expand Down

0 comments on commit 3f165cc

Please sign in to comment.