Skip to content

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

chore: adjust scheduler interval (#8144)

Danny Xu153d50d422ca
diff --git a/backend/api/v1/rollout_service.go b/backend/api/v1/rollout_service.go
index b398483eb2..2fe302e64a 100644
--- a/backend/api/v1/rollout_service.go
+++ b/backend/api/v1/rollout_service.go
@@ -170,6 +170,9 @@ func (s *RolloutService) CreatePlan(ctx context.Context, request *v1pb.CreatePla
return nil, status.Errorf(codes.Internal, "failed to create plan check runs, error: %v", err)
}
+ // Tickle plan check scheduler.
+ s.stateCfg.PlanCheckTickleChan <- 0
+
return convertToPlan(plan), nil
}
@@ -307,6 +310,10 @@ func (s *RolloutService) CreateRollout(ctx context.Context, request *v1pb.Create
if err != nil {
return nil, status.Errorf(codes.Internal, "failed to convert to rollout, error: %v", err)
}
+
+ // Tickle task run scheduler.
+ s.stateCfg.TaskRunTickleChan <- 0
+
return rolloutV1, nil
}
@@ -355,6 +362,9 @@ func (s *RolloutService) RunPlanChecks(ctx context.Context, request *v1pb.RunPla
return nil, status.Errorf(codes.Internal, "failed to create plan check runs, error: %v", err)
}
+ // Tickle plan check scheduler.
+ s.stateCfg.PlanCheckTickleChan <- 0
+
return &v1pb.RunPlanChecksResponse{}, nil
}
@@ -520,6 +530,9 @@ func (s *RolloutService) BatchRunTasks(ctx context.Context, request *v1pb.BatchR
slog.Error("failed to batch create activities for running tasks", log.BBError(err))
}
+ // Tickle task run scheduler.
+ s.stateCfg.TaskRunTickleChan <- 0
+
return &v1pb.BatchRunTasksResponse{}, nil
}
diff --git a/backend/component/state/state.go b/backend/component/state/state.go
index 74735de723..1bdb9d8ed6 100644
--- a/backend/component/state/state.go
+++ b/backend/component/state/state.go
@@ -54,6 +54,11 @@ type State struct {
// TaskSkippedOrDoneChan is the channel for notifying the task is skipped or done.
TaskSkippedOrDoneChan chan int
+ // PlanCheckTickleChan is the tickler for plan check scheduler.
+ PlanCheckTickleChan chan int
+ // TaskRunTickleChan is the tickler for task run scheduler.
+ TaskRunTickleChan chan int
+
sync.Mutex
}
diff --git a/backend/runner/plancheck/scheduler.go b/backend/runner/plancheck/scheduler.go
index 61a54d16f0..2dd9d6aa96 100644
--- a/backend/runner/plancheck/scheduler.go
+++ b/backend/runner/plancheck/scheduler.go
@@ -19,7 +19,7 @@ import (
)
const (
- planCheckSchedulerInterval = time.Duration(1) * time.Second
+ planCheckSchedulerInterval = 5 * time.Second
)
// NewScheduler creates a new plan check scheduler.
@@ -50,6 +50,8 @@ func (s *Scheduler) Run(ctx context.Context, wg *sync.WaitGroup) {
select {
case <-ticker.C:
s.runOnce(ctx)
+ case <-s.stateCfg.PlanCheckTickleChan:
+ s.runOnce(ctx)
case <-ctx.Done():
return
}
diff --git a/backend/runner/taskrun/schedulerv2.go b/backend/runner/taskrun/schedulerv2.go
index cd947e97c8..86b06ff22a 100644
--- a/backend/runner/taskrun/schedulerv2.go
+++ b/backend/runner/taskrun/schedulerv2.go
@@ -22,7 +22,7 @@ import (
)
const (
- taskSchedulerInterval = time.Duration(1) * time.Second
+ taskSchedulerInterval = 5 * time.Second
)
// SchedulerV2 is the V2 scheduler for task run.
@@ -66,6 +66,8 @@ func (s *SchedulerV2) Run(ctx context.Context, wg *sync.WaitGroup) {
select {
case <-ticker.C:
s.runOnce(ctx)
+ case <-s.stateCfg.TaskRunTickleChan:
+ s.runOnce(ctx)
case <-ctx.Done():
return
}
diff --git a/backend/server/server.go b/backend/server/server.go
index 1ed54df793..84295118bf 100644
--- a/backend/server/server.go
+++ b/backend/server/server.go
@@ -331,6 +331,8 @@ func NewServer(ctx context.Context, profile config.Profile) (*Server, error) {
InstanceOutstandingConnections: make(map[int]int),
IssueExternalApprovalRelayCancelChan: make(chan int, 1),
TaskSkippedOrDoneChan: make(chan int, 1000),
+ PlanCheckTickleChan: make(chan int, 1000),
+ TaskRunTickleChan: make(chan int, 1000),
}
s.store = storeInstance