85. Serve changed Jira issues oldest first with one poller per repository
Date: 2026-11-19
Status
Accepted
Partially supersedes ADR 0160: the row limit on the candidate pool, the random pick, the use of the per-issue lock, and both configuration keys are replaced. Its activity filter and its checkpoint clause remain.
Partially supersedes ADR 0063 for the jira-poll driver: the row limit on the candidate pool, the random pick, and the per-issue lock are replaced, together with what depends on the lock (the lock held during agent runs, the lock settings, the lock handling of fullsend poll cancel, and the expectation of several concurrent pollers). Its change detection and its authorization path remain.
Context
ADR 0063 has the jira-poll driver read the first M results of the configured query (50), drop the issues another poller has locked, and process N of the rest picked at random (5). ADR 0160 added a filter that skips issues with nothing new and kept the rest; it is not implemented yet. Under sustained load this loses requests. An issue outside the first M results is never examined, an issue inside them can lose the draw cycle after cycle, and a request that is not processed within the driver's 24-hour backfill window is dropped (see Poll coordination). ADR 0160 records starvation beyond the first M results as unmitigated.
The lock and the random pick both exist so that several pollers can work the same issues at once. The managed poll jobs do not do that: on GitHub (Scheduled workflow) and on GitLab (GitLab runtime) they run one cycle at a time per repository. The lock and the checkpoint are also named per target repository, so repositories that share a Jira project never coordinated through the lock (Multi-repo polling). ADR 0160 rejected an oldest-first order only because pollers that sort alike would race on those locks.
Two limits of the GitHub hand-off have to survive the change. The managed workflow passes the whole batch to the dispatch step as one job output and runs each dispatch record as one job of a job matrix. GitHub allows at most 256 jobs in a matrix and 1 MB in a job's outputs, and the driver commits an issue's checkpoint before the dispatch step runs, so a batch over either limit is lost whole. Nothing enforces either limit today; five issues per cycle only makes a large batch rare.
ADR 0098 and ADR 0149 set the durable direction for discovery, and no Jira adapter for it exists yet, so the jira-poll driver stays in service. This ADR aims to stop that driver from losing requests to its row limit and its random pick, with one change that leaves change detection and authorization alone.
Decision
We run one jira-poll poller per repository and serve every issue that changed within the backfill window, oldest change first, to remove the row limit, the random pick, and the lock.
- One poller per repository. The driver neither reads nor writes the lock property, and it ignores lock properties left by earlier versions. What ADR 0063 builds on the lock is withdrawn for this driver along with it: the lock held during agent runs, the lock settings, and the lock handling of
fullsend poll cancel. The managed GitHub workflow and the managed GitLab schedule already run one cycle at a time per repository. A scheduler other than the managed ones must itself keep two cycles for one repository from overlapping; overlapping cycles dispatch the same requests twice. Before it reads an issue's comments and history, the driver confirms that it can write to the issue, as the lock write did; an issue that fails yields no records, and the driver warns and carries on with the other issues. A cycle in which every issue fails this check ends in an error, as today, so a credential that cannot write shows as a failed run. How the driver confirms it is left to the implementation. - Pool. The issues that match the configured query and whose
updatedvalue falls within the driver's backfill window, read in ascending order ofupdated, with no row limit. The window is the 24 hours the driver already uses to bound a first poll and to clamp an old checkpoint; its length is fixed today and does not change. The driver sets the search's sort order itself: it drops a sort clause from the configured query and logs once that it did, and the default query no longer carries one. A candidate is active as ADR 0160 defines it, with the checkpoint returned by the search itself. That value is used only to skip idle issues; processing still reads the checkpoint from the issue, as today. - Selection. The driver processes active issues in that order until the cycle holds
tracker.jira.poll.max_dispatches_per_cycledispatch records (default 100, from 1 to 250), until on the GitHub target the next issue's records would take the serialized batch past 768 KB, or until five minutes have passed since the cycle started. The five minutes include the search and the per-issue reads: the driver checks the clock between Jira calls, and the rest of the job's time is left for committing checkpoints and dispatching. All of an issue's records go out in the same cycle, so an issue that does not fit in the room left waits and is first in line next cycle; the driver does not skip ahead to a smaller issue. An issue is always taken when the cycle holds no records yet, so a cycle can exceed the configured limit by that one issue. One issue contributes at most 250 records and, on the GitHub target, 768 KB: the driver keeps the oldest records, drops the rest with a warning, and advances the checkpoint. Today's cap of 100 events per issue, which also drops its overflow and advances the checkpoint, is unchanged. At any of these limits the driver stops reading, leaves an issue it has not finished for the next cycle, dispatches what it has completed, commits those checkpoints, and exits normally. - Bounds. 250 is GitHub's 256-job matrix limit less a small margin; it bounds a cycle and a single issue, and it applies on both targets. The default is 100 because the limit sets how fast a backlog drains, and a request that waits past the window is lost; it is twenty times today's five issues per cycle when each issue yields one record. 768 KB is three quarters of GitHub's 1 MB limit on a job's outputs, measured as GitHub measures it; the margin is there because GitHub describes its measure as approximate. It applies on the GitHub target only, since GitLab starts each pipeline separately and has no batch output. Five minutes is the managed GitHub schedule's interval and leaves ten minutes of that poll job's default 15-minute timeout. The default, the size limit, and the time limit are initial values; revisit them when a deployment needs more. This one key replaces both keys of ADR 0160, neither of which shipped.
- Unchanged. Change detection, bot filtering, authorization, the 24-hour window with its clamps and ADR 0160's one log line per cycle naming the clamped candidates, the checkpoint commit with ADR 0160's
updatedclause, and on GitLab the record-by-record dispatch with its retry of an issue whose dispatch failed.
Forge scope
Applies to the jira-poll input driver on both of its targets: GitHub, where the managed workflow turns the dispatch file into a job matrix, and GitLab, where the driver starts the agent pipelines itself. The 250 limit comes from GitHub and is applied on GitLab too, so that there is one rule. The size limit applies on GitHub only. The GitLab-native cron poller (ADR 0067) and webhook fast path (ADR 0125) are unaffected. Forgejo has no Jira poll target.
Consequences
- Every issue that changed within the window is eligible each cycle, in order, so none is skipped because of its position in the results or by chance.
- Requests are still lost when issues change faster than the driver can process them within 24 hours, when the poller is stopped for longer than that, or when one issue produces more than 250 dispatch records, or on GitHub more than 768 KB of them, in one cycle; removing the window is left to the entity-based design.
- On the GitHub target a batch is still lost whole when GitHub discards the job output, which it does when the output contains one of the poll job's secret values, or when the dispatch step fails after checkpoints are committed. A checkpoint commit that fails after the write check passed fails the poll step, and the issues whose commits succeeded lose their requests. All three exist today, and a larger batch raises what is lost; changing the hand-over is left to a separate change.
- An issue the driver cannot write to is checked again every cycle until its change leaves the window. Its requests are not served, and it takes no room from other issues.
- Any change to a waiting issue, including a comment from anyone allowed to comment, moves it to the back of the line; under a sustained backlog that can cost the issue its request.
- A rewound checkpoint can replay old requests from every issue that changed within the window, where today it reaches five issues per cycle; the per-cycle limit bounds the runs that starts. A rewind does not move an issue in the line, so an editor who keeps rewinding issues near the front can hold newer requests back. The random pick did not allow that; this ADR accepts it and extends the Jira guide's rule that Edit Issues on a polled project is part of the trust boundary.
- Each cycle reads the search rows of every issue that changed within the window, including those already handled, and no longer makes the lock calls or the per-issue pause. The number of Jira calls in a cycle is now bounded by the time limit, not by a count.
- The implementation must show that a batch at the record limit and a batch at the size limit, built from the largest records the driver can produce, are each dispatched whole, that an issue larger than the configured limit is dispatched alone and does not hold back the issues behind it, and that a cycle stopped by the time limit leaves undispatched requests eligible for the next one; the Jira guide, the config reference, and the custom poller example change with it.
- If entity-based discovery (ADR 0098, ADR 0149) fully replaces the
jira-polldriver, this change is retired with it. Until then it is needed, because the driver loses requests today.
