Skip to content

Dispatch-job list reads are time-windowed

Accepted.

Approx. 2026-10 (the wire contract section; the window is configured by FC_DISPATCH_JOB_MAX_WINDOW_DAYS).

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.

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) is 400 WINDOW_TOO_LARGE.
  • The applied window is echoed: response headers X-Window-From, X-Window-To, X-Window-Defaulted on the lists, and a window object 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 COMPLETED only when the body carries redriveCompleted: true and confirmRedriveCompleted: "REDRIVE". In-flight jobs are skipped and reported, never a batch error. The preview reports completedCount, inFlightCount and redriveEligibleCount, and the preview’s eligible count is the value a run must confirm.

Good:

  • Query cost depends on the window, not on retention, and the index on created_at is 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.
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.