
The checkpoint that lied: a live service and 252 minutes of false alarm
The alarm that arrived every six hours
Every six hours the agent health check opened its report with the same sentence: watcher stopped for 252 minutes. On the other side, the service had been up since 13:29 with zero restarts and was writing one log line every 30 seconds. One of the two was wrong, and it was not the service.
This kind of divergence is worse than a plain failure, because it teaches you to ignore the monitor. After three cycles like that, the red line becomes wallpaper, and on the day the process actually dies nobody will look.
The tools I use on this project live in the skills store — the first one is free.
What was being measured
The verifier had a reasonable notion of “still alive”: check the age of a checkpoint file. That idea works well for incremental ingestion, because the checkpoint moves forward as work is processed. The problem is that this file is only written when a new message arrives per group. A quiet group means a stalled checkpoint, even with the process running normally.
In other words: the chosen signal measured data movement, not process existence. On a quiet Sunday the two diverge for hours, and that is exactly when nobody is watching to tell them apart.
The size of the error is clear in the number itself: 252 minutes of “stopped” against a service active since 13:29 that same day. The process had not died at any point.
# wrong criterion: age(checkpoint) answers "did new messages arrive?"
if age(checkpoint) > 180 * 60:
report("watcher stopped")
# right criterion: age(log) answers "is the process still ticking?"
if age(log) > 10 * 60:
report("watcher stopped")
The fix that separates the two questions
The fix was to change the source of the signal, not the threshold. Liveness moved to the mtime of the loop log, with a 10 minute tolerance: enough slack for a slow tick without turning delay into failure. Checkpoint age stayed in the report, but demoted to its real job, which is proving that ingestion moved, not that the process exists.
When there is no log at all, the old criterion comes back as a fallback. I preferred that over inventing an “unknown state” that nobody knows how to interpret at 3 in the morning.
The commit that closed this (f8ef32b, Nov 21 at 14:04) touched 2 files, with 81 lines added and 9 removed, and brought three new test cases: stale checkpoint with a fresh log passes, stale log fails, missing log falls back. The file’s own suite closed 6 of 6, and the gate slice closed 65 of 65.
The second defect, hidden behind the first
The next day the lower layer showed up, and it was worse: the writer of the checkpoint and the reader of the checkpoint were not using the same path. The writer’s default had stayed in the format inherited from the migration, a Windows-style directory inside the user profile, while the reader looked in the agent state directory, POSIX style. The result: one file was written in one place and the measurement looked at another. Neither was wrong; both were right about different files.
This kind of bug survives well because it does not explode. No exception, no 500, no error line in the log. Just an indicator that ages alone forever, and a report that learns to lie with the face of data.
Commit 1d4a79c (Nov 22 at 05:28) unified the path source, with 4 files and 136 lines added against 11 removed. The same package carried three smaller fixes that had also been piling up quietly:
- configuration reads with three attempts and loud logging when the file fails, because an I/O error used to return an empty dictionary and the client moved on without credentials, ending as a 401 with no apparent cause;
- sync logging once per process instead of repeating the same warning in a loop: it was around 35 thousand lines a day to say the same thing;
- scheduled recycling of the loop at 1h50, before the service manager’s hard two hour cap. Dying on timeout was recorded as a failure on every cycle and fed the monitor a “slow” that never existed.
What stays
Two rules I should have written before the first line of monitoring code.
A liveness signal has to be the artifact that always moves: the tick, the log line, the heartbeat. What only moves when there is work measures load, not existence. Confusing the two produces alarms on quiet days and silence on the day the process dies, which is the exact opposite of what you want.
And a state path has to have a single source, read literally by the same code that writes it. Duplicating the path across two modules creates two systems that only agree by luck, and luck runs out on migration day.
Next step
Current state, measured now: the watcher writing every 30 seconds, last line at 12:04, a 7 byte checkpoint updated at 08:46 today, and the checkpoint path declared in the service environment itself, which closes the door on the writer drifting back to the old address when the unit gets recreated. The next item is applying the same criterion to the other two monitors that still treat artifact age as proof of life.
Related entries
Same project, same ground — the stories connect.
Next step
If this was useful, there is more: I write about the same ground in the other projects, and the store holds the tools I use here.
Done — I will send the next article when it is out.
No spam, one-click unsubscribe. I am also here: Skills store · Portfolio