Skip to content

Commit

Permalink
fix new sector allocation in snap
Browse files Browse the repository at this point in the history
  • Loading branch information
magik6k committed Aug 12, 2024
1 parent daf70ed commit 9d7010a
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions market/deal_ingest_snap.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,13 +300,15 @@ func (p *PieceIngesterSnap) AllocatePieceToSector(ctx context.Context, maddr add
// minExpiration = piece.DealSchedule.EndEpoch
// ideal expiration = minExpiration + 2 days
err = tx.Select(&candidates, `
SELECT sector_num, expiration_epoch
FROM sectors_meta
WHERE is_cc = true AND sp_id = $4
AND expiration_epoch IS NOT NULL
AND expiration_epoch > $1
AND ($2 = 0 OR expiration_epoch < $2)
ORDER BY ABS(expiration_epoch - ($1 + $3))
SELECT sm.sector_num, sm.expiration_epoch
FROM sectors_meta sm
LEFT JOIN curio.sectors_snap_pipeline ssp on sm.sp_id = ssp.sp_id and sm.sector_num = ssp.sector_number
WHERE sm.is_cc = true AND ssp.start_time IS NULL
AND sm.sp_id = $4
AND sm.expiration_epoch IS NOT NULL
AND sm.expiration_epoch > $1
AND ($2 = 0 OR sm.expiration_epoch < $2)
ORDER BY ABS(sm.expiration_epoch - ($1 + $3))
LIMIT 10
`, int64(piece.DealSchedule.EndEpoch), maxExpiration, IdealEndEpochBuffer, p.mid)
if err != nil {
Expand Down

0 comments on commit 9d7010a

Please sign in to comment.