diff --git a/cmd/lotus-provider/proving.go b/cmd/lotus-provider/proving.go index 1f2f186ce..129ca342f 100644 --- a/cmd/lotus-provider/proving.go +++ b/cmd/lotus-provider/proving.go @@ -69,7 +69,6 @@ It will not send any messages to the chain. Since it can compute any deadline, o if err != nil { return err } - defer deps.fullCloser() wdPostTask, wdPoStSubmitTask, derlareRecoverTask, err := provider.WindowPostScheduler(ctx, deps.cfg.Fees, deps.cfg.Proving, deps.full, deps.verif, deps.lw, deps.as, deps.maddrs, deps.db, deps.stor, deps.si, deps.cfg.Subsystems.WindowPostMaxTasks) diff --git a/cmd/lotus-provider/run.go b/cmd/lotus-provider/run.go index 763993c58..a7f19e57d 100644 --- a/cmd/lotus-provider/run.go +++ b/cmd/lotus-provider/run.go @@ -23,7 +23,6 @@ import ( "golang.org/x/xerrors" "github.com/filecoin-project/go-address" - "github.com/filecoin-project/go-jsonrpc" "github.com/filecoin-project/go-jsonrpc/auth" "github.com/filecoin-project/go-statestore" @@ -116,6 +115,12 @@ var runCmd = &cli.Command{ tag.Insert(metrics.Commit, build.CurrentCommit), tag.Insert(metrics.NodeType, "provider"), ) + shutdownChan := make(chan struct{}) + ctx, ctxclose := context.WithCancel(ctx) + go func() { + <-shutdownChan + ctxclose() + }() // Register all metric views /* if err := view.Register( @@ -133,14 +138,12 @@ var runCmd = &cli.Command{ } } - shutdownChan := make(chan struct{}) deps, err := getDeps(ctx, cctx) if err != nil { return err } cfg, db, full, verif, lw, as, maddrs, stor, si, localStore := deps.cfg, deps.db, deps.full, deps.verif, deps.lw, deps.as, deps.maddrs, deps.stor, deps.si, deps.localStore - defer deps.fullCloser() /////////////////////////////////////////////////////////////////////// ///// Task Selection @@ -206,7 +209,6 @@ var runCmd = &cli.Command{ //node.ShutdownHandler{Component: "provider", StopFunc: stop}, <-finishCh - return nil }, } @@ -256,7 +258,6 @@ type Deps struct { cfg *config.LotusProviderConfig db *harmonydb.DB full api.FullNode - fullCloser jsonrpc.ClientCloser verif storiface.Verifier lw *sealer.LocalWorker as *ctladdr.AddressSelector @@ -319,14 +320,19 @@ func getDeps(ctx context.Context, cctx *cli.Context) (*Deps, error) { if err != nil { return nil, err } - defer func() { _ = j.Close() }() full, fullCloser, err := cliutil.GetFullNodeAPIV1LotusProvider(cctx, cfg.Apis.ChainApiInfo) if err != nil { return nil, err } - defer fullCloser() + go func() { + select { + case <-ctx.Done(): + fullCloser() + _ = j.Close() + } + }() sa, err := StorageAuth(cfg.Apis.StorageRPCSecret) if err != nil { return nil, xerrors.Errorf(`'%w' while parsing the config toml's @@ -380,7 +386,6 @@ Get it with: jq .PrivateKey ~/.lotus-miner/keystore/MF2XI2BNNJ3XILLQOJUXMYLUMU`, cfg, db, full, - fullCloser, verif, lw, as, diff --git a/lib/harmony/resources/resources.go b/lib/harmony/resources/resources.go index c53d1806c..9d6cf7f73 100644 --- a/lib/harmony/resources/resources.go +++ b/lib/harmony/resources/resources.go @@ -3,6 +3,7 @@ package resources import ( "bytes" "context" + "fmt" "os/exec" "regexp" "runtime" @@ -94,8 +95,8 @@ func Register(db *harmonydb.DB, hostnameAndPort string) (*Reg, error) { func CleanupMachines(ctx context.Context, db *harmonydb.DB) int { ct, err := db.Exec(ctx, - `DELETE FROM harmony_machines WHERE last_contact < CURRENT_TIMESTAMP - INTERVAL $1 MILLISECONDS`, - LOOKS_DEAD_TIMEOUT.Milliseconds()) // ms enables unit testing to change timeout. + `DELETE FROM harmony_machines WHERE last_contact < CURRENT_TIMESTAMP - INTERVAL $1 `, + fmt.Sprintf("%d MILLISECOND", LOOKS_DEAD_TIMEOUT.Milliseconds())) // ms enables unit testing to change timeout. if err != nil { logger.Warn("unable to delete old machines: ", err) } diff --git a/provider/lpwindow/compute_task.go b/provider/lpwindow/compute_task.go index f606c7105..c3385533c 100644 --- a/provider/lpwindow/compute_task.go +++ b/provider/lpwindow/compute_task.go @@ -74,10 +74,10 @@ type WdPostTask struct { } type wdTaskIdentity struct { - SpID uint64 - ProvingPeriodStart abi.ChainEpoch - DeadlineIndex uint64 - PartitionIndex uint64 + SpID uint64 `db:"sp_id"` + ProvingPeriodStart abi.ChainEpoch `db:"proving_period_start"` + DeadlineIndex uint64 `db:"deadline_index"` + PartitionIndex uint64 `db:"partition_index"` } func NewWdPostTask(db *harmonydb.DB,