Skip to content

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

chore: order by task run id (#7766)

Danny Xu8d8664f1b290
diff --git a/backend/api/v1/rollout_service.go b/backend/api/v1/rollout_service.go
index ec841944c4..a189559489 100644
--- a/backend/api/v1/rollout_service.go
+++ b/backend/api/v1/rollout_service.go
@@ -4,6 +4,7 @@ import (
"context"
"encoding/json"
"fmt"
+ "sort"
"strconv"
"time"
@@ -508,6 +509,9 @@ func (s *RolloutService) BatchRunTasks(ctx context.Context, request *v1pb.BatchR
}
taskRunCreates = append(taskRunCreates, create)
}
+ sort.Slice(taskRunCreates, func(i, j int) bool {
+ return taskRunCreates[i].TaskUID < taskRunCreates[j].TaskUID
+ })
if err := s.store.CreatePendingTaskRuns(ctx, taskRunCreates...); err != nil {
return nil, status.Errorf(codes.Internal, "failed to create pending task runs")
diff --git a/backend/store/task_run.go b/backend/store/task_run.go
index aed26618d0..5293d549af 100644
--- a/backend/store/task_run.go
+++ b/backend/store/task_run.go
@@ -134,7 +134,8 @@ func (s *Store) ListTaskRunsV2(ctx context.Context, find *FindTaskRunMessage) ([
LEFT JOIN task ON task.id = task_run.task_id
LEFT JOIN pipeline ON pipeline.id = task.pipeline_id
LEFT JOIN project ON project.id = pipeline.project_id
- WHERE %s`, strings.Join(where, " AND ")),
+ WHERE %s
+ ORDER BY task_run.id ASC`, strings.Join(where, " AND ")),
args...,
)
if err != nil {
@@ -410,7 +411,8 @@ func (*Store) findTaskRunImpl(ctx context.Context, tx *Tx, find *TaskRunFind) ([
task.stage_id
FROM task_run
JOIN task ON task.id = task_run.task_id
- WHERE %s`, strings.Join(where, " AND ")),
+ WHERE %s
+ ORDER BY task_run.id ASC`, strings.Join(where, " AND ")),
args...,
)
if err != nil {