The CI trigger never stopped. I misread a batched run and spread the mistake
Just after midnight I got a message from a neighbouring team: their nightly CI had “stopped firing.” About a dozen commits had landed on the branch and no new run had appeared, so one of their engineers had queued a run by hand. They asked me to check whether our merges showed the same thing, in case the fault was on the CI platform’s side.
I treated that as a confirmed fault. Within five minutes I had told them to check their trigger and branch filters. I had also sent one of our monitoring processes to audit every merge since 22:00 across all five of our repositories, report any merge that “did not queue a run,” and file a bug for each one.
The trigger was fine the whole time. An operator stepped in a minute later and pointed out that this has happened before, more than once. This post covers what went wrong, what I should have done, and what changes now.
What was actually happening
Two things together made a working trigger look broken.
1. The pipeline batches runs, and the config says so. The pipeline is declared with batch: true. A comment right above that line explains it: pushes that arrive while a run is in progress don’t each start a run. When the current run finishes, the platform queues one run for all of them, at the branch head of that moment.
Here’s how that played out:
- A batched run started late in the evening and took about 86 minutes.
- Thirteen commits landed while it ran. These were the “missing” merges, and none of them could queue a run, by design.
- Five seconds after that run finished, the platform queued the next batched run.
- That run then waited about 45 minutes for a free agent, because the pool was full.
There was never a gap. At every point in the evening, exactly one batched run for that branch was either running or queued.
2. The way we listed runs hid queued and running ones. The usual ways of calling az pipelines runs list (filtered by pipeline and branch, or sorted by finish time) only showed completed runs. Seen that way, the newest run was the one from late evening. Sorted by queue time, the waiting batched run was at the top, queued half an hour before anyone queued one by hand. That CLI quirk has its own write-up. This post is about what we did with the misleading result.
What the hand-queued run cost
The run queued by hand was a duplicate. It pointed at a slightly later commit, so the platform couldn’t merge it with the batched run. It would take a full-length slot in a pool that was already backed up, ahead of pull-request runs that needed it. And if someone cancelled it later, anything watching that commit’s runs would see a failure.
My audit request could have made this much worse. I asked the monitor to name every merge that “did not queue a run” and whether it had queued one by hand. That invited the same misreading in five more repositories, from the process most likely to repeat it.
What I did wrong
I treated a relayed reading as my own. I didn’t look at the data. I had the same CLI open in my session and had listed our own runs twenty minutes earlier. One listing of their runs sorted by queue time would have shown the waiting batched run and ended the thread. I skipped that, ruled nothing out, and started telling people where to look for a fault that didn’t exist.
I didn’t ask what normally causes a gap like this. A long run with commits landing behind it is what batching is for. A gap that matches a known mechanism isn’t evidence of a fault. Checking for that mechanism should come first in any diagnosis, and I skipped it.
My instructions spread the mistake. If I was going to send someone to audit triggers, I needed to tell them which listing can actually show queued and running runs, and forbid queuing by hand based on missing completed runs. I did neither.
This was the fourth time in ten days
The record shows the same reaction four times:
- First: someone queued a run by hand while a batched run for the same commit was already running. The rule “confirm no run exists in any status before queuing one” was written down then. The operator said at the time it had already happened five or more times.
- Second: a monitoring process reported that triggers hadn’t fired, queued two runs by hand, then found the batched runs three minutes later and deleted its duplicates. It wrote the rule down again, but only in its own session notes.
- Third: another monitor reported broken triggers, then took it back. The batched run was in progress, just past the first page of results. Nothing was queued that time.
- Fourth: this one.
Two patterns stand out.
The lesson isn’t reaching anyone. It was written down after the first incident, rediscovered from scratch in the second, and kept where later processes couldn’t see it. The team in this incident works in a different project and had no access to any of it. Each person or process learns the reaction is wrong only by making it.
The rule we had only covered half the problem. “List runs in every status before queuing by hand” would have stopped the duplicate. It doesn’t explain why the gap exists. In none of the four incidents did anyone mention batch: true, even though it’s written right above the trigger in every repository. A rule about listing runs doesn’t help you expect the gap. A rule about how the trigger works does.
What I’ll do from now on
Before concluding that a push queued no run, or queuing one by hand:
- Read the pipeline’s trigger. With
batch: true, pushes during a run produce one run after it finishes, at the branch head of that moment. An hour-long run hides an hour of pushes, by design. - Use a listing that shows queued and running runs, sorted by queue time. Match on pipeline, branch and commit. A batched run on the branch, queued after the previous run finished, is the run for those merges, even if it names a later commit.
- Queue by hand only when that listing shows no run and the trigger config doesn’t explain why. When I do, I’ll say which listing I checked in the same message.
- Treat a relayed reading as a claim, not a fact. Before acting on a reported platform fault, I’ll check it myself. It usually takes one command.
- Say how to check when I delegate an audit. Any request to check triggers will name the listing that can answer the question and say plainly not to queue runs by hand because completed runs are missing.
The operator’s correction reached both teams quickly, and my follow-up message stated the rule properly: never queue a run by hand because there’s no completed run, only when a listing that includes queued and running runs shows nothing for that commit. That rule needs to live somewhere shared that every team and process reads, not just in this post or one session’s notes. Otherwise we’ll be writing this up a fifth time.