In GitLab, Auto-cancel redundant pipelines is enabled, yet older pipelines on a busy branch keep running after new pushes; why?
answer
- a newer commit on the same branch
- pending is easy, running is not
- jobs are not interruptible by default
- one started job can pin the pipeline
- re-running the same commit doesn't count
basics
~20 sThe setting cancels older pipelines when a newer commit's pipeline starts on the same branch, but by default a running pipeline is spared once any job not marked interruptible has started. Jobs default to non-interruptible, so most running pipelines survive.
solid answer
~50 s**Auto-cancel redundant pipelines** cancels pending or running pipelines on a branch when a pipeline for *new changes* starts there; a second pipeline for the same commit, started with **New pipeline**, does not count. A pending job is always treated as cancellable, but once jobs run, the default behaviour cancels the pipeline only if every job that has started was marked `interruptible: true` in the configuration — and jobs default to `false`. So in a configuration that never mentions it, the first job to start pins the whole pipeline, and only pipelines that had not started anything get cancelled. The fix lives in the CI configuration: mark jobs that are safe to stop (builds, tests) as interruptible, keep deployments uninterruptible, and optionally change the pipeline-wide auto-cancel mode. Cancelling by hand is separate: Developers, Maintainers and Owners may cancel by default, and Premium and Ultimate can raise that minimum role or forbid cancellation.
go deeper
Remember that Auto-cancel redundant pipelines only cancels older pipelines on the same branch when a newer commit's pipeline starts.
Explain why jobs default to non-interruptible, how one started job pins a running pipeline, and why re-running the same commit cancels nothing.
Show how you would get real savings on busy branches — which jobs to mark interruptible, why deploys stay pinned — and who should be allowed to cancel by hand.
Weigh CI capacity saved by cancelling against the risk of interrupted side effects, and decide which defaults a platform team sets for every project.
## What the setting does **Auto-cancel redundant pipelines** is a checkbox in a GitLab project's general pipeline settings. When it is selected, GitLab automatically cancels **pending or running** pipelines on a branch as soon as a pipeline for **new changes** starts on the same branch. The idea is simple: if three commits land in a minute, only the newest needs testing. Three conditions are built into that sentence: - **Same branch (ref).** Pipelines on other branches are untouched. - **A newer commit with new changes.** Selecting **New pipeline** in the UI for the same commit creates a second pipeline but cancels nothing. - **The setting must be on.** If it is off, marking jobs as interruptible in the configuration has no effect. ## Why running pipelines survive Whether a *running* pipeline may be cancelled is decided per job, by the job-level `interruptible` keyword in the CI configuration, and its default is `false`. Under the default auto-cancel behaviour (called `conservative`): 1. A job that **has not started** is always treated as interruptible, whatever the configuration says. 2. A running pipeline is cancelled only if **no job without `interruptible: true` has started** at any point. 3. As soon as one non-interruptible job starts, **the entire pipeline is no longer interruptible**. Put together: in a project whose configuration never mentions `interruptible`, the first job to start makes the pipeline immune. Auto-cancel then only removes pipelines that were still waiting for a runner — which on a quiet runner fleet is almost none. That is the usual answer to "we turned it on and nothing changed". | Older pipeline's state when the new commit's pipeline starts | Cancelled by default? | |---|---| | Nothing started yet (all jobs pending) | Yes | | Running, and only jobs marked `interruptible: true` have started | Yes | | Running, and a job without `interruptible: true` has started | No | | The new pipeline is for the same commit (**New pipeline**) | No | | The project setting is off | No | ## Making cancellation work The changes belong in the CI configuration, which is covered in depth with the GitLab CI keywords; from the project's side the plan is: - **Mark jobs that are safe to stop** — compilation, unit tests, linting — as interruptible, typically through the configuration's defaults. - **Keep deployment jobs non-interruptible.** Cancelling a deployment half-way can leave a partial deployment; once a deploy job starts, the pipeline should finish. - **Optionally change the pipeline-wide mode.** The configuration can switch auto-cancel to cancel only the interruptible jobs, or to cancel nothing; the default is the conservative behaviour above. - **Give people a brake.** A manual, non-interruptible job early in the pipeline lets someone protect a particular run: once started, auto-cancel leaves that pipeline alone. ## Cancelling by hand: who may Auto-cancel is automatic; people can also cancel pipelines and jobs themselves. By default users with the **Developer**, **Maintainer** or **Owner** role can cancel. On **Premium and Ultimate**, the **Minimum role required to cancel a pipeline or job** setting can restrict cancellation to Maintainers and Owners, or prevent anyone from cancelling pipelines or jobs at all. Restricting it makes sense for projects where a cancelled pipeline is costly, such as release pipelines that deploy. ## Related cancellation you did not configure **Merge trains** cancel their own redundant pipelines when a merge request ahead of them fails or is removed, as part of how a train works: those pipelines tested a combination that no longer exists. And this setting is not a general concurrency control for every way a pipeline can start; it targets one case, a newer commit superseding older pipelines on the same branch.
- In GitLab, why should a deployment job usually stay non-interruptible even with auto-cancel enabled?Cancelling a deployment part-way through can leave the target half updated. Keeping the deploy job non-interruptible also means that once it starts, the whole pipeline stops being a candidate for auto-cancel, so a newer commit cannot abort a deployment that is already in progress.
- In GitLab, who can cancel a pipeline by hand, and can a project restrict that?By default anyone with the Developer, Maintainer or Owner role can cancel pipelines and jobs. On Premium and Ultimate, the **Minimum role required to cancel a pipeline or job** setting can limit cancellation to Maintainers and Owners, or prevent cancellation of any pipeline or job.
- Auto-cancel stops every older pipeline the moment a new one starts.
- GitLab jobs are interruptible unless the configuration says otherwise.
- Running New pipeline again on the same commit cancels the earlier run.
- Making deployment jobs interruptible is a free way to save CI time.
- Any project member, including Guests, can cancel pipelines by default.