CHAPTER DEEPREAD · SRE · CH 26

Data Integrity

Site Reliability Engineering · Ch 26 · Google · 2016

中文 →

What is this chapter about?

The photos on your phone, a chat thread from four years ago, the contract in your cloud drive — you simply assume they are still there, and still exactly as you left them. This chapter is about that assumption: how do you make sure that when you open it, the thing is still there and hasn't been quietly mangled? It was written by two Google engineers who run Gmail and Google Drive — systems where losing a single item makes the news.

Start with something odd

Most people think: "I keep three copies, what could go wrong?" But three copies are exactly what will not save you. If you delete a file by accident, all three copies vanish within a second — none left. Extra copies protect you from a machine dying. They do not protect you from a person or a program doing the wrong thing. The book puts it bluntly: more copies is not the same as being able to get it back.

Why this is hard

There are too many ways for data to go bad: a user slips, an operator types the wrong command, a program bug deletes in bulk, a disk quietly rots, a data center floods. Worse, the tempo differs too. Some losses happen all at once and you know immediately. Others leak a little every day, and by the time anyone notices six months later, the last clean copy has already aged out and been thrown away. No single trick covers all of that, which is why this chapter's answer is: put up three doors.

The three doors

Door one is the trash can. Deleted things aren't really deleted — they get a "deleted" tag and sit there for a while before being cleaned out. This catches the most common accident by far: the slip, and the malicious wipe after someone's account is stolen. Undoing it costs essentially nothing: remove the tag.

Door two is the old photo album in a safe. Periodically copy everything to somewhere far away, disconnected, and untouchable — Google used tape. Precisely because it is physically cut off from the live system, whatever mess you make online cannot reach it. But the question that matters isn't "did we make a copy". It's "when did we last actually take it out and use it?"

Door three is the clerk who counts the stock every day. A separate program constantly reconciles the data: does this song's record still point at a real audio file? Do the two ledgers add up? It prevents nothing. Its entire value is that it lets you find out before your users complain — because every day you find out late is a day the clean copy in the safe gets closer to expiring.

It replaces the question you were asking

The most useful line in the chapter: stop asking "do we have backups?" and start asking "when did we last restore everything, end to end, and how long did it take?" In real incidents, most teams' backup jobs report success every single day — nobody had ever tried loading one back. They find out on the day it matters. One honest cost: all three doors take real money (an extra copy is storage, daily counting is compute, rehearsing a restore takes people), and the trash can has an awkward side — the thing you thought you deleted is still lying around somewhere for a while.

Remember this

Extra copies protect you from machines failing, not from people and programs doing the wrong thing. What actually saves you is three doors: a trash can, an offline backup, and daily stock-counting. And to judge whether a team is serious, one question is enough: when did you last actually restore?

Want the mechanisms, the selection tables and the real incident numbers? → switch to the deep read