From f4a3eaf32ecff80bfa18b451d8a18eb10bcc4b44 Mon Sep 17 00:00:00 2001 From: "Andrew Jackson (Ajax)" Date: Tue, 9 Jul 2024 23:53:53 -0500 Subject: [PATCH 01/10] harmonycron --- cmd/curio/tasks/tasks.go | 14 ++- deps/deps.go | 2 + harmony/harmonydb/sql/20240709-cron.sql | 15 +++ harmony/harmonytask/harmonycron/doc.go | 12 +++ .../harmonytask/harmonycron/harmonycron.go | 94 +++++++++++++++++++ harmony/harmonytask/harmonytask.go | 7 +- 6 files changed, 138 insertions(+), 6 deletions(-) create mode 100644 harmony/harmonydb/sql/20240709-cron.sql create mode 100644 harmony/harmonytask/harmonycron/doc.go create mode 100644 harmony/harmonytask/harmonycron/harmonycron.go diff --git a/cmd/curio/tasks/tasks.go b/cmd/curio/tasks/tasks.go index 94cdcfc68..2513ead69 100644 --- a/cmd/curio/tasks/tasks.go +++ b/cmd/curio/tasks/tasks.go @@ -3,6 +3,7 @@ package tasks import ( "context" + "fmt" "sort" "strings" "sync" @@ -21,6 +22,8 @@ import ( "github.com/filecoin-project/curio/deps/config" "github.com/filecoin-project/curio/harmony/harmonydb" "github.com/filecoin-project/curio/harmony/harmonytask" + "github.com/filecoin-project/curio/harmony/harmonytask/harmonycron" + "github.com/filecoin-project/curio/harmony/resources" "github.com/filecoin-project/curio/lib/chainsched" "github.com/filecoin-project/curio/lib/curiochain" "github.com/filecoin-project/curio/lib/fastparamfetch" @@ -187,11 +190,20 @@ func StartTasks(ctx context.Context, dependencies *deps.Deps) (*harmonytask.Task "miner_addresses", minerAddresses, "tasks", lo.Map(activeTasks, func(t harmonytask.TaskInterface, _ int) string { return t.TypeDetails().Name })) + reg, err := resources.Register(db, dependencies.ListenAddr) + if err != nil { + return nil, fmt.Errorf("cannot get resources: %w", err) + } + + cron := harmonycron.New(db, reg.MachineID) + activeTasks = append(activeTasks, cron) + dependencies.At = cron.At + // harmony treats the first task as highest priority, so reverse the order // (we could have just appended to this list in the reverse order, but defining // tasks in pipeline order is more intuitive) - ht, err := harmonytask.New(db, activeTasks, dependencies.ListenAddr) + ht, err := harmonytask.New(db, activeTasks, dependencies.ListenAddr, reg) if err != nil { return nil, err } diff --git a/deps/deps.go b/deps/deps.go index 3f30ce79a..86fc7d4b0 100644 --- a/deps/deps.go +++ b/deps/deps.go @@ -15,6 +15,7 @@ import ( "os" "path/filepath" "strings" + "time" "github.com/BurntSushi/toml" "github.com/gbrlsnchs/jwt/v3" @@ -178,6 +179,7 @@ type Deps struct { LocalPaths *paths.BasicLocalStorage ListenAddr string Name string + At func(t time.Time, taskType, sqlTable string, sqlRowID int) } const ( diff --git a/harmony/harmonydb/sql/20240709-cron.sql b/harmony/harmonydb/sql/20240709-cron.sql new file mode 100644 index 000000000..d0bf2f5e1 --- /dev/null +++ b/harmony/harmonydb/sql/20240709-cron.sql @@ -0,0 +1,15 @@ +CREATE TABLE harmony_cron ( + id SERIAL PRIMARY KEY NOT NULL, + task_id INTEGER NOT NULL REFERENCES harmony_task (id) ON DELETE CASCADE, + task_name VARCHAR(16) NOT NULL, + sql_table TEXT NOT NULL, + sql_row_id INTEGER NOT NULL, +); + +CREATE OR REPLACE FUNCTION update_ext_taskid(table_name text, tid integer, id_value integer) +RETURNS void AS $$ +BEGIN + EXECUTE format('UPDATE %I SET task_id = $1 WHERE id=$2', table_name) + USING tid, id_value; +END; +$$ LANGUAGE plpgsql; \ No newline at end of file diff --git a/harmony/harmonytask/harmonycron/doc.go b/harmony/harmonytask/harmonycron/doc.go new file mode 100644 index 000000000..60ffc5568 --- /dev/null +++ b/harmony/harmonytask/harmonycron/doc.go @@ -0,0 +1,12 @@ +/* + Workflow: + HarmonyCron is a regular harmonytask.TaskInterface + It supports: At(when time.Time, taskType string, sqlTable, sqlRowID, sqlTaskIDColumnName) + which will add a task to the task engine at the specified time and associate it with the specified row. + + Operation: + The cron-task will be picked up by Cron runners, which try to avoid being sealers or provers. + The cron-task is held until the specified time in seconds, then it completes after starting + the task in the task engine. +*/ +package harmonycron diff --git a/harmony/harmonytask/harmonycron/harmonycron.go b/harmony/harmonytask/harmonycron/harmonycron.go new file mode 100644 index 000000000..7c6495dcb --- /dev/null +++ b/harmony/harmonytask/harmonycron/harmonycron.go @@ -0,0 +1,94 @@ +package harmonycron + +import ( + "context" + "regexp" + "time" + + "github.com/filecoin-project/curio/harmony/harmonydb" + "github.com/filecoin-project/curio/harmony/harmonytask" + "github.com/filecoin-project/curio/harmony/resources" + "golang.org/x/xerrors" +) + +type Cron struct { + DB *harmonydb.DB + AddTaskFunc harmonytask.AddTaskFunc + me int +} + +func New(db *harmonydb.DB, myMachineID int) *Cron { + return &Cron{DB: db, me: myMachineID} +} + +// At schedules a task to be run at a specific time. +// The task will be added to the harmony_task table with the given taskType. +// The task will be associated with the given sqlTable at the specified sqlRowID. +// Note: sqlTable must use the standard columns "id" and "task_id" +func (c *Cron) At(t time.Time, taskType, sqlTable string, sqlRowID int) { + c.AddTaskFunc(func(tid harmonytask.TaskID, tx *harmonydb.Tx) (shouldCommit bool, seriousError error) { + _, err := tx.Exec(`INSERT INTO harmony_cron (task_id, unixtime, task_type, sql_table, sql_row_id) VALUES ($1, $2, $3, $4, $5)`, + tid, t.Unix(), taskType, sqlTable, sqlRowID) + if harmonydb.IsErrUniqueContraint(err) { + return false, nil + } + return true, err + }) +} + +var validSQL = regexp.MustCompile(`^[a-zA-Z0-9_]+$`) + +func (c *Cron) Do(taskID harmonytask.TaskID, stillOwned func() bool) (done bool, err error) { + var unixtime int64 + var taskType, sqlTable, sqlRowID string + err = c.DB.QueryRow(context.Background(), `SELECT unixtime, task_type, sql_table, sql_row_id + FROM harmony_cron WHERE task_id = $1`, taskID). + Scan(&unixtime, &taskType, &sqlTable, &sqlRowID) + if err != nil { + return false, xerrors.Errorf("getting cron task: %w", err) + } + if !validSQL.MatchString(sqlTable) { + return false, xerrors.Errorf("invalid sql table or column name") + } + time.Sleep(time.Until(time.Unix(unixtime, 0))) + if !stillOwned() { + return false, nil + } + _, err = c.DB.BeginTransaction(context.Background(), func(tx *harmonydb.Tx) (commit bool, err error) { + err = tx.QueryRow(`INSERT INTO harmony_task (name, added_by, posted_time) VALUES ($1) RETURNING id`, taskType, c.me, time.Now()).Scan(&taskID) + if err != nil { + return false, xerrors.Errorf("adding new task: %w", err) + } + _, err = tx.Exec(`SELECT update_ext_taskid($1, $2, $3)`, sqlTable, taskID, sqlRowID) + if err != nil { + return false, xerrors.Errorf("deleting cron task: %w", err) + } + return true, nil + }) + if err != nil { + return false, xerrors.Errorf("doing cron task: %w", err) + } + return true, nil +} + +func (c *Cron) CanAccept(ids []harmonytask.TaskID, te *harmonytask.TaskEngine) (*harmonytask.TaskID, error) { + // TODO: avoid accepting if we are one of the busier nodes. + return &ids[0], nil +} + +func (c *Cron) TypeDetails() harmonytask.TaskTypeDetails { + return harmonytask.TaskTypeDetails{ + Name: "Cron", + Cost: resources.Resources{ + Cpu: 0, + Ram: 5 << 20, + Gpu: 0, + }, + } +} + +func (c *Cron) Adder(f harmonytask.AddTaskFunc) { + c.AddTaskFunc = f +} + +var _ harmonytask.TaskInterface = &Cron{} diff --git a/harmony/harmonytask/harmonytask.go b/harmony/harmonytask/harmonytask.go index 1027618e7..bc10f49b3 100644 --- a/harmony/harmonytask/harmonytask.go +++ b/harmony/harmonytask/harmonytask.go @@ -133,12 +133,9 @@ type TaskID int func New( db *harmonydb.DB, impls []TaskInterface, - hostnameAndPort string) (*TaskEngine, error) { + hostnameAndPort string, + reg *resources.Reg) (*TaskEngine, error) { - reg, err := resources.Register(db, hostnameAndPort) - if err != nil { - return nil, fmt.Errorf("cannot get resources: %w", err) - } ctx, grace := context.WithCancel(context.Background()) e := &TaskEngine{ ctx: ctx, From cf65d0beb80183966dc5e07d615971451f372ac0 Mon Sep 17 00:00:00 2001 From: "Andrew Jackson (Ajax)" Date: Tue, 9 Jul 2024 23:57:03 -0500 Subject: [PATCH 02/10] doc --- harmony/harmonytask/harmonycron/doc.go | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/harmony/harmonytask/harmonycron/doc.go b/harmony/harmonytask/harmonycron/doc.go index 60ffc5568..97622c5f2 100644 --- a/harmony/harmonytask/harmonycron/doc.go +++ b/harmony/harmonytask/harmonycron/doc.go @@ -1,12 +1,15 @@ /* - Workflow: - HarmonyCron is a regular harmonytask.TaskInterface - It supports: At(when time.Time, taskType string, sqlTable, sqlRowID, sqlTaskIDColumnName) - which will add a task to the task engine at the specified time and associate it with the specified row. - - Operation: - The cron-task will be picked up by Cron runners, which try to avoid being sealers or provers. - The cron-task is held until the specified time in seconds, then it completes after starting - the task in the task engine. +HarmonyCron is a regular harmonytask.TaskInterface task +It supports: At(when time.Time, taskType string, sqlTable, sqlRowID, sqlTaskIDColumnName) + + which will add a task to the task engine at the specified time and associate it with the specified row. + +Operation: + + The cron-task will be picked up by Cron runners, which try to avoid being sealers or provers. + The cron-task is held until the specified time in seconds, then it completes after starting + the task in the task engine. + +Requirement: The sqlTable must have columns "id" and "task_id" to be able to update the task_id. */ package harmonycron From 5fe68a0240e563101de4cdba5865f6eef89c3c70 Mon Sep 17 00:00:00 2001 From: "Andrew Jackson (Ajax)" Date: Thu, 11 Jul 2024 15:32:00 -0500 Subject: [PATCH 03/10] cron should be first --- cmd/curio/tasks/tasks.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/curio/tasks/tasks.go b/cmd/curio/tasks/tasks.go index 2513ead69..79f17ed41 100644 --- a/cmd/curio/tasks/tasks.go +++ b/cmd/curio/tasks/tasks.go @@ -196,8 +196,8 @@ func StartTasks(ctx context.Context, dependencies *deps.Deps) (*harmonytask.Task } cron := harmonycron.New(db, reg.MachineID) - activeTasks = append(activeTasks, cron) dependencies.At = cron.At + activeTasks = append([]harmonytask.TaskInterface{cron}, activeTasks...) // harmony treats the first task as highest priority, so reverse the order // (we could have just appended to this list in the reverse order, but defining From 444bf10565a55ef3ad1116679b2fc638dcf011be Mon Sep 17 00:00:00 2001 From: "Andrew Jackson (Ajax)" Date: Sun, 14 Jul 2024 13:44:53 -0500 Subject: [PATCH 04/10] sql oops --- harmony/harmonydb/sql/20240709-cron.sql | 2 +- harmony/harmonytask/harmonycron/harmonycron.go | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/harmony/harmonydb/sql/20240709-cron.sql b/harmony/harmonydb/sql/20240709-cron.sql index d0bf2f5e1..7c3f120ef 100644 --- a/harmony/harmonydb/sql/20240709-cron.sql +++ b/harmony/harmonydb/sql/20240709-cron.sql @@ -3,7 +3,7 @@ CREATE TABLE harmony_cron ( task_id INTEGER NOT NULL REFERENCES harmony_task (id) ON DELETE CASCADE, task_name VARCHAR(16) NOT NULL, sql_table TEXT NOT NULL, - sql_row_id INTEGER NOT NULL, + sql_row_id INTEGER NOT NULL ); CREATE OR REPLACE FUNCTION update_ext_taskid(table_name text, tid integer, id_value integer) diff --git a/harmony/harmonytask/harmonycron/harmonycron.go b/harmony/harmonytask/harmonycron/harmonycron.go index 7c6495dcb..86adc0711 100644 --- a/harmony/harmonytask/harmonycron/harmonycron.go +++ b/harmony/harmonytask/harmonycron/harmonycron.go @@ -5,10 +5,11 @@ import ( "regexp" "time" + "golang.org/x/xerrors" + "github.com/filecoin-project/curio/harmony/harmonydb" "github.com/filecoin-project/curio/harmony/harmonytask" "github.com/filecoin-project/curio/harmony/resources" - "golang.org/x/xerrors" ) type Cron struct { From 7af2e969bfbf45357e7d876ce821d094c78a122a Mon Sep 17 00:00:00 2001 From: "Andrew Jackson (Ajax)" Date: Mon, 22 Jul 2024 23:14:04 -0500 Subject: [PATCH 05/10] rearrange & doc --- harmony/{harmonytask => taskhelp}/harmonycron/doc.go | 5 +++-- harmony/{harmonytask => taskhelp}/harmonycron/harmonycron.go | 0 2 files changed, 3 insertions(+), 2 deletions(-) rename harmony/{harmonytask => taskhelp}/harmonycron/doc.go (66%) rename harmony/{harmonytask => taskhelp}/harmonycron/harmonycron.go (100%) diff --git a/harmony/harmonytask/harmonycron/doc.go b/harmony/taskhelp/harmonycron/doc.go similarity index 66% rename from harmony/harmonytask/harmonycron/doc.go rename to harmony/taskhelp/harmonycron/doc.go index 97622c5f2..e90698409 100644 --- a/harmony/harmonytask/harmonycron/doc.go +++ b/harmony/taskhelp/harmonycron/doc.go @@ -1,6 +1,6 @@ /* -HarmonyCron is a regular harmonytask.TaskInterface task -It supports: At(when time.Time, taskType string, sqlTable, sqlRowID, sqlTaskIDColumnName) +HarmonyCron starts tasks at a specified time & associates them with a row in a SQL table. +It supports: At(when time.Time, taskType, sqlTable string, sqlRowID int) which will add a task to the task engine at the specified time and associate it with the specified row. @@ -11,5 +11,6 @@ Operation: the task in the task engine. Requirement: The sqlTable must have columns "id" and "task_id" to be able to update the task_id. +HarmonyCron is a regular harmonytask.TaskInterface task ran by all nodes. */ package harmonycron diff --git a/harmony/harmonytask/harmonycron/harmonycron.go b/harmony/taskhelp/harmonycron/harmonycron.go similarity index 100% rename from harmony/harmonytask/harmonycron/harmonycron.go rename to harmony/taskhelp/harmonycron/harmonycron.go From 53b845db5a70588acecf30b247ee156f6af53702 Mon Sep 17 00:00:00 2001 From: "Andrew Jackson (Ajax)" Date: Mon, 22 Jul 2024 23:18:27 -0500 Subject: [PATCH 06/10] build oops --- cmd/curio/tasks/tasks.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/curio/tasks/tasks.go b/cmd/curio/tasks/tasks.go index 79f17ed41..bc933037e 100644 --- a/cmd/curio/tasks/tasks.go +++ b/cmd/curio/tasks/tasks.go @@ -22,8 +22,8 @@ import ( "github.com/filecoin-project/curio/deps/config" "github.com/filecoin-project/curio/harmony/harmonydb" "github.com/filecoin-project/curio/harmony/harmonytask" - "github.com/filecoin-project/curio/harmony/harmonytask/harmonycron" "github.com/filecoin-project/curio/harmony/resources" + "github.com/filecoin-project/curio/harmony/taskHelp/harmonycron" "github.com/filecoin-project/curio/lib/chainsched" "github.com/filecoin-project/curio/lib/curiochain" "github.com/filecoin-project/curio/lib/fastparamfetch" From e2b901d7b040d154086c9bfda0fe7d7548e56cc2 Mon Sep 17 00:00:00 2001 From: "Andrew Jackson (Ajax)" Date: Tue, 23 Jul 2024 15:25:18 -0500 Subject: [PATCH 07/10] fix caps --- cmd/curio/tasks/tasks.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/curio/tasks/tasks.go b/cmd/curio/tasks/tasks.go index bc933037e..eb58eb69c 100644 --- a/cmd/curio/tasks/tasks.go +++ b/cmd/curio/tasks/tasks.go @@ -23,7 +23,7 @@ import ( "github.com/filecoin-project/curio/harmony/harmonydb" "github.com/filecoin-project/curio/harmony/harmonytask" "github.com/filecoin-project/curio/harmony/resources" - "github.com/filecoin-project/curio/harmony/taskHelp/harmonycron" + "github.com/filecoin-project/curio/harmony/taskhelp/harmonycron" "github.com/filecoin-project/curio/lib/chainsched" "github.com/filecoin-project/curio/lib/curiochain" "github.com/filecoin-project/curio/lib/fastparamfetch" From 6f90dbcab401f67cbd0dbdf46afbec98edd2ad36 Mon Sep 17 00:00:00 2001 From: "Andrew Jackson (Ajax)" Date: Tue, 23 Jul 2024 17:54:12 -0500 Subject: [PATCH 08/10] tests yay --- itests/harmonycron_test.go | 83 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 itests/harmonycron_test.go diff --git a/itests/harmonycron_test.go b/itests/harmonycron_test.go new file mode 100644 index 000000000..eb60f1dbd --- /dev/null +++ b/itests/harmonycron_test.go @@ -0,0 +1,83 @@ +package itests + +import ( + "context" + "testing" + "time" + + "github.com/filecoin-project/curio/deps/config" + "github.com/filecoin-project/curio/harmony/harmonydb" + "github.com/filecoin-project/curio/harmony/harmonytask" + "github.com/filecoin-project/curio/harmony/resources" + "github.com/filecoin-project/curio/harmony/taskhelp/harmonycron" + "github.com/snadrus/must" + "github.com/stretchr/testify/require" +) + +// TestHarmonyCron is Documentesting +func TestHarmonyCron(t *testing.T) { + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + + dbConfig := config.HarmonyDB{ + Hosts: []string{envElse("CURIO_HARMONYDB_HOSTS", "127.0.0.1")}, + Database: "yugabyte", + Username: "yugabyte", + Password: "yugabyte", + Port: "5433", + } + db := must.One(harmonydb.NewFromConfigWithITestID(t, dbConfig, harmonydb.ITestNewID())) + hp := "localhost:1234" + reg := must.One(resources.Register(db, hp)) + cron := harmonycron.New(db, reg.MachineID) + + // FutureTask is the task we want to run in the future. + FutureTask := &FutureTask{db: db, Ch: make(chan string)} + _ = must.One(harmonytask.New(db, []harmonytask.TaskInterface{cron, FutureTask}, hp, reg)) + // harmonycron lives in Deps, but we are shortcutting things here. + // Above here is the setup `curio run`, below is the test ///////////////// + + var taskValueForTesting string + + // A tale of PreviousTask and FutureTask /story + // (p *PreviousTask) Do() { + { + taskValue := "abcde" // our future task needs this, so save it to that task's table + var rowID int64 + // Pretend harmony_test is FutureTask's table + db.QueryRow(ctx, "INSERT INTO harmony_test (options, result) VALUES ('FutureTaskTbl', $1) RETURNING id", taskValue).Scan(&rowID) + + // PreviousTask then schedules it sometime in the future. It will run AFTER this time. + cron.At(time.Now().Add(3*time.Second), "FutureTask", "harmony_test", int(rowID)) + // Now, PreviousTask's machine could go down, & someone's FutureTask runner will pick it up. + + taskValueForTesting = taskValue // hack for the test. Nothing to see here. + } + require.Equal(t, taskValueForTesting, <-FutureTask.Ch) +} + +type FutureTask struct { + db *harmonydb.DB + Ch chan string +} + +func (*FutureTask) Adder(harmonytask.AddTaskFunc) {} +func (*FutureTask) CanAccept(tids []harmonytask.TaskID, te *harmonytask.TaskEngine) (*harmonytask.TaskID, error) { + id := tids[0] + return &id, nil +} +func (w *FutureTask) Do(tID harmonytask.TaskID, stillMe func() bool) (bool, error) { + var taskValue string + err := w.db.QueryRow(context.Background(), "SELECT options FROM harmony_test WHERE task_id=$1", tID).Scan(&taskValue) + if err != nil { + return false, err + } + w.Ch <- taskValue + return false, nil +} +func (*FutureTask) TypeDetails() harmonytask.TaskTypeDetails { + return harmonytask.TaskTypeDetails{ + Name: "FutureTask", + Cost: resources.Resources{}, // zeroes ok + } +} From 92864661c25319bc5093ba9fbdf40c4270bb8cfb Mon Sep 17 00:00:00 2001 From: "Andrew Jackson (Ajax)" Date: Fri, 26 Jul 2024 17:19:55 -0500 Subject: [PATCH 09/10] lint --- go.mod | 2 +- go.sum | 5 ++--- itests/harmonycron_test.go | 9 +++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/go.mod b/go.mod index 68be56908..d2643caa4 100644 --- a/go.mod +++ b/go.mod @@ -22,7 +22,7 @@ require ( github.com/filecoin-project/go-fil-commcid v0.1.0 github.com/filecoin-project/go-jsonrpc v0.5.0 github.com/filecoin-project/go-padreader v0.0.1 - github.com/filecoin-project/go-state-types v0.14.0-dev + github.com/filecoin-project/go-state-types v0.14.0-rc1 github.com/filecoin-project/go-statestore v0.2.0 github.com/filecoin-project/lotus v1.27.0 github.com/filecoin-project/specs-actors/v5 v5.0.6 diff --git a/go.sum b/go.sum index 83f21ead7..53d6ab81b 100644 --- a/go.sum +++ b/go.sum @@ -361,9 +361,8 @@ github.com/filecoin-project/go-state-types v0.0.0-20201102161440-c8033295a1fc/go github.com/filecoin-project/go-state-types v0.1.0/go.mod h1:ezYnPf0bNkTsDibL/psSz5dy4B5awOJ/E7P2Saeep8g= github.com/filecoin-project/go-state-types v0.1.6/go.mod h1:UwGVoMsULoCK+bWjEdd/xLCvLAQFBC7EDT477SKml+Q= github.com/filecoin-project/go-state-types v0.1.10/go.mod h1:UwGVoMsULoCK+bWjEdd/xLCvLAQFBC7EDT477SKml+Q= -github.com/filecoin-project/go-state-types v0.13.1/go.mod h1:cHpOPup9H1g2T29dKHAjC2sc7/Ef5ypjuW9A3I+e9yY= -github.com/filecoin-project/go-state-types v0.14.0-dev h1:bDwq1S28D7EC/uDmKU8vvNcdFw/YDsNq09pe3zeV5h4= -github.com/filecoin-project/go-state-types v0.14.0-dev/go.mod h1:cHpOPup9H1g2T29dKHAjC2sc7/Ef5ypjuW9A3I+e9yY= +github.com/filecoin-project/go-state-types v0.14.0-rc1 h1:kWBGX/uqZmYotYMNmw+R/fIuot/k0KMcEtB7PKFy1SQ= +github.com/filecoin-project/go-state-types v0.14.0-rc1/go.mod h1:cHpOPup9H1g2T29dKHAjC2sc7/Ef5ypjuW9A3I+e9yY= github.com/filecoin-project/go-statemachine v0.0.0-20200925024713-05bd7c71fbfe/go.mod h1:FGwQgZAt2Gh5mjlwJUlVB62JeYdo+if0xWxSEfBD9ig= github.com/filecoin-project/go-statemachine v1.0.3 h1:N07o6alys+V1tNoSTi4WuuoeNC4erS/6jE74+NsgQuk= github.com/filecoin-project/go-statemachine v1.0.3/go.mod h1:jZdXXiHa61n4NmgWFG4w8tnqgvZVHYbJ3yW7+y8bF54= diff --git a/itests/harmonycron_test.go b/itests/harmonycron_test.go index eb60f1dbd..a240d2891 100644 --- a/itests/harmonycron_test.go +++ b/itests/harmonycron_test.go @@ -5,13 +5,14 @@ import ( "testing" "time" + "github.com/snadrus/must" + "github.com/stretchr/testify/require" + "github.com/filecoin-project/curio/deps/config" "github.com/filecoin-project/curio/harmony/harmonydb" "github.com/filecoin-project/curio/harmony/harmonytask" "github.com/filecoin-project/curio/harmony/resources" "github.com/filecoin-project/curio/harmony/taskhelp/harmonycron" - "github.com/snadrus/must" - "github.com/stretchr/testify/require" ) // TestHarmonyCron is Documentesting @@ -45,8 +46,8 @@ func TestHarmonyCron(t *testing.T) { taskValue := "abcde" // our future task needs this, so save it to that task's table var rowID int64 // Pretend harmony_test is FutureTask's table - db.QueryRow(ctx, "INSERT INTO harmony_test (options, result) VALUES ('FutureTaskTbl', $1) RETURNING id", taskValue).Scan(&rowID) - + err := db.QueryRow(ctx, "INSERT INTO harmony_test (options, result) VALUES ('FutureTaskTbl', $1) RETURNING id", taskValue).Scan(&rowID) + require.NoError(t, err) // PreviousTask then schedules it sometime in the future. It will run AFTER this time. cron.At(time.Now().Add(3*time.Second), "FutureTask", "harmony_test", int(rowID)) // Now, PreviousTask's machine could go down, & someone's FutureTask runner will pick it up. From e6421eed877920c66fb18e58a5058e2f9a7753a3 Mon Sep 17 00:00:00 2001 From: "Andrew Jackson (Ajax)" Date: Mon, 29 Jul 2024 10:32:00 -0500 Subject: [PATCH 10/10] tidy --- go.sum | 1 + 1 file changed, 1 insertion(+) diff --git a/go.sum b/go.sum index 53d6ab81b..170175524 100644 --- a/go.sum +++ b/go.sum @@ -361,6 +361,7 @@ github.com/filecoin-project/go-state-types v0.0.0-20201102161440-c8033295a1fc/go github.com/filecoin-project/go-state-types v0.1.0/go.mod h1:ezYnPf0bNkTsDibL/psSz5dy4B5awOJ/E7P2Saeep8g= github.com/filecoin-project/go-state-types v0.1.6/go.mod h1:UwGVoMsULoCK+bWjEdd/xLCvLAQFBC7EDT477SKml+Q= github.com/filecoin-project/go-state-types v0.1.10/go.mod h1:UwGVoMsULoCK+bWjEdd/xLCvLAQFBC7EDT477SKml+Q= +github.com/filecoin-project/go-state-types v0.13.1/go.mod h1:cHpOPup9H1g2T29dKHAjC2sc7/Ef5ypjuW9A3I+e9yY= github.com/filecoin-project/go-state-types v0.14.0-rc1 h1:kWBGX/uqZmYotYMNmw+R/fIuot/k0KMcEtB7PKFy1SQ= github.com/filecoin-project/go-state-types v0.14.0-rc1/go.mod h1:cHpOPup9H1g2T29dKHAjC2sc7/Ef5ypjuW9A3I+e9yY= github.com/filecoin-project/go-statemachine v0.0.0-20200925024713-05bd7c71fbfe/go.mod h1:FGwQgZAt2Gh5mjlwJUlVB62JeYdo+if0xWxSEfBD9ig=