From 8257357e7bfed0f8da29fdf47ff7c799555cfb8c Mon Sep 17 00:00:00 2001 From: LexLuthr <88259624+LexLuthr@users.noreply.github.com> Date: Thu, 10 Oct 2024 00:16:30 +0400 Subject: [PATCH] restart button for sectors (#266) --- web/api/webrpc/sector.go | 27 ++++++++++++++++++++++++ web/static/pages/sector/sector-info.mjs | 28 ++++++++++++++++++------- 2 files changed, 47 insertions(+), 8 deletions(-) diff --git a/web/api/webrpc/sector.go b/web/api/webrpc/sector.go index ea2e70fba..595f99706 100644 --- a/web/api/webrpc/sector.go +++ b/web/api/webrpc/sector.go @@ -11,6 +11,7 @@ import ( "golang.org/x/xerrors" "github.com/filecoin-project/go-address" + "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/curio/lib/paths" "github.com/filecoin-project/curio/lib/storiface" @@ -30,6 +31,7 @@ type SectorInfo struct { TaskHistory []TaskHistory Resumable bool + Restart bool } type SectorInfoTaskSummary struct { @@ -118,6 +120,7 @@ func (a *WebRPC) SectorInfo(ctx context.Context, sp string, intid int64) (*Secto task_id_tree_d, after_tree_d, task_id_tree_c, after_tree_c, task_id_tree_r, after_tree_r, + task_id_synth, after_synth, task_id_precommit_msg, after_precommit_msg, after_precommit_msg_success, seed_epoch, task_id_porep, porep_proof, after_porep, @@ -407,6 +410,7 @@ func (a *WebRPC) SectorInfo(ctx context.Context, sp string, intid int64) (*Secto TaskHistory: th, Resumable: hasAnyStuckTask, + Restart: hasAnyStuckTask && !sle.AfterSynthetic, // Should be stuck and not be past SyntheticProofs }, nil } @@ -438,3 +442,26 @@ func (a *WebRPC) SectorRemove(ctx context.Context, spid, id int64) error { return nil } + +func (a *WebRPC) SectorRestart(ctx context.Context, spid, id int64) error { + _, err := a.deps.DB.Exec(ctx, `UPDATE sectors_sdr_pipeline SET after_sdr = false, after_tree_d = false, after_tree_c = false, + after_tree_r = false WHERE sp_id = $1 AND sector_number = $2`, spid, id) + if err != nil { + return xerrors.Errorf("failed to reset sector state: %w", err) + } + + err = a.deps.Stor.Remove(ctx, abi.SectorID{Miner: abi.ActorID(spid), Number: abi.SectorNumber(id)}, storiface.FTCache, true, nil) + if err != nil { + return xerrors.Errorf("failed to remove cache file: %w", err) + } + err = a.deps.Stor.Remove(ctx, abi.SectorID{Miner: abi.ActorID(spid), Number: abi.SectorNumber(id)}, storiface.FTSealed, true, nil) + if err != nil { + return xerrors.Errorf("failed to remove sealed file: %w", err) + } + + _, err = a.deps.DB.Exec(ctx, `SELECT unset_task_id($1, $2)`, spid, id) + if err != nil { + return xerrors.Errorf("failed to resume sector: %w", err) + } + return nil +} diff --git a/web/static/pages/sector/sector-info.mjs b/web/static/pages/sector/sector-info.mjs index 5332ceac1..d53c41368 100644 --- a/web/static/pages/sector/sector-info.mjs +++ b/web/static/pages/sector/sector-info.mjs @@ -20,6 +20,10 @@ customElements.define('sector-info',class SectorInfo extends LitElement { await RPCCall('SectorResume', [this.data.SpID, this.data.SectorNumber]); window.location.reload(); } + async restartSector() { + await RPCCall('SectorRestart', [this.data.SpID, this.data.SectorNumber]); + window.location.reload(); + } render() { if (!this.data) { @@ -29,14 +33,22 @@ customElements.define('sector-info',class SectorInfo extends LitElement { return html` - -