From f885ffb44d25b925ec94daf79d2a2ebcc286071d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Fri, 15 Dec 2023 14:37:22 +0100 Subject: [PATCH 1/2] lpwinning: Don't say a task is done when persistNoWin fails --- lib/harmony/harmonytask/task_type_handler.go | 3 +++ provider/lpwinning/winning_task.go | 19 ++++++++++++------- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/lib/harmony/harmonytask/task_type_handler.go b/lib/harmony/harmonytask/task_type_handler.go index ccfcc1f6f..a6e8933d2 100644 --- a/lib/harmony/harmonytask/task_type_handler.go +++ b/lib/harmony/harmonytask/task_type_handler.go @@ -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() diff --git a/provider/lpwinning/winning_task.go b/provider/lpwinning/winning_task.go index 907b594fd..6e5e1cc5a 100644 --- a/provider/lpwinning/winning_task.go +++ b/provider/lpwinning/winning_task.go @@ -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() } } From 15128b69a7a93a0a294d05b91b53164d7a90e060 Mon Sep 17 00:00:00 2001 From: "Andrew Jackson (Ajax)" Date: Wed, 3 Jan 2024 10:11:10 -0600 Subject: [PATCH 2/2] Update winning_task.go last return should be true --- provider/lpwinning/winning_task.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/provider/lpwinning/winning_task.go b/provider/lpwinning/winning_task.go index 6e5e1cc5a..bf4f2fe71 100644 --- a/provider/lpwinning/winning_task.go +++ b/provider/lpwinning/winning_task.go @@ -167,7 +167,7 @@ func (t *WinPostTask) Do(taskID harmonytask.TaskID, stillOwned func() bool) (don return false, xerrors.Errorf("persist no win: no rows updated") } - return false, nil + return true, nil } // ensure we have a beacon entry for the epoch we're mining on