Book Deep Read · Database Internals · Chapter 12

Anti-Entropy and Dissemination

Database Internals · Ch 12 · Alex Petrov · 2019

中文 →

What is this chapter about?

You post a message to a group chat. Most people see it instantly, one person sees it ten minutes later, and someone whose phone was off all day still finds it waiting when they switch back on. Chapter 12 of Database Internals is about how that last part — "still gets it eventually" — actually works. The previous chapter promised that the copies "will eventually match." This one asks the obvious follow-up: eventually by what means?

A strange thing first

Something you deleted days ago comes back on its own. It sounds like a haunting; the mechanics are mundane. When you deleted it, one machine happened to be offline, so its copy still says "present." When it comes back, it notices its neighbours are missing that item and helpfully hands it over — the deletion gets undone. Which is why the real design problem is not "how do we deliver the data" but "what happens to the part that never arrived".

Why the old world found this hard

The obvious answer is "make sure everybody has it before you call the write done." But that means every write waits for the slowest machine, and one machine being off means nobody can write at all — exactly the bill the previous chapter priced out. So real systems finish the write first and settle the debt later. The trouble is that the debt does not clear itself: missing one write and missing a million writes look identical from outside — the copies differ, and nobody knows where.

Three moments to settle the debt

The skeleton of the chapter is three complementary channels:

How news spreads: like a rumour

Some information — who is alive, who just joined — has to reach every machine. Telling them one by one is slow, and appointing one announcer means everything stops when the announcer dies. The chapter's answer is rumour: every machine, every second, picks a peer at random and tells it everything it knows. No centre, no single link that matters, and the spread is explosive — the number of machines in the know multiplies each round, so doubling the cluster costs only a round or two more. The price: nobody can promise exactly how many seconds it takes. You get "fast," not a guarantee.

Remember this one line

"Eventually consistent" is not something you wait for; it is something you pay for. A system has to run three repair channels — hold at write time, check at read time, audit when idle — plus a rumour-style way of spreading news. Skip them and the copies stay different forever, and the things you deleted climb back out.

Want the mechanisms, the notation and the diagrams? → Switch to the deep read