BOOKS DEEP-READ · DATABASE INTERNALS · CH 9

Failure Detection

Database Internals · Ch 9 · Alex Petrov · 2019

中文 →

What is this chapter about?

You message a colleague. Ten minutes, no reply. Are they in a meeting? Out of battery? In trouble? You can't tell. When a pile of machines works together, every machine spends every second answering that same question about the others: is that box dead, or just slow? Chapter 9 of Database Internals is about exactly that — how you decide a node has failed, and why you can never decide it correctly.

The catch: silence is not a message

People don't publish their own obituary. A crashed machine doesn't send a farewell note either — it simply stops talking. So you have to reason backwards: it's been quiet this long, it's probably gone. But how long is "this long"? Nobody knows. That is the knot the whole chapter is tied around: silence can mean death, or it can mean traffic, and from the outside the two look identical.

Why the old way is hard: every wait is the wrong wait

The obvious fix is a stopwatch: no answer in 3 seconds, call it dead. Wait too little — the other side merely hit a network hiccup, or spent two seconds tidying up memory, and you have just pronounced a living machine dead. That's a false positive, and it's expensive: the system thinks the boss is gone, elects a new one, and now two bosses are giving orders; or it starts hauling hundreds of gigabytes to other machines and finishes off a network that was only wobbling — the detector has manufactured the very outage it was watching for. Wait too long and requests keep flowing to a genuinely dead box while users sit there for thirty seconds. Too short kills the living, too long is oblivious, and there is no "just right" number in between.

The idea: stop asking "dead or alive", ask "how suspicious"

The most useful move in this chapter is to stop forcing the system to answer a yes/no question. Four ideas, each building on the last —

So how do you choose?

The real trade-off isn't "how do I judge more accurately" but "when I judge wrong, which direction hurts more": a bank transfer would rather be slow than kill a living node — two bosses will corrupt the ledger; a chat app's little green dot can be wrong all day as long as it's fast.

The honest cost: none of these methods is guaranteed correct. As long as messages can be arbitrarily late, "slow" and "dead" cannot be told apart, and every detector is just playing the odds.

One line to remember

You can never be sure whether another machine is dead or merely slow. So don't chase being right — replace the "dead / alive" yes/no question with a "how suspicious" score and let each action draw its own line according to what it costs. And accept it: sooner or later you will judge wrong, and the system has to survive that.

Want the actual algorithms, the thresholds and the diagrams? → switch to the deep read