fix(stats): harden delete maintenance queue and shutdown handling

- Flush pending writes before locking during maintenance
- Handle scheduler failures and worker shutdown races
This commit is contained in:
2026-08-12 00:49:40 -07:00
parent 675cb33519
commit 772635ab96
8 changed files with 223 additions and 43 deletions
@@ -58,7 +58,9 @@ export class DeleteMaintenanceScheduler {
}
private scheduleDrain(): void {
if (this.destroyed || this.running || this.drainTimer) return;
if (this.destroyed || this.running || this.drainTimer || this.pendingRequests.length === 0) {
return;
}
this.drainTimer = setTimeout(() => {
this.drainTimer = null;
void this.drain();