Repository navigation
Description
Problem
A scheduled fire that does not terminate appears able to prevent the scheduler from discovering and claiming unrelated due schedules. Fire deadlines request cancellation but do not reliably bound how long the scheduler waits. This makes unattended monitoring brittle: schedule creation succeeds, leadership remains healthy, yet nothing executes and no failure notification arrives.
Observed incident
On October 12, 2026, a five-minute monitor was created for native execution qualification run https://github.com/stacklok/mecatl/actions/runs/38227550692 (PR #2219).
- New schedule:
pr-2219-native-ci-38227550692. - Created at 09:32:17 UTC, with its first due slot at 09:37:17 UTC.
- The workflow finished at 10:32:08 UTC, but no scheduled notification arrived.
- Inspection after completion still showed the original next-fire time, fire count 0, and no fire records. The schedule was subsequently paused manually.
Read-only investigation of the embedded mecatui runtime found:
- Scheduling was enabled with local flock leadership; the process still held the leadership lock and renewed its lease.
- An older
pr-2219-ci-monitorfire had started on October 11 at 11:20:01 UTC, last progressed at 11:20:19 UTC, and had a deadline of 11:50:01 UTC. - That older fire still had no terminal stop recorded almost a day later. The same process still held and renewed its session lease.
- No scheduler standby, lease-loss, Due-error, or Claim-error diagnostics were found in the inspected runtime log after startup.
This was not merely a notification-delivery failure: the new schedule was never claimed.
Suspected mechanism and confidence
Source inspection shows a concrete liveness weakness consistent with the runtime evidence:
- The scheduler waits for the current batch's fire workers in
g.Wait()before returning to polling. One fire that never returns can therefore block laterDue()queries and unrelated claims. - Leadership renewal runs separately, so a healthy leadership lease does not prove scheduler progress.
- The fire watchdog requests cancellation through
Service.Cancel, discarding its error. The fire path then drainsrun.Events()until closure, without an independent deadline escape.
Relevant code at ccfd074a81f4814b45a02275a0d283d1397ca300:
internal/adapter/scheduler/scheduler.go:963— batch completion wait.internal/app/scheduler_fire.go:165— watchdog cancellation path.internal/app/scheduler_fire.go:211— event draining.
Strongly supported, not conclusively proven: no goroutine snapshot was captured, so the exact blocking location and original cause of the old fire's nontermination remain unknown. The running binary reported revision c6d7338888 with vcs.modified=true; the inspected scheduler/startup/fire files have no committed differences from that revision to ccfd074a81, but runtime uncommitted changes cannot be excluded.
Expected behavior
A stuck or uncooperative fire must not silently freeze unrelated scheduling. Deadline handling must produce a durable, inspectable outcome or an explicit degraded state, rather than leave an apparently healthy scheduler renewing leases indefinitely without making progress.
Acceptance criteria
- Reproduce with deterministic offline fixtures: keep one fire blocked past its deadline and make another schedule due. Verify unrelated work can be discovered and started within configured capacity.
- Decouple polling/admission progress from waiting indefinitely for an entire batch, while preserving bounded concurrency, atomic claims, and cross-replica exclusivity.
- Cover cancellation failure, blocked cancellation, and an event channel that does not close. Ensure deadlines do not depend solely on cooperative event-channel closure.
- Persist a truthful timeout/error or degraded state and report it through usable diagnostics; distinguish scheduler leadership health from polling/fire progress.
- Preserve same-schedule overlap exclusion and execution ownership: do not release an execution fence and permit duplicate mutating work while the old execution may still be active. If work cannot safely be terminated, quarantine/account for it explicitly and expose exhausted capacity rather than spawning unbounded replacements.
- Test terminal fire reporting and origin-conversation notification where supported, including a busy/idle origin and eventual recovery. A delivery failure must not erase the durable fire result.
- Test restart/reconciliation behavior and lease/resource cleanup without leaking workers or silently losing due work.
Investigation next step
Capture a safe stacks-only goroutine snapshot from an affected process to confirm whether Scheduler.tickOnce is blocked in errgroup.Wait and locate the stuck fire/cancellation worker. Do not include session payloads, credentials, raw configuration, or private connection details in diagnostics.
Activity
fix(scheduler): keep polling behind quarantined fires
fix(scheduler): keep polling behind stuck fires without releasing own…