Skip to content

[Feature][CI] Introduce Merge Queue to Keep the dev Baseline Stable - #11963

Merged
davidzollo merged 4 commits into
apache:devfrom
nzw921rx:feature/merge-queue
Aug 26, 2026
Merged

davidzollo merged 4 commits into
apache:devfrom
nzw921rx:feature/merge-queue

Conversation

@nzw921rx

@nzw921rx nzw921rx commented Aug 25, 2026 •

Copy link
Copy Markdown
Member

Purpose of this pull request

Background

Two recent fixes exposed deterministic compilation failures only after related changes had reached dev:

  • #11954 fixed a remaining test reference after a constant had been removed. The stale reference prevented the seatunnel-engine-server test sources from compiling.
  • #10998 updated a missed JdbcHiveIT call site after a method signature gained a parameter.

These were not flaky tests. A pull request can pass CI against the baseline available at that time and still become incompatible with dev or with another pull request merged immediately before it.

This PR introduces a GitHub Merge Queue gate for dev. GitHub validates a temporary merge_group containing the latest dev, the current pull request, and any pull requests ahead of it before updating dev.

Implementation

  1. Add a dedicated merge-group compilation gate.

    .github/workflows/merge_queue.yml listens to merge_group.checks_requested and runs two complementary Maven builds:

    # Compile the standard modules with the CI profile.
    ./mvnw -B -T 1C -Pci clean install -DskipTests \
      -D"license.skipAddThirdParty"=true -D"skip.ui"=true \
      --no-snapshot-updates
    
    # Compile the opt-in seatunnel-benchmarks module.
    ./mvnw -B -Pbenchmark -pl seatunnel-benchmarks clean install -DskipTests \
      -D"license.skipAddThirdParty"=true --no-snapshot-updates

    The first command uses the repository's ci profile to compile and install the standard modules, including the main and test sources under seatunnel-e2e, while excluding the seatunnel-dist release assembly.

    The benchmark module is opt-in and is not part of the CI reactor, so the second command compiles its main and test sources separately. It intentionally omits -am because the first command has already installed its SeaTunnel dependencies in the same runner; rebuilding those modules would only duplicate work.

    The benchmark artifact is installed only in the temporary runner's local Maven repository and is not included in the SeaTunnel distribution.

    -DskipTests skips test execution but still compiles main and test sources, so missing symbols and incompatible method signatures are detected. The UI build and third-party license generation are outside this compilation gate and are skipped. Snapshot updates are disabled to reduce unnecessary remote repository access.

    Both Maven steps use the Maven cache and retry up to three times for transient repository failures such as HTTP 403 responses or connection resets. The CI-reactor attempt timeout is 28 minutes and the focused benchmark attempt timeout is 8 minutes, with a 10-second retry delay. The job has a global 30-minute timeout and uses Temurin JDK 8 with read-only repository permissions.

    The job is named Build intentionally. dev already requires the GitHub Actions Build context. Pull-request and merge-group required checks are coupled, so reusing this context lets normal pull requests keep the existing Build validation while the merge group reports the final compilation gate.

  2. Manage the queue through .asf.yaml.

    The ASF-supported raw repository ruleset activates Merge Queue for the exact refs/heads/dev ref with these settings:

    Setting Value Reason
    Bypass actors None Phase one does not allow direct-merge bypasses, including an administrator bypass list.
    Build concurrency 5 Dispatch at most five merge-group validations concurrently. Additional entries wait in FIFO order.
    Required-check strategy ALLGREEN Every queue entry must pass the required check.
    Minimum merge group size 1 A single queued PR can proceed immediately.
    Maximum merge group size 1 Merge PRs into dev individually during phase one.
    Wait for minimum group 0 minutes Do not delay an available PR to form a batch.
    Merge method SQUASH Match the repository's enabled merge method.
    Required-check response timeout 45 minutes Allow runner scheduling and status-reporting time around the 30-minute Actions job.

    Classic protected_branches.dev settings remain in place, so the existing approval requirement and required Build check continue to apply alongside the Merge Queue ruleset.

  3. Avoid duplicate Backend runs for queue branches.

    GitHub owns the gh-readonly-queue/** temporary branch namespace. build_main.yml now ignores pushes to that namespace so a merge group runs only the dedicated compilation gate instead of also starting the complete existing Backend matrix. Ordinary branch pushes and the final push to dev continue to run the existing Build workflow.

Queue and failure behavior

  • When capacity is available, GitHub dispatches the merge-group build immediately; there is no minimum build concurrency or idle delay.
  • A failing or timed-out merge group does not update dev. GitHub removes the affected PR from the queue and leaves it open with the failure details.
  • After the PR is fixed or rebased, a writer must select Merge when ready again.
  • If an earlier queued PR fails, GitHub rebuilds later temporary groups without that PR.
  • GitHub does not publish a total queue-length limit. Entries beyond the build concurrency remain queued in FIFO order.
  • This PR itself must merge through the existing process. Once it reaches dev, ASF applies the active ruleset automatically; no separate manual Merge Queue configuration is required under normal operation.

Does this PR introduce any user-facing change?

No SeaTunnel runtime, connector, configuration, or public API behavior changes. This changes the maintainer workflow for merging pull requests into dev.

How was this patch tested?

The following checks passed locally:

./mvnw spotless:apply

git diff --check
git diff --cached --check

ruby -e 'require "yaml"; [".asf.yaml", ".github/workflows/build_main.yml", ".github/workflows/merge_queue.yml"].each { |f| YAML.load_file(f); puts "#{f}: valid YAML" }'

actionlint .github/workflows/build_main.yml .github/workflows/merge_queue.yml

asfyaml-validate --repo "$PWD"

./mvnw -B -Pbenchmark -pl seatunnel-benchmarks clean test-compile \
  -DskipTests -D"license.skipAddThirdParty"=true --no-snapshot-updates

Validation details:

  • actionlint version: 1.7.12
  • ASF validator source: apache/infrastructure-asfyaml at 32076d4b739c35460b6f67091df5e82553e251e5
  • ASF validator result: .asf.yaml is a valid .asf.yaml file.
  • Maven profile inspection confirmed that the ci profile contains the standard modules and seatunnel-e2e while excluding seatunnel-dist, and that the benchmark profile adds seatunnel-benchmarks separately.
  • The focused benchmark check used JDK 8 and successfully compiled 25 main source files and 8 test source files without executing tests.

./mvnw verify and test suites were not run. This PR changes only GitHub Actions and ASF repository-policy YAML; the Merge Queue workflow is the pre-merge compilation integration gate introduced by this change.

Check list

  • No new Jar or binary package is added to the repository or SeaTunnel distribution.
  • No connector documentation or incompatible-change documentation is required.
  • No connector registration, distribution, or E2E fixture changes are required.

@github-actions github-actions Bot added the CI&CD label Aug 25, 2026
@nzw921rx nzw921rx self-assigned this Aug 25, 2026
@goutamadwant

Copy link
Copy Markdown
Collaborator

thanks @nzw921rx merge queue approach looks great. just couple of things to confirm:

  • I see the job timeout is 30 minutes, but the configured retries can take longer, so some retries may never run ?
  • I do not see the primary merge queue build command listed in the local verification. The current green build appears to be from the existing CI workflow. Could you confirm whether the new command was tested separately? or any plan?

Could we run the exact command once and adjust the timeout based on its duration? Let me know thanks! but great plan.

@nzw921rx

Copy link
Copy Markdown
Member Author

Update: Test time results of running two build commands locally

image image

@DanielLeens DanielLeens left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What Problem Does This PR Solve?

Pain point: dev has twice gone red right after merge (#11954, #10998) even though each individual PR passed CI, because a PR's own CI runs against the baseline at the time it was tested, not against the state dev reaches after other PRs land ahead of it. Two PRs can each compile cleanly alone and still break each other's assumptions once combined.

Fix approach: Add a GitHub Merge Queue gate on refs/heads/dev (via .asf.yaml) that builds a temporary merge_group containing latest dev + the candidate PR before actually updating dev, backed by a new lightweight, compile-only workflow (merge_queue.yml) that reuses the existing required check name Build, and excludes the queue's temporary gh-readonly-queue/** branches from the existing heavyweight build_main.yml push trigger so the two don't collide.

One-sentence summary: This PR adds a pre-merge integration-compile gate for dev so that combinations of already-passing PRs can't silently break the baseline.

1. Code Change Review

1.1 Core Logic Analysis

Before this PR, the required check Build on dev is satisfied per-PR, independently, against each PR's own branch tip — there is no check that validates the combination of a PR with everything merged just ahead of it.

After this PR: a merge_group event (fired by GitHub only when a maintainer clicks "Merge when ready" and the temporary integration branch is built) runs .github/workflows/merge_queue.yml, whose single job is deliberately named Build (merge_queue.yml:29, not shown above but confirmed via grep name: Build) so it satisfies the exact same required-status-check context (.asf.yaml:80 context: Build) that dev's branch protection already requires — no separate ruleset wiring was needed for that part.

Key finding — this is architecturally the right call, and it was clearly load-bearing enough that the author fixed it correctly in the same PR: merge_group pushes a real commit to refs/heads/gh-readonly-queue/dev/... in the base repo. Since build_main.yml previously triggered on push: branches: ['**'], that legacy trigger would also fire on the queue's temporary branch, running the full existing Backend matrix under the same workflow name Build in parallel with the new compile-only gate — two different check runs racing to report the same required context name on the same commit. build_main.yml:24-25 was changed to branches-ignore: ['gh-readonly-queue/**'] to prevent exactly that collision. I traced this end-to-end and it is correct and necessary.

I also traced how the existing Build check is produced for ordinary (fork-based) PRs, since it's not obvious from this diff alone: notify_test_workflow.yml (pull_request_target) creates a synthetic Build check-run pointing at the fork's own build_main.yml run, and a 15-minute cron (update_build_status.yml) patches that check-run to reflect the fork build's real conclusion. This mechanism is completely unaffected by this PR — the new merge_queue.yml runs natively in the base repo instead (since merge_group always executes there), so it doesn't need that indirection. Both mechanisms report under the same GitHub Actions app, so app_id: 15368 continues to line up correctly for both paths (verified via gh api commits/<sha>/check-runs on a live dev HEAD and on this PR's head).

Runtime path diagram (why "Build" resolves consistently regardless of trigger source):

Normal PR (fork)                          Merge Queue (base repo)
──────────────────                        ────────────────────────
push (fork) → build_main.yml (fork)       merge_group event (apache/seatunnel)
   │                                              │
pull_request_target → notify_test_workflow.yml    merge_queue.yml (job name: Build)
   creates synthetic "Build" check                  │
   │                                          reports native "Build" check-run
cron (15m) → update_build_status.yml               │
   patches synthetic check to real conclusion       │
   │                                                │
   └──────────────► both feed required-status-check "Build" on dev, evaluated on DIFFERENT commits (PR head vs. ephemeral merge commit)

Correctness verified: -Pci deactivates the activeByDefault release profile (pom.xml:1183-1190), which is what carries seatunnel-dist — so -Pci clean install genuinely excludes seatunnel-dist while still building all default reactor modules including seatunnel-e2e (pom.xml:54, in the default <modules> list). seatunnel-benchmarks is not in the default module list (only added by -Pbenchmark, pom.xml:1206), which is exactly why the workflow needs the second, separate install -Pbenchmark -pl seatunnel-benchmarks step — the PR description's claims here check out against the real pom.xml.

1.2 Compatibility Impact

Partially incompatible (operationally, not at runtime). No SeaTunnel connector/API/runtime behavior changes — confirmed by inspection, this is 100% CI/governance config. However, it does change the maintainer merge workflow: merging into dev now requires "Merge when ready" instead of a direct squash-merge click, and adds a second, sequential ~30-minute compile gate on top of the existing per-PR Build check (which itself already has 15-minute cron-driven latency). This is an intentional, disclosed trade-off, but it is a real change to committer muscle memory and should be called out prominently to committers, not just in the PR description.

1.3 Performance/Side-Effect Analysis

max_entries_to_build: 5 with max_entries_to_merge: 1 / min_entries_to_merge: 1 keeps merge groups at size 1 (validate-and-merge-one-at-a-time), which is the safest possible phase-one configuration — a single bad PR can never poison a batch containing other people's changes, and up to 5 PRs' compiles can run concurrently. merge_method: SQUASH matches the pre-existing enabled_merge_buttons.squash: true (.asf.yaml), so no mismatch there.

Risk (see Issue 1 below): the retry budget cannot be honored by the job's own timeout. Outer job timeout-minutes: 30 (merge_queue.yml:35); step 1 alone is configured for up to 3 attempts × 28 minutes + 2×10s waits (~84+ minutes) inside that same 30-minute ceiling (merge_queue.yml:47-52); step 2 similarly budgets up to 3×8 minutes (merge_queue.yml:59-64) with whatever's left of the 30 minutes after step 1. In practice only one attempt of step 1 can realistically complete before the job is hard-killed, and step 2 may get little or no time at all if step 1 runs long. This doesn't cause a deadlock — a failed/killed merge group per the PR's own description just gets kicked out of the queue and the writer re-clicks "Merge when ready" — but it means the stated purpose of the retry ("transient repository failures such as HTTP 403 or connection resets") is largely non-functional for anything but very fast transient failures, and every real failure late in a build gets consumed silently by the outer timeout rather than retried.

1.4 Error Handling and Logging

  • Issue 1 (+1 to goutamadwant's review comment from 2026-08-26T00:22:51Z, with concrete evidence): goutamadwant already flagged "the job timeout is 30 minutes, but the configured retries can take longer, so some retries may never run." I verified this against the actual numbers (28min×3 + 8min×3 vs. a 30-minute outer ceiling) and it is correct. The author's only response (2026-08-26T01:24:13Z) was local timing screenshots, posted after all four commits on this PR (last commit 2026-08-26T01:42:18+08:00 predates the author's own reply, and no follow-up commit exists) — i.e. the timeout mismatch has not actually been fixed in code. Recommend either lowering timeout_minutes/max_attempts on both retry steps so 3 real attempts fit inside 30 minutes, or raising the outer job timeout (and re-checking it still fits under check_response_timeout_minutes: 45).
  • Failure/removal behavior is otherwise well documented in the PR body and matches standard GitHub Merge Queue semantics (failing group is dropped, later groups rebuilt without it, PR stays open with failure details) — no additional error-handling gaps found in the two workflow files themselves.

2. Code Quality Assessment

2.1 Coding Standards

Both new/changed workflow files carry the ASF license header. Non-trivial parameters (.asf.yaml ruleset) have inline comments explaining the two non-obvious choices (check_response_timeout_minutes, max_entries_to_merge: 1), and merge_queue.yml comments explain the CI-profile vs. benchmark-profile split and why -am is intentionally omitted for the benchmark step. This meets the bar for "explain why, not what" on config that isn't self-explanatory.

2.2 Test Coverage and Test Stability

No UT/E2E test code is touched — inherent to this class of change. Validation performed: local spotless:apply, YAML parse, actionlint, asfyaml-validate against the real ASF validator, and a partial local test-compile of the benchmark module only. Gap: the merge_group event itself — and therefore the two retry-wrapped Maven commands running end-to-end together under real merge-queue conditions — cannot be exercised before this PR is live, because GitHub only fires merge_group inside an actual queue attempt. There is no staged/shadow rollout (e.g., temporarily wiring the same gate to a throwaway ref first). Given bypass_actors: [], the first real exercise of this gate is a live PR merge attempt with no admin override available if something in the untested path (permissions, caching behavior on the ephemeral ref, action version behavior) doesn't work as expected. Stability rating: Risk present (not High — a single bad merge group is self-healing per the PR's own described failure semantics, and does not brick unrelated branches or other merge groups).

2.3 Documentation Updates

No contributor/committer-facing doc (e.g., a CONTRIBUTING/PR-process page) was updated to describe the new "Merge when ready" step or the added latency. Given this changes how every future PR gets merged, a short note for committers (not just the PR description) would materially reduce confusion the first time someone hits it. Not blocking, but recommended before or shortly after merge.

3. Architectural Soundness

3.1 Precise fix vs. long-term solution

This is a precisely-scoped, compile-only gate matching the two specific incidents cited (both were compile failures, not runtime/test failures) — appropriately narrow rather than gold-plating with a full Backend test matrix on every merge attempt, which the 30-minute budget likely couldn't absorb anyway. Reasonable trade-off, explicitly labeled "phase one" by the author, implying room to widen scope later.

3.2 Maintainability

Config is centralized and legible: one ruleset block in .asf.yaml, one small workflow file, and a minimal, well-justified change to the pre-existing build_main.yml trigger. Low surface area, easy to reason about.

3.3 Extensibility

max_entries_to_build, group size, and check timeout are all named parameters that can be tuned later without structural changes. Reasonable extensibility for phase two (e.g., raising max_entries_to_merge for batching, or adding bypass actors once the gate is proven stable).

3.4 Historical-version compatibility

N/A — this only targets refs/heads/dev (.asf.yaml:61), does not touch any release/maintenance branch protection, and does not alter any serialization/checkpoint/config-compatibility surface. No historical-version risk.

4. Issue Summary

Number Issue Location Severity
1 Retry budget (3× up to 28min, then 3× up to 8min) cannot fit inside the outer 30-minute job timeout, so the stated "retry transient failures" behavior is largely non-functional for anything but fast failures; flagged by another reviewer and not yet fixed in code .github/workflows/merge_queue.yml:35,47-52,59-64 Medium
2 No staged/dry-run validation is possible for the merge_group event path itself before this goes live, combined with bypass_actors: [] meaning there is no admin override if the untested path misbehaves on the first real merge attempt .asf.yaml:57, .github/workflows/merge_queue.yml Medium
3 No committer-facing documentation update describing the new "Merge when ready" step / added latency (missing) Low

5. Merge Recommendation

Conclusion: Ready to merge after fixes

Blockers (must-fix): None that are correctness- or deadlock-level. I traced the collision risk with the existing full Build workflow on queue branches and confirmed it's correctly handled (branches-ignore: gh-readonly-queue/**), and the merge_queue/bypass_actors: [] design does not create an unrecoverable deadlock — a failing merge group is self-healing per GitHub's own merge-queue semantics (it's dropped, the PR stays open, later groups rebuild without it).

Recommended fixes (non-blocking):

  • Issue 1: fix the retry/timeout budget mismatch (goutamadwant's comment is correct and still open).
  • Issue 2: confirm with ASF INFRA that the "Merge Queue" ruleset can be disabled quickly via the GitHub UI if the very first live merge attempts misbehave (since a broken gate with no bypass actors would also block the PR that would fix .asf.yaml itself), and consider watching the first several real merge-group runs closely after this lands.
  • Issue 3: add a short committer-facing note about the new merge step.

Overall this is a well-reasoned, narrowly-scoped, and carefully cross-checked change (the gh-readonly-queue exclusion in particular shows real attention to how the two workflows would otherwise collide). The remaining issues are real but non-blocking operational risks rather than functional defects — comfortable approving with the above called out for follow-up.

@nzw921rx

Copy link
Copy Markdown
Member Author

@goutamadwant @DanielLeens Thank you for the detailed review🚀

I will make the following adjustments:

  1. I agree that the retry mechanism should be removed. It cannot reliably distinguish between a temporary Maven dependency download failure and an actual compilation failure in the PR.

  2. Regarding bypass_actors, I think we should enable it initially as a fallback in case a bug in Merge Queue prevents PRs from being merged after rollout. Once Merge Queue has proven stable, we can remove the bypass permission.

  3. I will also add supplementary documentation.

@davidzollo davidzollo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1
Good job

@davidzollo
davidzollo merged commit f9b1b33 into apache:dev Aug 26, 2026
4 checks passed
@nzw921rx
nzw921rx deleted the feature/merge-queue branch August 26, 2026 04:10
zhangshenghang added a commit to zhangshenghang/seatunnel that referenced this pull request Aug 28, 2026
Merge apache/seatunnel dev (1ff72ce) into fix/sql-string-case-locale.

paimon-connector-it (8) hung in PaimonIT on the old base: the job got stuck
in CANCELING after the expected NoPrivilegeException and never finished,
which reproduces across runs on this branch but not on current dev, where
the Paimon E2E stabilization commits (apache#11608, apache#11718) landed. Syncing picks
those up (dev's latest Build run has paimon-connector-it 8/11 green), along
with the new merge queue CI (apache#11963). No functional changes beyond the
merge: the PR diff vs dev is still StringFunction + its unit test.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants