Build notes

A Detector That Fires Into Nobody's Inbox: Two Blind Spots That Hid a Nine Hour Outage

Batdorj Byambadorj · · 5 min read

On a Friday my price feed stopped for nine hours. I learned about it the next day, from a chart, not from an alarm.

The gap ran 07:29 to 16:45 UTC, 556 minutes. There had been a shorter warning earlier, 38 minutes, with 81 normal minutes between them. Nothing restarted. Nothing crashed.

The cause was not mine

The error log carried one routing failure 3,046 times. Dividing 556 minutes by 3,046 gives 10.95 seconds per attempt, which is my ten second retry plus the time each attempt spent before failing. The arithmetic matched the code exactly.

A second, independent measurement agreed. My staleness detector had logged 2,384 times at fifteen second intervals: 596 minutes, against 594 minutes of genuinely missing data.

So the feed had been retrying correctly, every ten seconds, for nine hours, and it recovered by itself the moment the route came back. Process uptime was unbroken. No data was lost; it was still at the source.

I looked for a bug in my own code and did not find one. That is the point where this stops being an outage story.

The real failure was the watching

Two blind spots, and either one alone would have been survivable.

The detector wrote only to a log. It noticed. It said so 2,384 times. It said so into a file that nobody opens, because the thing you open a log for is a problem you already know about. A detector whose only output is a log line is not monitoring. It is a diary.

The watchdog treated Saturday as closed. Unconditionally. Which is right for currency pairs and wrong for crypto, and crypto was the one group of symbols that could have proved the feed was dead on a weekend. The check that would have caught it was suppressed by the check that was supposed to prevent noise.

Neither blind spot is clever. Together they hid nine hours.

What replaced it

Symbols now fall into two groups, crypto and FX, each with its own state machine and its own message, so a message names which group is down and how many symbols are affected. The market-closed rule applies to FX only. A new rollover window, 20:50 to 22:30 UTC, suppresses both.

The staleness threshold went from 300 to 600 seconds. Not a guess: the daily rollover gap is six to seven minutes, measured across four days. At 300 seconds the new grouping would have produced a false alarm every single day starting Monday.

That number is the part I would have got wrong without the outage. The six minute gap had always been there. I had never seen it, because the weekend rule had been hiding it — the same rule that hid the nine hours. One blind spot was concealing the evidence needed to tune the fix for the other.

There is also a daily "alive" message at a fixed hour. It is the only way to catch a watchdog that has died itself.

Proving it without stopping anything

The obvious test is to stop the feed and watch for the message. I did not do that, and not only because the service was in use.

Instead I ran a copy of the watchdog against a second Redis port, with three tick keys driven by a small script and the threshold cut to sixty seconds. The diff against the real file was three lines: the port, a prefix on the message, and the one condition under test. Five cases passed.

  1. FX freezes. The message names FX and two symbols, and does not mention crypto.
  2. No repeat. Silence for the next sixty seconds.
  3. FX recovers. The recovery message carries a gap of five minutes, matching the real one.
  4. Crypto freezes alone. The message names crypto and one symbol.
  5. Inside the rollover window, all three symbols stale, nothing sent — while with the market-closed rule forced true, crypto still fired.

The last line is the whole thing. It is the blind spot, closed, demonstrated directly.

And stopping the service would have proved none of the five. FX and crypto would have gone down together, so the grouping — the actual new code — would have been invisible, and neither time condition would have been reached. The isolated copy was both safer and strictly more thorough. That surprised me. I had assumed the realistic test was the better one.

The gap I found while fixing the gap

Through all five cases the watchdog's own log file stayed empty. It logs errors. It does not log the messages it successfully sends.

So every confirmation in that test was made by eye, on a phone. And the question "did it fire that day?" cannot be answered from the server at all. I wrote it down as a deferred task rather than fix it in the same sitting, but it belongs in this article, because it is the same mistake in a new place: a step nobody can audit is a step that gets blamed and a step that gets excused, and neither one is knowledge.

That system is switched off now, for reasons that had nothing to do with monitoring. The rules survived it.

If you are writing a detector

  • A log line is not a notification. Decide who receives it before you write the condition.
  • Check what your noise suppression also suppresses. A rule that silences weekends silences everything that trades on weekends.
  • Tune thresholds against measured normal behaviour, not against a round number. Mine was wrong by a factor of two.
  • Send a heartbeat on a schedule. Nothing else catches a dead watchdog.
  • Log what you sent, not only what failed.
  • Prefer an isolated copy to stopping production. It is usually safer and often proves more.

Batdorj Byambadorj

Batdorj Byambadorj has been trading forex for his own account since 2007, mostly gold. He is the sole developer of fx-alert and writes every article on this site himself.

About the author

← All articles