Skip to content
Latchkey

What Is a Merge Queue?

A merge queue serializes pull-request merges and tests each one against the latest main, so the main branch never breaks from concurrent merges.

A merge queue solves a subtle problem in busy repositories. Two pull requests can each pass CI on their own, yet break main when both merge, because neither was tested against the other. A merge queue closes that gap by testing changes against the up-to-date main, one at a time, before they land.

The problem it solves

When many PRs pass CI in parallel, each was tested against an older main. Merging them in quick succession can produce a combination no pipeline ever ran, breaking the branch. This race grows worse as a team and its merge rate scale up.

How a merge queue works

Instead of merging directly, approved PRs enter a queue. The system builds each one on top of the current main (and the queued changes ahead of it), runs CI, and merges only if it passes. Failing entries are kicked out so they cannot break the branch.

Why it matters

A merge queue guarantees that what lands on main was actually tested against the exact state it merges into. The result is a main branch that stays green even under heavy, concurrent merging, eliminating the firefighting that comes from a surprise breakage no single PR caused.

Merge queues and CI/CD

A merge queue can fan out many speculative CI runs as it validates queued entries, so it puts real demand on your runners; slow or capacity-limited runners turn the queue into a bottleneck. Ample, fast runner capacity, the kind managed platforms like Latchkey provide, keeps a busy queue flowing so merges do not stall.

When to adopt one

  • Useful once concurrent merges start breaking main.
  • Pairs with required status checks and branch protection.
  • Needs enough CI capacity to validate queued entries quickly.
  • Keeps main green for high-velocity teams.

Key takeaways

  • A merge queue serializes merges and tests each against the latest main.
  • It prevents the broken-main races that independent PRs can cause.
  • It needs ample, fast CI capacity to keep the queue flowing.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →