Fix monitor collect-now queue fairness

This commit is contained in:
2026-06-22 21:47:26 +08:00
parent 5a32926009
commit 082f91a6a9
11 changed files with 222 additions and 258 deletions
@@ -74,7 +74,7 @@ interface MonitorTaskMetadata {
questionText: string | null
}
const schedulerStateVersion = 5
const schedulerStateVersion = 6
const schedulerQuestionCooldownMs = 45_000
const schedulerPlatformCooldownMs = 5_000
const schedulerRestartRecoveryDelayMs = 90_000
@@ -492,10 +492,10 @@ export function selectNextMonitorTask(
continue
}
const bypassCooldowns = candidate.lane === 'high'
const bypassQuestionCooldown = candidate.lane === 'high'
const platformCooldown = draft.platformCooldowns[candidate.platform] ?? 0
if (!bypassCooldowns && platformCooldown > now) {
if (platformCooldown > now) {
continue
}
@@ -508,7 +508,7 @@ export function selectNextMonitorTask(
continue
}
const questionCooldown = draft.questionCooldowns[candidate.questionKey] ?? 0
if (!bypassCooldowns && questionCooldown > now) {
if (!bypassQuestionCooldown && questionCooldown > now) {
continue
}
}
@@ -553,12 +553,12 @@ export function getMonitorSchedulerSnapshot(): MonitorSchedulerSnapshot {
function leaseMissBackoffMs(leaseMisses: number): number {
if (leaseMisses <= 1) {
return 20_000
return 15_000
}
if (leaseMisses === 2) {
return 60_000
return 30_000
}
return 3 * 60_000
return 60_000
}
function metadataFromEvent(event: DesktopTaskEventMessage): MonitorTaskMetadata {