fix: remove no-op SaveJobs calls, fix PendingRuns lifecycle and cap
Implements items 4-5 of the whole-project review's suggested order (docs/PROJECT_REVIEW_PLAN.md): - Drop the three SaveJobs calls in the run lifecycle (startRunLocked, executeRun, SetGlobalPause): none of them change a durable Job field, everything they touch lives on JobRuntime, which is never persisted. Retire TestStartRunLockedRollbackOnSaveFailure with the rollback it guarded, since a run can no longer fail to start this way. - Clear PendingRuns (the "queue" overlap policy's backlog) when a job is disabled or the scheduler is globally paused, so resuming or re-enabling a job no longer replays a deferred run left over from before the pause/disable. Cap it at maxPendingRuns (10) so a job whose runs take longer than its own interval stops accumulating an unbounded backlog. Surface the queued count in the details pane via DisplayStats. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
1242b22e4f
commit
263717874c
9 files changed
+147
-82
No files matched your search
+18
-3
@@ -82,14 +82,29 @@ func DisplayInvocation(job domain.Job) string {
|
||||
return job.Command + " " + strings.ReplaceAll(strings.TrimSpace(job.Arguments), "\n", " ")
|
||||
}
|
||||
|
||||
// DisplayStats returns a one-line execution-time summary for a job runtime.
|
||||
// Returns "No runs recorded" when no runs have been counted yet.
|
||||
// DisplayStats returns a one-line execution-time summary for a job runtime,
|
||||
// with the queued-run depth appended whenever the "queue" overlap policy has
|
||||
// deferred runs waiting (see maxPendingRuns). Returns "No runs recorded" when
|
||||
// no runs have been counted yet, still showing the queue depth if one exists.
|
||||
func DisplayStats(rt *domain.JobRuntime) string {
|
||||
if rt == nil || rt.RunCount == 0 {
|
||||
if rt != nil && rt.PendingRuns > 0 {
|
||||
return "No runs recorded" + pendingRunsSuffix(rt.PendingRuns)
|
||||
}
|
||||
return "No runs recorded"
|
||||
}
|
||||
return fmt.Sprintf("%d runs, %d failed, last %d ms, avg %d ms, max %d ms",
|
||||
rt.RunCount, rt.FailCount, rt.LastDurationMS, rt.AvgDurationMS, rt.MaxDurationMS)
|
||||
rt.RunCount, rt.FailCount, rt.LastDurationMS, rt.AvgDurationMS, rt.MaxDurationMS) +
|
||||
pendingRunsSuffix(rt.PendingRuns)
|
||||
}
|
||||
|
||||
// pendingRunsSuffix formats the queued-run depth for DisplayStats, empty when
|
||||
// nothing is queued.
|
||||
func pendingRunsSuffix(pending int) string {
|
||||
if pending <= 0 {
|
||||
return ""
|
||||
}
|
||||
return fmt.Sprintf(", %d queued", pending)
|
||||
}
|
||||
|
||||
// DisplayOverlapPolicy formats a job's effective overlap policy for the details
|
||||
|
||||
Reference in new issue
Block a user