Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

fix: data update task executor (#2000)

Yilong Lic2dba8f124d5
diff --git a/server/task_executor_data_update.go b/server/task_executor_data_update.go
index 86956fdc2d..4eccbf3521 100644
--- a/server/task_executor_data_update.go
+++ b/server/task_executor_data_update.go
@@ -4,6 +4,7 @@ import (
"context"
"encoding/json"
"fmt"
+ "sync/atomic"
"github.com/bytebase/bytebase/api"
"github.com/bytebase/bytebase/plugin/db"
@@ -11,15 +12,17 @@ import (
// NewDataUpdateTaskExecutor creates a data update (DML) task executor.
func NewDataUpdateTaskExecutor() TaskExecutor {
- return &SchemaUpdateTaskExecutor{}
+ return &DataUpdateTaskExecutor{}
}
// DataUpdateTaskExecutor is the data update (DML) task executor.
type DataUpdateTaskExecutor struct {
+ completed int32
}
// RunOnce will run the data update (DML) task executor once.
func (exec *DataUpdateTaskExecutor) RunOnce(ctx context.Context, server *Server, task *api.Task) (terminated bool, result *api.TaskRunResultPayload, err error) {
+ defer atomic.StoreInt32(&exec.completed, 1)
payload := &api.TaskDatabaseDataUpdatePayload{}
if err := json.Unmarshal([]byte(task.Payload), payload); err != nil {
return true, nil, fmt.Errorf("invalid database data update payload: %w", err)
@@ -27,3 +30,8 @@ func (exec *DataUpdateTaskExecutor) RunOnce(ctx context.Context, server *Server,
return runMigration(ctx, server, task, db.Data, payload.Statement, payload.SchemaVersion, payload.VCSPushEvent)
}
+
+// IsCompleted tells the scheduler if the task execution has completed
+func (exec *DataUpdateTaskExecutor) IsCompleted() bool {
+ return atomic.LoadInt32(&exec.completed) == 1
+}