Dispatch-job list reads are time-windowed
Status
Section titled “Status”Accepted.
Approx. 2026-10 (the wire contract section; the window is configured by FC_DISPATCH_JOB_MAX_WINDOW_DAYS).
Context
Section titled “Context”The dispatch-job table is the largest operational table. It grows with every delivery, and operators and dashboards read it with filters. A list query with no time bound forces the database to consider the whole table, and the cost grows with retention. The console’s filter-option lists (distinct applications, event types) had the same problem. Bulk requeue had a second hazard: a filter that matched completed jobs would re-deliver work that had already succeeded.
Decision
Section titled “Decision”The list-shaped reads are held to a created_at window, using the existing RFC 3339 since and until parameters:
| Given | Window |
|---|---|
| neither | now minus 24 hours (defaulted: true) |
since only |
since to now |
until only |
until minus 24 hours to until (defaulted: true) |
| both | as given; until before since is 400 INVALID_WINDOW |
- A window wider than
FC_DISPATCH_JOB_MAX_WINDOW_DAYS(default 31) is400 WINDOW_TOO_LARGE. - The applied window is echoed: response headers
X-Window-From,X-Window-To,X-Window-Defaultedon the lists, and awindowobject on filter-options, the requeue preview and the requeue run. List bodies stay bare arrays for compatibility. - Reads of a single job, its attempts or its event are not windowed, since the identifier already bounds them.
- Filter-option values are read from the window, not the event-type catalogue, and cached per (tenant scope, window bucket) for 60 seconds.
- Redrive of completed jobs is explicit. Requeue by filter resets failed and pending-type jobs but resets
COMPLETEDonly when the body carriesredriveCompleted: trueandconfirmRedriveCompleted: "REDRIVE". In-flight jobs are skipped and reported, never a batch error. The preview reportscompletedCount,inFlightCountandredriveEligibleCount, and the preview’s eligible count is the value a run must confirm.
Consequences
Section titled “Consequences”Good:
- Query cost depends on the window, not on retention, and the index on
created_atis the access path. - The defaulted flag tells a client it did not choose the range, which avoids “missing” data confusion.
- Re-delivering successful work needs a deliberate two-field confirmation.
Bad:
- Clients that expected an unbounded list now see only 24 hours unless they pass
since. - Looking for an old job by anything other than its id needs the date range.
- The echoed window lives in headers on the list endpoints, which some clients ignore.
Alternatives considered
Section titled “Alternatives considered”| Alternative | Why not |
|---|---|
| Cursor pagination only | Does not bound the filtered scan, and distinct-value queries still read the table. |
| Partitioning the table by time | The platform avoids database extensions and keeps partitioning in process (see no PostgreSQL extensions). |
| Silent redrive of everything matched | Easy to double-deliver completed work. |