fix: anchor floor on re-enable; breaker on scheduled panic; propagate next-run err; reject negative interval; close phantom runs on startup
This commit is contained in:
@@ -6,6 +6,8 @@ import "context"
|
||||
// process died mid-run (crash, container restart). A fresh process has no
|
||||
// in-flight goroutines, so any persisted "running" is stale and would otherwise
|
||||
// wedge the task (the run-guard refuses to start, and accounts can't be edited).
|
||||
// It also closes any run rows left stuck in "running" (finished_at NULL), which
|
||||
// would otherwise surface as perpetually "running" in the run-log modal.
|
||||
// Returns how many task and account rows were reset.
|
||||
func (s *Store) ResetRunningOnStartup(ctx context.Context) (tasks int64, accounts int64, err error) {
|
||||
ct, err := s.Pool.Exec(ctx, `UPDATE accounts SET status='idle' WHERE status='running'`)
|
||||
@@ -18,6 +20,11 @@ func (s *Store) ResetRunningOnStartup(ctx context.Context) (tasks int64, account
|
||||
return 0, accounts, err
|
||||
}
|
||||
tasks = ct.RowsAffected()
|
||||
_, err = s.Pool.Exec(ctx,
|
||||
`UPDATE runs SET status='error', finished_at=now() WHERE finished_at IS NULL`)
|
||||
if err != nil {
|
||||
return tasks, accounts, err
|
||||
}
|
||||
return tasks, accounts, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user