Fail the batch job when recording its end fails, and reconcile orphans
CI / ci (push) Successful in 2m55s
CI / ci (pull_request) Successful in 3m1s

finishBatch now returns its error, and treats a batch that is no longer
running as one, so a batch job never ends succeeded with its batch still
running. A batch left pending or running with its job ended (process
stopped, or the final status write failed) is failed inside startBatch,
before the active batch is read, so it never blocks a manual or
replenish batch. This replaces the boot-only FailInterruptedBatches.

Document suggestions.name in the architecture schema summary.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-06 23:59:40 -04:00
co-authored by Claude Opus 5.5
parent 4e2773703b
commit a6643aaa94
8 changed files with 88 additions and 51 deletions
+2 -3
View File
@@ -132,9 +132,8 @@ type FailOrphanedSuggestionBatchesParams struct {
}
// Fails every batch still pending or running whose job is no longer queued
// or running: the process stopped before its handler recorded a result.
// Run at boot, after the job runner fails the jobs a previous process left
// running.
// or running: the process stopped, or recording the batch's end failed,
// before its handler recorded a result. Run before reading the active batch.
func (q *Queries) FailOrphanedSuggestionBatches(ctx context.Context, arg FailOrphanedSuggestionBatchesParams) (int64, error) {
result, err := q.db.ExecContext(ctx, failOrphanedSuggestionBatches, arg.UpdatedAt, arg.Kind)
if err != nil {