lpwinning: Don't say a task is done when persistNoWin fails

This commit is contained in:
Łukasz Magiera 2023-12-15 14:37:22 +01:00
parent fac1d11ccb
commit f885ffb44d
2 changed files with 15 additions and 7 deletions

View File

@ -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()

View File

@ -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)
if n == 0 {
return false, xerrors.Errorf("persist no win: no rows updated")
}
return nil
return false, nil
}
// ensure we have a beacon entry for the epoch we're mining on
@ -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 {
@ -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()
}
}