DEV Community

Cover image for The Log Says Alive. The File Says Dead.
AheadKit
AheadKit

Posted on

The Log Says Alive. The File Says Dead.

The pid existed. The process was dead. That is the whole run, and it took me five minutes of checking three signals to learn which one of those sentences was true.

heinrichneb lost 38 minutes to the same confusion. His worst case was a long benchmark run, 90 items, that died at item 53. No error line. No exit message. The last line in the log was the start banner, and he took the run for alive for 38 minutes. What gave it away was two timestamps: the results file last changed at 09:19, the clock said 09:57. The file had not been touched in 38 minutes and the log had said nothing the whole time, because a dead run writes nothing and a quiet run writes nothing, and the log cannot tell those two apart. Now his runs start detached, and the first thing he checks is the age of the last write, not the last line of the log.

I killed a run myself to measure how long each signal lies. Same shape as his: 90 items, about a second and a half each, one result line and one log line per item as it goes. I killed the whole group at item 53, 78 seconds in, the way a closing window kills a job. No warning, no error line, no exit message. Then I checked three signals at one, three and five minutes after the kill: the tail of the log, the age of the results file, and whether the process was still there.

Here is what each signal said, at each check:

Signal +1 minute +3 minutes +5 minutes
Log tail, last 3 lines cannot tell, last line still "item 53/90 done", no error line cannot tell, byte-identical cannot tell, byte-identical
Results file, last-write age 60 seconds old, 53 items, dead 180 seconds old, 53 items, dead 300 seconds old, 53 items, dead
Does the pid exist alive, wrong alive, wrong alive, wrong
Process state column dead, Z, defunct dead, Z, defunct dead, Z, defunct

Three numbered problems, because each signal fails in a different way.

  1. The log is the worst aliveness signal you can check. At one minute it said nothing new. At three minutes it said nothing new. At five minutes it said nothing new, and it would have said nothing new at fifty minutes, because a killed job writes no farewell. The last line, "item 53/90 done", reads like a run that is merely between items. It is also the last line of a run that will never write again, and the two look identical. There is no error line to wait for. Waiting for one is waiting for a message that was never written. The log is a record of what the run did, and a dead run did nothing after 53, so the record stops looking like a record and starts looking like a pause. A pause and a death are the same three lines.

  2. The file's last-write age is the fastest honest signal, and it has one condition. Sixty seconds of silence against a 1.5-second item pace is 40 missed writes. You do not need five minutes of watching. One missed write is already suspicious and forty is a verdict. But the age only means something if you know the pace. A job that writes every ten minutes would look dead by this test while perfectly alive, and a job that writes every second convicts itself in seconds. The signal is not "the file is old". The signal is "the file is older than the job's own rhythm". heinrichneb knew his rhythm, so 09:19 against 09:57 was enough. If you do not know the rhythm, check the rhythm first, then the age. That is the whole method: know how often the job writes, then ask when it last wrote.

  3. The pid check lied, and it lied in a way that should make you distrust the check itself. At all three samples, asking whether the pid existed got the answer "alive". The process was dead. It lingered as a zombie because its parent had not reaped it, so the pid was still there, answering present, with nothing behind it. What told the truth instantly was the state column: Z, defunct, visible at the very first check. Existence is not aliveness. A pid can exist and be dead, and the only thing that separates the two is one letter in a column most people never read. In heinrichneb's real case the pid would have vanished instead of lingering, because the window that owned the job died with it, so his check would have worked where mine lied. That is worth saying plainly: my zombie is partly an artifact of how I staged the kill, with a parent that stayed alive. The lesson holds in both directions. A pid that exists can be dead, and a pid that is gone is the only clean answer you get from that check.

So here is the claim, and it is the one you can argue with: the log is the worst aliveness signal you can check, and the file's last-write age is the best one you already have. The log tells you what happened. The file tells you when something last happened. For a run that might be dead, when is the only question that matters.

There are limits here and I would rather name them than let a reader find them. One staged kill, one job shape, a sampling cadence I chose. The hash work per item measured under a millisecond, so the 1.5-second pace came from a sleep, not from heavy compute, and I am saying that plainly because the write cadence is what the experiment measured, not the compute. The zombie wrinkle is partly my setup, as above. What carries over is the shape, not the count: a log that stops writing looks like a log that is pausing, a file that stops being written tells you the moment it stopped, and a pid that answers "here" can be a corpse.

What caught your dead run? Was it the log, the file, the pid, or something else entirely, and how long did you believe it was alive before you checked? I want the numbers. How many minutes, what signal finally told you, and what did the log say while you believed it?


P.S. Everything I write stays free — that part doesn't change. But if this one was worth something to you, you can buy me a coffee ☕ (one-time or monthly, both work). It covers the API credits and hosting behind these experiments — and honestly, it's also the nudge that gets the next one started on the evenings I'd otherwise skip it. — Salam

Buy me a coffee

AheadKit on Gumroad — Beginner-Friendly Books & Packs

Top comments (0)