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
@@ -203,6 +203,44 @@ func TestBuildCountPublishTasksByStatusesQueryHidesDeletedPublishRecords(t *test
}
}
func TestLeaseNextQueuedMonitorTaskSQLSerializesPerClientPlatform(t *testing.T) {
t.Parallel()
normalized := normalizeSQLForDesktopTaskTest(leaseNextQueuedMonitorTaskSQL())
for _, fragment := range []string{
"NOT EXISTS ( SELECT 1 FROM desktop_tasks AS active",
"active.target_client_id = $3",
"active.platform_id = dt.platform_id",
"active.status = 'in_progress'",
"active.desktop_id <> dt.desktop_id",
"recent.status IN ('succeeded', 'failed', 'unknown', 'aborted')",
"recent.updated_at >= now() - interval '30 seconds'",
} {
if !strings.Contains(normalized, fragment) {
t.Fatalf("monitor lease query missing %q: %s", fragment, normalized)
}
}
}
func TestLeaseQueuedDesktopTaskByIDSQLSerializesMonitorPerClientPlatform(t *testing.T) {
t.Parallel()
normalized := normalizeSQLForDesktopTaskTest(leaseQueuedDesktopTaskByIDSQL())
for _, fragment := range []string{
"dt.kind <> 'monitor' OR NOT EXISTS",
"active.target_client_id = $4",
"active.platform_id = dt.platform_id",
"active.status = 'in_progress'",
"active.desktop_id <> dt.desktop_id",
"recent.status IN ('succeeded', 'failed', 'unknown', 'aborted')",
"recent.updated_at >= now() - interval '30 seconds'",
} {
if !strings.Contains(normalized, fragment) {
t.Fatalf("task-specific lease query missing %q: %s", fragment, normalized)
}
}
}
func recoverDesktopTaskSelectColumns(query string) []string {
re := regexp.MustCompile(`(?is)select\s+(.*?)\s+from\s+desktop_tasks`)
match := re.FindStringSubmatch(query)