Repository navigation
Description
Summary
A bulk workflow_dispatch (PR_NUMBER=0, or unset) processes every open pull
request inside one job, in the concurrency group g2g-<repo>-workflow_dispatch.
Event-driven runs for those same pull requests use g2g-<repo>-<number>.
GitHub concurrency is per group, and cancel-in-progress: false does not
serialise different groups, so the two can overlap.
Where they overlap on a pull request with no Gerrit change yet, both runs can
observe that absence and take the CREATE path, producing two Gerrit changes for
one pull request. ALLOW_DUPLICATES defaults to true, under which duplicate
detection logs and continues, so nothing downstream prevents it.
Not new, but now easier to reach
This predates the fork approval work: a bulk dispatch could always overlap a
pull_request_target run for a pull request it was sweeping. #418 did not
create the defect, but it added a third route — the @github2gerrit check
comment — so there is one more way to collide, and the comment is most likely
to be posted while a maintainer is actively waiting.
The same reasoning removed the scheduled sweep from #418 (see #421) and closed
the equivalent gap for single-PR dispatches, which now join the pull
request's own group via inputs.PR_NUMBER. Bulk is the remaining route that
cannot, because one job covers many pull requests.
Options
Fan out to per-pull-request jobs. An enumeration job lists open pull
requests and a matrix job processes each, so every transfer lands in the pull
request's own group and serialises against event-driven runs. This is the same
mechanism #421 needs, and doing one would largely deliver the other.
A repository-wide lock for every transfer route. Correct but costly: it
would serialise unrelated pull requests, and automation pull requests — the
overwhelming majority of traffic — would queue behind each other for no reason.
Idempotency instead of locking. #419, again shared with #421: if a run can
cheaply tell that a pull request was already transferred at its current head, a
losing racer becomes a no-op.
Fan-out plus idempotency looks like the combination worth building once, since
#419, #421 and this issue all reduce to it.
Meanwhile
Bulk dispatches are manual and occasional, so the exposure is small in
practice. Anyone triggering one on a busy repository should avoid doing so
while pull request activity is in flight.
Acceptance criteria
- A bulk run and an event-driven run for the same pull request cannot both
create a first Gerrit change - Unrelated pull requests still process in parallel
- Covered by tests rather than only documented
Found while reviewing #418.
Activity
Docs: Document the check command and its aliases
Test: Share the reusable workflow test harness
Feat: Sweep approved fork PRs on a schedule