Merge pull request #149 from Molecule-AI/fix/140-scheduler-heartbeat-pulse

fix(scheduler): independent heartbeat pulse so liveness doesn't false-stale during long fires (#140)
This commit is contained in:
Hongming Wang 2026-04-15 03:20:55 -07:00 committed by GitHub
commit a95fbf7f52

View File

@ -113,6 +113,25 @@ func (s *Scheduler) Start(ctx context.Context) {
s.lastTickAt = time.Now()
s.mu.Unlock()
// Independent heartbeat pulse (#140). Decoupled from tick completion so
// a single long fire (UIUX audits routinely take 60-120s; max fireTimeout
// is 5min) can't make /admin/liveness look stale for the whole fire window.
// tick() also calls Heartbeat at its top + each fire goroutine calls it
// entry/exit — those are kept as redundant signals but this pulse is the
// one that guarantees liveness freshness regardless of tick state.
go func() {
pulseTicker := time.NewTicker(10 * time.Second)
defer pulseTicker.Stop()
for {
select {
case <-ctx.Done():
return
case <-pulseTicker.C:
supervised.Heartbeat("scheduler")
}
}
}()
for {
select {
case <-ctx.Done():