Skip to content

Commit

Permalink
Merge pull request #11532 from filecoin-project/fix/lpwinning-nowin-err
Browse files Browse the repository at this point in the history
lpwinning: Don't say a task is done when persistNoWin fails
  • Loading branch information
snadrus authored Jan 3, 2024
2 parents b0bc4a9 + 15128b6 commit a959c04
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
3 changes: 3 additions & 0 deletions lib/harmony/harmonytask/task_type_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@ retryRecordCompletion:
return false, fmt.Errorf("could not log completion: %w", err)
}
result = ""
if doErr != nil {
result = "non-failing error: " + doErr.Error()
}
} else {
if doErr != nil {
result = "error: " + doErr.Error()
Expand Down
19 changes: 12 additions & 7 deletions provider/lpwinning/winning_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,18 @@ func (t *WinPostTask) Do(taskID harmonytask.TaskID, stillOwned func() bool) (don
ComputeTime: details.CompTime,
}

persistNoWin := func() error {
_, err := t.db.Exec(ctx, `UPDATE mining_base_block SET no_win = true WHERE task_id = $1`, taskID)
persistNoWin := func() (bool, error) {
n, err := t.db.Exec(ctx, `UPDATE mining_base_block SET no_win = true WHERE task_id = $1`, taskID)
if err != nil {
return xerrors.Errorf("marking base as not-won: %w", err)
return false, xerrors.Errorf("marking base as not-won: %w", err)
}
log.Debugw("persisted no-win", "rows", n)

return nil
if n == 0 {
return false, xerrors.Errorf("persist no win: no rows updated")
}

return true, nil
}

// ensure we have a beacon entry for the epoch we're mining on
Expand All @@ -182,13 +187,13 @@ func (t *WinPostTask) Do(taskID harmonytask.TaskID, stillOwned func() bool) (don
if mbi == nil {
// not eligible to mine on this base, we're done here
log.Debugw("WinPoSt not eligible to mine on this base", "tipset", types.LogCids(base.TipSet.Cids()))
return true, persistNoWin()
return persistNoWin()
}

if !mbi.EligibleForMining {
// slashed or just have no power yet, we're done here
log.Debugw("WinPoSt not eligible for mining", "tipset", types.LogCids(base.TipSet.Cids()))
return true, persistNoWin()
return persistNoWin()
}

if len(mbi.Sectors) == 0 {
Expand Down Expand Up @@ -217,7 +222,7 @@ func (t *WinPostTask) Do(taskID harmonytask.TaskID, stillOwned func() bool) (don
if eproof == nil {
// not a winner, we're done here
log.Debugw("WinPoSt not a winner", "tipset", types.LogCids(base.TipSet.Cids()))
return true, persistNoWin()
return persistNoWin()
}
}

Expand Down

0 comments on commit a959c04

Please sign in to comment.