Skip to content

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

refactor: move shared state to state package (#3740)

Danny Xuf3a61f50ef5d
diff --git a/server/component/state/state.go b/server/component/state/state.go
index 7583ff0150..2cc77ef74f 100644
--- a/server/component/state/state.go
+++ b/server/component/state/state.go
@@ -19,4 +19,13 @@ type State struct {
TaskProgress sync.Map // map[taskID]api.Progress
// GhostTaskState is the map from task ID to gh-ost state.
GhostTaskState sync.Map // map[taskID]sharedGhostState
+
+ // RunningBackupDatabases is the set of databases running backups.
+ RunningBackupDatabases sync.Map // map[databaseID]bool
+ // RunningTaskChecks is the set of running task checks.
+ RunningTaskChecks sync.Map // map[taskCheckID]bool
+ // RunningTasks is the set of running tasks.
+ RunningTasks sync.Map // map[taskID]bool
+ // RunningTasksCancel is the cancel's of running tasks.
+ RunningTasksCancel sync.Map // map[taskID]context.CancelFunc
}
diff --git a/server/runner/backuprun/runner.go b/server/runner/backuprun/runner.go
index bff1c207a3..93a72c5386 100644
--- a/server/runner/backuprun/runner.go
+++ b/server/runner/backuprun/runner.go
@@ -24,16 +24,18 @@ import (
"github.com/bytebase/bytebase/plugin/storage/s3"
"github.com/bytebase/bytebase/server/component/config"
"github.com/bytebase/bytebase/server/component/dbfactory"
+ "github.com/bytebase/bytebase/server/component/state"
"github.com/bytebase/bytebase/server/utils"
"github.com/bytebase/bytebase/store"
)
// NewRunner creates a new backup runner.
-func NewRunner(store *store.Store, dbFactory *dbfactory.DBFactory, s3Client *s3.Client, profile *config.Profile) *Runner {
+func NewRunner(store *store.Store, dbFactory *dbfactory.DBFactory, s3Client *s3.Client, stateCfg *state.State, profile *config.Profile) *Runner {
return &Runner{
store: store,
dbFactory: dbFactory,
s3Client: s3Client,
+ stateCfg: stateCfg,
profile: profile,
downloadBinlogInstanceIDs: make(map[int]bool),
}
@@ -44,6 +46,7 @@ type Runner struct {
store *store.Store
dbFactory *dbfactory.DBFactory
s3Client *s3.Client
+ stateCfg *state.State
profile *config.Profile
downloadBinlogInstanceIDs map[int]bool
backupWg sync.WaitGroup
@@ -57,8 +60,6 @@ func (r *Runner) Run(ctx context.Context, wg *sync.WaitGroup) {
defer ticker.Stop()
defer wg.Done()
log.Debug("Auto backup runner started", zap.Duration("interval", r.profile.BackupRunnerInterval))
- runningTasks := make(map[int]bool)
- var mu sync.RWMutex
for {
select {
case <-ticker.C:
@@ -72,7 +73,7 @@ func (r *Runner) Run(ctx context.Context, wg *sync.WaitGroup) {
log.Error("Auto backup runner PANIC RECOVER", zap.Error(err), zap.Stack("panic-stack"))
}
}()
- r.startAutoBackups(ctx, runningTasks, &mu)
+ r.startAutoBackups(ctx)
r.downloadBinlogFiles(ctx)
r.purgeExpiredBackupData(ctx)
}()
@@ -297,7 +298,7 @@ func (r *Runner) downloadBinlogFilesForInstance(ctx context.Context, instance *a
}
}
-func (r *Runner) startAutoBackups(ctx context.Context, runningTasks map[int]bool, mu *sync.RWMutex) {
+func (r *Runner) startAutoBackups(ctx context.Context) {
// Find all databases that need a backup in this hour.
t := time.Now().UTC().Truncate(time.Hour)
match := &api.BackupSettingsMatch{
@@ -311,14 +312,9 @@ func (r *Runner) startAutoBackups(ctx context.Context, runningTasks map[int]bool
}
for _, backupSetting := range backupSettingList {
- mu.Lock()
- if _, ok := runningTasks[backupSetting.ID]; ok {
- mu.Unlock()
+ if _, ok := r.stateCfg.RunningBackupDatabases.Load(backupSetting.DatabaseID); ok {
continue
}
- runningTasks[backupSetting.ID] = true
- mu.Unlock()
-
db := backupSetting.Database
if db.Name == api.AllDatabaseName {
// Skip backup job for wildcard database `*`.
@@ -337,11 +333,11 @@ func (r *Runner) startAutoBackups(ctx context.Context, runningTasks map[int]bool
log.Debug("Skip creating backup because it already exists", zap.Int("database-id", db.ID), zap.String("name", backupName))
continue
}
- go func(database *api.Database, backupSettingID int, backupName string, hookURL string) {
+
+ r.stateCfg.RunningBackupDatabases.Store(backupSetting.DatabaseID, true)
+ go func(database *api.Database, backupName string, hookURL string) {
defer func() {
- mu.Lock()
- delete(runningTasks, backupSettingID)
- mu.Unlock()
+ r.stateCfg.RunningBackupDatabases.Delete(database.ID)
r.backupWg.Done()
}()
log.Debug("Schedule auto backup",
@@ -364,7 +360,7 @@ func (r *Runner) startAutoBackups(ctx context.Context, runningTasks map[int]bool
zap.Int("databaseID", database.ID),
zap.Error(err))
}
- }(db, backupSetting.ID, backupName, backupSetting.HookURL)
+ }(db, backupName, backupSetting.HookURL)
r.backupWg.Add(1)
}
}
diff --git a/server/runner/taskcheck/task_check_executor.go b/server/runner/taskcheck/executor.go
similarity index 100%
rename from server/runner/taskcheck/task_check_executor.go
rename to server/runner/taskcheck/executor.go
diff --git a/server/runner/taskcheck/task_check_scheduler.go b/server/runner/taskcheck/scheduler.go
similarity index 97%
rename from server/runner/taskcheck/task_check_scheduler.go
rename to server/runner/taskcheck/scheduler.go
index 41ffdaea36..a5220a2fac 100644
--- a/server/runner/taskcheck/task_check_scheduler.go
+++ b/server/runner/taskcheck/scheduler.go
@@ -15,6 +15,7 @@ import (
"github.com/bytebase/bytebase/common"
"github.com/bytebase/bytebase/common/log"
enterpriseAPI "github.com/bytebase/bytebase/enterprise/api"
+ "github.com/bytebase/bytebase/server/component/state"
"github.com/bytebase/bytebase/store"
)
@@ -23,10 +24,11 @@ const (
)
// NewScheduler creates a task check scheduler.
-func NewScheduler(store *store.Store, licenseService enterpriseAPI.LicenseService) *Scheduler {
+func NewScheduler(store *store.Store, licenseService enterpriseAPI.LicenseService, stateCfg *state.State) *Scheduler {
return &Scheduler{
store: store,
licenseService: licenseService,
+ stateCfg: stateCfg,
executors: make(map[api.TaskCheckType]Executor),
}
}
@@ -35,6 +37,7 @@ func NewScheduler(store *store.Store, licenseService enterpriseAPI.LicenseServic
type Scheduler struct {
store *store.Store
licenseService enterpriseAPI.LicenseService
+ stateCfg *state.State
executors map[api.TaskCheckType]Executor
}
@@ -44,8 +47,6 @@ func (s *Scheduler) Run(ctx context.Context, wg *sync.WaitGroup) {
defer ticker.Stop()
defer wg.Done()
log.Debug(fmt.Sprintf("Task check scheduler started and will run every %v", taskCheckSchedulerInterval))
- runningTaskChecks := make(map[int]bool)
- mu := sync.RWMutex{}
for {
select {
case <-ticker.C:
@@ -83,19 +84,13 @@ func (s *Scheduler) Run(ctx context.Context, wg *sync.WaitGroup) {
continue
}
- mu.Lock()
- if _, ok := runningTaskChecks[taskCheckRun.ID]; ok {
- mu.Unlock()
+ if _, ok := s.stateCfg.RunningTaskChecks.Load(taskCheckRun.ID); ok {
continue
}
- runningTaskChecks[taskCheckRun.ID] = true
- mu.Unlock()
-
+ s.stateCfg.RunningTaskChecks.Store(taskCheckRun.ID, true)
go func(taskCheckRun *api.TaskCheckRun) {
defer func() {
- mu.Lock()
- delete(runningTaskChecks, taskCheckRun.ID)
- mu.Unlock()
+ s.stateCfg.RunningTaskChecks.Delete(taskCheckRun.ID)
}()
checkResultList, err := executor.Run(ctx, taskCheckRun)
diff --git a/server/runner/taskrun/task_executor.go b/server/runner/taskrun/executor.go
similarity index 100%
rename from server/runner/taskrun/task_executor.go
rename to server/runner/taskrun/executor.go
diff --git a/server/runner/taskrun/task_scheduler.go b/server/runner/taskrun/scheduler.go
similarity index 92%
rename from server/runner/taskrun/task_scheduler.go
rename to server/runner/taskrun/scheduler.go
index 13c539631b..db665918ff 100644
--- a/server/runner/taskrun/task_scheduler.go
+++ b/server/runner/taskrun/scheduler.go
@@ -46,9 +46,9 @@ var (
}
)
-// NewTaskScheduler creates a new task scheduler.
-func NewTaskScheduler(store *store.Store, applicationRunner *apprun.Runner, schemaSyncer *schemasync.Syncer, activityManager *activity.Manager, licenseService enterpriseAPI.LicenseService, stateCfg *state.State, profile config.Profile) *TaskScheduler {
- return &TaskScheduler{
+// NewScheduler creates a new task scheduler.
+func NewScheduler(store *store.Store, applicationRunner *apprun.Runner, schemaSyncer *schemasync.Syncer, activityManager *activity.Manager, licenseService enterpriseAPI.LicenseService, stateCfg *state.State, profile config.Profile) *Scheduler {
+ return &Scheduler{
store: store,
applicationRunner: applicationRunner,
schemaSyncer: schemaSyncer,
@@ -60,8 +60,8 @@ func NewTaskScheduler(store *store.Store, applicationRunner *apprun.Runner, sche
}
}
-// TaskScheduler is the task scheduler.
-type TaskScheduler struct {
+// Scheduler is the task scheduler.
+type Scheduler struct {
store *store.Store
applicationRunner *apprun.Runner
schemaSyncer *schemasync.Syncer
@@ -70,13 +70,10 @@ type TaskScheduler struct {
stateCfg *state.State
profile config.Profile
executorMap map[api.TaskType]Executor
-
- runningTasks sync.Map // map[taskID]bool
- runningTasksCancel sync.Map // map[taskID]context.CancelFunc
}
// Run will run the task scheduler.
-func (s *TaskScheduler) Run(ctx context.Context, wg *sync.WaitGroup) {
+func (s *Scheduler) Run(ctx context.Context, wg *sync.WaitGroup) {
ticker := time.NewTicker(taskSchedulerInterval)
defer ticker.Stop()
defer wg.Done()
@@ -152,7 +149,7 @@ func (s *TaskScheduler) Run(ctx context.Context, wg *sync.WaitGroup) {
continue
}
// Skip the task that is already being executed.
- if _, ok := s.runningTasks.Load(task.ID); ok {
+ if _, ok := s.stateCfg.RunningTasks.Load(task.ID); ok {
continue
}
// Skip the task that is not the earliest task of the database.
@@ -173,16 +170,16 @@ func (s *TaskScheduler) Run(ctx context.Context, wg *sync.WaitGroup) {
continue
}
- s.runningTasks.Store(task.ID, true)
+ s.stateCfg.RunningTasks.Store(task.ID, true)
go func(ctx context.Context, task *api.Task, executor Executor) {
defer func() {
- s.runningTasks.Delete(task.ID)
- s.runningTasksCancel.Delete(task.ID)
+ s.stateCfg.RunningTasks.Delete(task.ID)
+ s.stateCfg.RunningTasksCancel.Delete(task.ID)
s.stateCfg.TaskProgress.Delete(task.ID)
}()
executorCtx, cancel := context.WithCancel(ctx)
- s.runningTasksCancel.Store(task.ID, cancel)
+ s.stateCfg.RunningTasksCancel.Store(task.ID, cancel)
done, result, err := RunExecutorOnce(executorCtx, executor, task)
@@ -318,7 +315,7 @@ func (s *TaskScheduler) Run(ctx context.Context, wg *sync.WaitGroup) {
}
// Register will register a task executor factory.
-func (s *TaskScheduler) Register(taskType api.TaskType, executorGetter Executor) {
+func (s *Scheduler) Register(taskType api.TaskType, executorGetter Executor) {
if executorGetter == nil {
panic("scheduler: Register executor is nil for task type: " + taskType)
}
@@ -332,7 +329,7 @@ func (s *TaskScheduler) Register(taskType api.TaskType, executorGetter Executor)
// When there are running tasks and Bytebase server is shutdown, these task executors are stopped, but the tasks' status are still RUNNING.
// When Bytebase is restarted, the task scheduler will re-schedule those RUNNING tasks, which should be CANCELED instead.
// So we change their status to CANCELED before starting the scheduler.
-func (s *TaskScheduler) ClearRunningTasks(ctx context.Context) error {
+func (s *Scheduler) ClearRunningTasks(ctx context.Context) error {
taskFind := &api.TaskFind{StatusList: &[]api.TaskStatus{api.TaskRunning}}
runningTasks, err := s.store.FindTask(ctx, taskFind, false)
if err != nil {
@@ -371,7 +368,7 @@ func (s *TaskScheduler) ClearRunningTasks(ctx context.Context) error {
return nil
}
-func (s *TaskScheduler) passAllCheck(ctx context.Context, task *api.Task, allowedStatus api.TaskCheckStatus) (bool, error) {
+func (s *Scheduler) passAllCheck(ctx context.Context, task *api.Task, allowedStatus api.TaskCheckStatus) (bool, error) {
// schema update, data update and gh-ost sync task have required task check.
if task.Type == api.TaskDatabaseSchemaUpdate || task.Type == api.TaskDatabaseSchemaUpdateSDL || task.Type == api.TaskDatabaseDataUpdate || task.Type == api.TaskDatabaseSchemaUpdateGhostSync {
pass, err := s.passCheck(ctx, task, api.TaskCheckDatabaseConnect, allowedStatus)
@@ -446,7 +443,7 @@ func (s *TaskScheduler) passAllCheck(ctx context.Context, task *api.Task, allowe
// For PendingApproval->Pending transitions, the minimum level is SUCCESS.
// For Pending->Running transitions, the minimum level is WARN.
// TODO(dragonly): refactor arguments.
-func (s *TaskScheduler) passCheck(ctx context.Context, task *api.Task, checkType api.TaskCheckType, allowedStatus api.TaskCheckStatus) (bool, error) {
+func (s *Scheduler) passCheck(ctx context.Context, task *api.Task, checkType api.TaskCheckType, allowedStatus api.TaskCheckStatus) (bool, error) {
statusList := []api.TaskCheckRunStatus{api.TaskCheckRunDone, api.TaskCheckRunFailed}
taskCheckRunFind := &api.TaskCheckRunFind{
TaskID: &task.ID,
@@ -478,12 +475,12 @@ func (s *TaskScheduler) passCheck(ctx context.Context, task *api.Task, checkType
}
// auto transit PendingApproval to Pending if all required task checks pass.
-func (s *TaskScheduler) canAutoApprove(ctx context.Context, task *api.Task) (bool, error) {
+func (s *Scheduler) canAutoApprove(ctx context.Context, task *api.Task) (bool, error) {
return s.passAllCheck(ctx, task, api.TaskCheckStatusSuccess)
}
// CanSchedule returns whether a task can be scheduled.
-func (s *TaskScheduler) CanSchedule(ctx context.Context, task *api.Task) (bool, error) {
+func (s *Scheduler) CanSchedule(ctx context.Context, task *api.Task) (bool, error) {
blocked, err := s.isTaskBlocked(ctx, task)
if err != nil {
return false, errors.Wrap(err, "failed to check if task is blocked")
@@ -503,7 +500,7 @@ func (s *TaskScheduler) CanSchedule(ctx context.Context, task *api.Task) (bool,
// 1. its required check does not contain error in the latest run.
// 2. it has no blocking tasks.
// 3. it has passed the earliest allowed time.
-func (s *TaskScheduler) ScheduleIfNeeded(ctx context.Context, task *api.Task) (*api.Task, error) {
+func (s *Scheduler) ScheduleIfNeeded(ctx context.Context, task *api.Task) (*api.Task, error) {
schedule, err := s.CanSchedule(ctx, task)
if err != nil {
return nil, err
@@ -524,7 +521,7 @@ func (s *TaskScheduler) ScheduleIfNeeded(ctx context.Context, task *api.Task) (*
return updatedTask, nil
}
-func (s *TaskScheduler) isTaskBlocked(ctx context.Context, task *api.Task) (bool, error) {
+func (s *Scheduler) isTaskBlocked(ctx context.Context, task *api.Task) (bool, error) {
for _, blockingTaskIDString := range task.BlockedBy {
blockingTaskID, err := strconv.Atoi(blockingTaskIDString)
if err != nil {
@@ -542,7 +539,7 @@ func (s *TaskScheduler) isTaskBlocked(ctx context.Context, task *api.Task) (bool
}
// ScheduleActiveStage tries to schedule the tasks in the active stage.
-func (s *TaskScheduler) ScheduleActiveStage(ctx context.Context, pipeline *api.Pipeline) error {
+func (s *Scheduler) ScheduleActiveStage(ctx context.Context, pipeline *api.Pipeline) error {
stage := utils.GetActiveStage(pipeline.StageList)
if stage == nil {
return nil
@@ -581,7 +578,7 @@ func (s *TaskScheduler) ScheduleActiveStage(ctx context.Context, pipeline *api.P
}
// PatchTaskStatus patches a single task.
-func (s *TaskScheduler) PatchTaskStatus(ctx context.Context, task *api.Task, taskStatusPatch *api.TaskStatusPatch) (_ *api.Task, err error) {
+func (s *Scheduler) PatchTaskStatus(ctx context.Context, task *api.Task, taskStatusPatch *api.TaskStatusPatch) (_ *api.Task, err error) {
defer func() {
if err != nil {
log.Error("Failed to change task status.",
@@ -608,7 +605,7 @@ func (s *TaskScheduler) PatchTaskStatus(ctx context.Context, task *api.Task, tas
if !taskCancellationImplemented[task.Type] {
return nil, common.Errorf(common.NotImplemented, "Canceling task type %s is not supported", task.Type)
}
- cancelAny, ok := s.runningTasksCancel.Load(task.ID)
+ cancelAny, ok := s.stateCfg.RunningTasksCancel.Load(task.ID)
cancel := cancelAny.(context.CancelFunc)
if !ok {
return nil, errors.New("failed to cancel task")
@@ -754,7 +751,7 @@ func isTaskStatusTransitionAllowed(fromStatus, toStatus api.TaskStatus) bool {
return false
}
-func (s *TaskScheduler) createTaskStatusUpdateActivity(ctx context.Context, task *api.Task, taskStatusPatch *api.TaskStatusPatch, issue *api.Issue) error {
+func (s *Scheduler) createTaskStatusUpdateActivity(ctx context.Context, task *api.Task, taskStatusPatch *api.TaskStatusPatch, issue *api.Issue) error {
var issueName string
if issue != nil {
issueName = issue.Name
@@ -791,7 +788,7 @@ func (s *TaskScheduler) createTaskStatusUpdateActivity(ctx context.Context, task
return nil
}
-func (s *TaskScheduler) cancelDependingTasks(ctx context.Context, task *api.Task) error {
+func (s *Scheduler) cancelDependingTasks(ctx context.Context, task *api.Task) error {
queue := []int{task.ID}
seen := map[int]bool{task.ID: true}
var idList []int
@@ -833,7 +830,7 @@ func areAllTasksDone(pipeline *api.Pipeline) bool {
}
// GetDefaultAssigneeID gets the default assignee for an issue.
-func (s *TaskScheduler) GetDefaultAssigneeID(ctx context.Context, environmentID int, projectID int, issueType api.IssueType) (int, error) {
+func (s *Scheduler) GetDefaultAssigneeID(ctx context.Context, environmentID int, projectID int, issueType api.IssueType) (int, error) {
policy, err := s.store.GetPipelineApprovalPolicy(ctx, environmentID)
if err != nil {
return api.UnknownID, errors.Wrapf(err, "failed to GetPipelineApprovalPolicy for environmentID %d", environmentID)
@@ -868,7 +865,7 @@ func (s *TaskScheduler) GetDefaultAssigneeID(ctx context.Context, environmentID
}
// getAnyFromWorkspaceOwnerOrDBA finds a default assignee from the workspace owners or DBAs.
-func (s *TaskScheduler) getAnyWorkspaceOwnerOrDBA(ctx context.Context) (*api.Member, error) {
+func (s *Scheduler) getAnyWorkspaceOwnerOrDBA(ctx context.Context) (*api.Member, error) {
for _, role := range []api.Role{api.Owner, api.DBA} {
memberList, err := s.store.FindMember(ctx, &api.MemberFind{
Role: &role,
@@ -884,7 +881,7 @@ func (s *TaskScheduler) getAnyWorkspaceOwnerOrDBA(ctx context.Context) (*api.Mem
}
// getAnyProjectOwner gets a default assignee from the project owners.
-func (s *TaskScheduler) getAnyProjectOwner(ctx context.Context, projectID int) (*api.ProjectMember, error) {
+func (s *Scheduler) getAnyProjectOwner(ctx context.Context, projectID int) (*api.ProjectMember, error) {
role := api.Owner
find := &api.ProjectMemberFind{
ProjectID: &projectID,
@@ -901,7 +898,7 @@ func (s *TaskScheduler) getAnyProjectOwner(ctx context.Context, projectID int) (
}
// CanPrincipalBeAssignee checks if a principal could be the assignee of an issue, judging by the principal role and the environment policy.
-func (s *TaskScheduler) CanPrincipalBeAssignee(ctx context.Context, principalID int, environmentID int, projectID int, issueType api.IssueType) (bool, error) {
+func (s *Scheduler) CanPrincipalBeAssignee(ctx context.Context, principalID int, environmentID int, projectID int, issueType api.IssueType) (bool, error) {
policy, err := s.store.GetPipelineApprovalPolicy(ctx, environmentID)
if err != nil {
return false, err
@@ -952,7 +949,7 @@ func (s *TaskScheduler) CanPrincipalBeAssignee(ctx context.Context, principalID
}
// ChangeIssueStatus changes the status of an issue.
-func (s *TaskScheduler) ChangeIssueStatus(ctx context.Context, issue *api.Issue, newStatus api.IssueStatus, updaterID int, comment string) (*api.Issue, error) {
+func (s *Scheduler) ChangeIssueStatus(ctx context.Context, issue *api.Issue, newStatus api.IssueStatus, updaterID int, comment string) (*api.Issue, error) {
var pipelineStatus api.PipelineStatus
switch newStatus {
case api.IssueOpen:
diff --git a/server/runner/taskrun/task_scheduler_test.go b/server/runner/taskrun/scheduler_test.go
similarity index 100%
rename from server/runner/taskrun/task_scheduler_test.go
rename to server/runner/taskrun/scheduler_test.go
diff --git a/server/server.go b/server/server.go
index 23deaabbeb..b8b8272104 100644
--- a/server/server.go
+++ b/server/server.go
@@ -94,7 +94,7 @@ const (
// Server is the Bytebase server.
type Server struct {
// Asynchronous runners.
- TaskScheduler *taskrun.TaskScheduler
+ TaskScheduler *taskrun.Scheduler
TaskCheckScheduler *taskcheck.Scheduler
MetricReporter *metricreport.Reporter
SchemaSyncer *schemasync.Syncer
@@ -301,10 +301,10 @@ func NewServer(ctx context.Context, profile config.Profile) (*Server, error) {
// TODO(p0ny): enable Feishu provider only when it is needed.
s.feishuProvider = feishu.NewProvider(profile.FeishuAPIURL)
s.ApplicationRunner = apprun.NewRunner(storeInstance, s.ActivityManager, s.feishuProvider, profile)
- s.BackupRunner = backuprun.NewRunner(storeInstance, s.dbFactory, s.s3Client, &profile)
+ s.BackupRunner = backuprun.NewRunner(storeInstance, s.dbFactory, s.s3Client, s.stateCfg, &profile)
s.RollbackRunner = rollbackrun.NewRunner(storeInstance, s.dbFactory, s.stateCfg)
- s.TaskScheduler = taskrun.NewTaskScheduler(storeInstance, s.ApplicationRunner, s.SchemaSyncer, s.ActivityManager, s.licenseService, s.stateCfg, profile)
+ s.TaskScheduler = taskrun.NewScheduler(storeInstance, s.ApplicationRunner, s.SchemaSyncer, s.ActivityManager, s.licenseService, s.stateCfg, profile)
s.TaskScheduler.Register(api.TaskGeneral, taskrun.NewDefaultExecutor())
s.TaskScheduler.Register(api.TaskDatabaseCreate, taskrun.NewDatabaseCreateExecutor(storeInstance, s.dbFactory, profile))
s.TaskScheduler.Register(api.TaskDatabaseSchemaBaseline, taskrun.NewSchemaBaselineExecutor(storeInstance, s.dbFactory, s.ActivityManager, s.stateCfg, profile))
@@ -317,7 +317,7 @@ func NewServer(ctx context.Context, profile config.Profile) (*Server, error) {
s.TaskScheduler.Register(api.TaskDatabaseRestorePITRRestore, taskrun.NewPITRRestoreExecutor(storeInstance, s.dbFactory, s.s3Client, s.SchemaSyncer, s.stateCfg, profile))
s.TaskScheduler.Register(api.TaskDatabaseRestorePITRCutover, taskrun.NewPITRCutoverExecutor(storeInstance, s.dbFactory, s.SchemaSyncer, s.BackupRunner, s.ActivityManager, profile))
- s.TaskCheckScheduler = taskcheck.NewScheduler(storeInstance, s.licenseService)
+ s.TaskCheckScheduler = taskcheck.NewScheduler(storeInstance, s.licenseService, s.stateCfg)
statementSimpleExecutor := taskcheck.NewStatementAdvisorSimpleExecutor()
s.TaskCheckScheduler.Register(api.TaskCheckDatabaseStatementFakeAdvise, statementSimpleExecutor)
s.TaskCheckScheduler.Register(api.TaskCheckDatabaseStatementSyntax, statementSimpleExecutor)