fix: throttle desktop monitoring dispatch
Desktop Client Build / Resolve Build Metadata (push) Successful in 27s
Backend CI / Backend (push) Successful in 15m57s
Desktop Client Build / Build Desktop Client (push) Successful in 22m57s
Desktop Client Build / Publish Client Artifacts to NAS (push) Successful in 27s

This commit is contained in:
2026-06-22 12:21:59 +08:00
parent 54c2f92e02
commit 8c6789dca6
23 changed files with 591 additions and 88 deletions
@@ -398,7 +398,7 @@ func (w *ScheduleDispatchWorker) claimDueSchedules(ctx context.Context, runtimeC
}
now := time.Now()
tasks := make([]dueScheduleTask, 0, runtimeCfg.BatchSize)
candidates := make([]dueScheduleTask, 0, runtimeCfg.BatchSize)
updates := make([]struct {
cacheUpdate scheduleTaskCacheUpdate
nextRun *time.Time
@@ -469,17 +469,6 @@ func (w *ScheduleDispatchWorker) claimDueSchedules(ctx context.Context, runtimeC
}
task.PublishAccountIDs = decodeDueSchedulePublishAccountIDs(publishAccountIDsJSON)
task.PublishEnterpriseSiteTargets = tenantapp.DecodeScheduleEnterpriseSiteTargets(publishEnterpriseSiteTargetsJSON)
if task.AutoPublish && len(task.PublishAccountIDs) > 0 {
accountIDs, _, err := tenantapp.LoadExistingSchedulePublishAccountIDsAndPlatformsByIDs(ctx, tx, task.TenantID, task.WorkspaceID, task.PublishAccountIDs)
if err != nil {
rows.Close()
return nil, err
}
task.PublishAccountIDs = accountIDs
}
if task.AutoPublish && len(task.PublishAccountIDs) == 0 && len(task.PublishEnterpriseSiteTargets) == 0 {
task.AutoPublish = false
}
task.CoverRandomFolderID = int64PtrFromInt8(coverRandomFolderID)
if task.CoverMode == "" {
task.CoverMode = tenantapp.ScheduleCoverModeSpecific
@@ -519,7 +508,7 @@ func (w *ScheduleDispatchWorker) claimDueSchedules(ctx context.Context, runtimeC
})
if nextErr == nil && sharedschedule.IsRunAllowed(task.ScheduledFor, task.StartAt, task.EndAt) {
tasks = append(tasks, task)
candidates = append(candidates, task)
}
}
if err := rows.Err(); err != nil {
@@ -528,6 +517,21 @@ func (w *ScheduleDispatchWorker) claimDueSchedules(ctx context.Context, runtimeC
}
rows.Close()
tasks := make([]dueScheduleTask, 0, len(candidates))
for _, task := range candidates {
if task.AutoPublish && len(task.PublishAccountIDs) > 0 {
accountIDs, _, err := tenantapp.LoadExistingSchedulePublishAccountIDsAndPlatformsByIDs(ctx, tx, task.TenantID, task.WorkspaceID, task.PublishAccountIDs)
if err != nil {
return nil, err
}
task.PublishAccountIDs = accountIDs
}
if task.AutoPublish && len(task.PublishAccountIDs) == 0 && len(task.PublishEnterpriseSiteTargets) == 0 {
task.AutoPublish = false
}
tasks = append(tasks, task)
}
for _, update := range updates {
if update.invalidErr != nil {
message := truncateDispatchError(update.invalidErr)