diff --git a/lib/harmony/harmonydb/sql/20231217-sdr-pipeline.sql b/lib/harmony/harmonydb/sql/20231217-sdr-pipeline.sql index e41e865d0..c0540148f 100644 --- a/lib/harmony/harmonydb/sql/20231217-sdr-pipeline.sql +++ b/lib/harmony/harmonydb/sql/20231217-sdr-pipeline.sql @@ -67,8 +67,8 @@ create table sectors_sdr_pipeline ( -- Failure handling failed bool not null default false, failed_at timestamp, - failed_reason varchar(20), - failed_reason_msg text, + failed_reason varchar(20) not null default '', + failed_reason_msg text not null default '', -- constraints primary key (sp_id, sector_number) diff --git a/provider/lpseal/poller.go b/provider/lpseal/poller.go index 4747eb332..c3222016d 100644 --- a/provider/lpseal/poller.go +++ b/provider/lpseal/poller.go @@ -42,7 +42,7 @@ func (s *SealPoller) RunPoller(ctx context.Context) { return case <-ticker.C: if err := s.poll(ctx); err != nil { - log.Errorf("polling sdr sector pipeline: %w", err) + log.Errorw("polling failed", "error", err) } } } @@ -84,7 +84,19 @@ func (s *SealPoller) poll(ctx context.Context) error { FailedReason string `db:"failed_reason"` } - err := s.db.Select(ctx, &tasks, `SELECT * FROM sectors_sdr_pipeline WHERE after_commit_msg_success != true`) + err := s.db.Select(ctx, &tasks, `SELECT + sp_id, sector_number, + task_id_sdr, after_sdr, + task_id_tree_d, after_tree_d, + task_id_tree_c, after_tree_c, + task_id_tree_r, after_tree_r, + task_id_precommit_msg, after_precommit_msg, + task_id_precommit_msg_wait, after_precommit_msg_success, + task_id_porep, porep_proof, + task_id_commit_msg, after_commit_msg, + task_id_commit_msg_wait, after_commit_msg_success, + failed, failed_reason + FROM sectors_sdr_pipeline WHERE after_commit_msg_success != true`) if err != nil { return err } diff --git a/provider/lpwinning/winning_task.go b/provider/lpwinning/winning_task.go index 8b289a8de..b795ade4f 100644 --- a/provider/lpwinning/winning_task.go +++ b/provider/lpwinning/winning_task.go @@ -107,13 +107,13 @@ func (t *WinPostTask) Do(taskID harmonytask.TaskID, stillOwned func() bool) (don // First query to fetch from mining_tasks err = t.db.QueryRow(ctx, `SELECT sp_id, epoch, base_compute_time FROM mining_tasks WHERE task_id = $1`, taskID).Scan(&details.SpID, &details.Epoch, &details.CompTime) if err != nil { - return false, err + return false, xerrors.Errorf("query mining base info fail: %w", err) } // Second query to fetch from mining_base_block rows, err := t.db.Query(ctx, `SELECT block_cid FROM mining_base_block WHERE task_id = $1`, taskID) if err != nil { - return false, err + return false, xerrors.Errorf("query mining base blocks fail: %w", err) } defer rows.Close() @@ -126,7 +126,7 @@ func (t *WinPostTask) Do(taskID harmonytask.TaskID, stillOwned func() bool) (don } if err := rows.Err(); err != nil { - return false, err + return false, xerrors.Errorf("query mining base blocks fail (rows.Err): %w", err) } // construct base