Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
fix: use serializable isolation for patching task status (#779)
Danny Xu46fbcc453537
diff --git a/store/task.go b/store/task.goindex fac0315b9f..d896d27774 100644--- a/store/task.go+++ b/store/task.go@@ -102,7 +102,10 @@ func (s *TaskService) PatchTask(ctx context.Context, patch *api.TaskPatch) (*api// PatchTaskStatus updates an existing task status and the correspondng task run status atomically.// Returns ENOTFOUND if task does not exist.func (s *TaskService) PatchTaskStatus(ctx context.Context, patch *api.TaskStatusPatch) (*api.Task, error) {- tx, err := s.db.BeginTx(ctx, nil)+ // Without using serializable isolation transaction, we will get race condition and have multiple task runs inserted because+ // we do a read and write on task, without guanrantee consistency on task runs.+ // Once we have multiple task runs, the task will get to unrecoverable state because find task run will fail with two active runs.+ tx, err := s.db.BeginTx(ctx, &sql.TxOptions{Isolation: sql.LevelSerializable})if err != nil {return nil, FormatError(err)}