← Latest papers
💻 computer science

Machine-Checked Dual-Write Recovery from a Committed Log

This paper presents a machine-checked theory in Isabelle/HOL that establishes the fundamental limits of crash recovery in dual-write systems, proving that reliable exactly-once delivery requires reading the sink's acceptance state and providing formal guarantees on the necessary fencing mechanisms and evidence lifetime.

Original authors: Andreas Andreakis

Published 2026-08-04
📖 8 min read🧠 Deep dive

Original authors: Andreas Andreakis

Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer

The Great Digital Handshake That Never Happened

Imagine you are running a busy lemonade stand. You have two jobs: first, you write down every cup sold in your official ledger (the "source"), and second, you hand a receipt to the customer (the "sink"). In the perfect world of computer science, you want to do both at the exact same time, so that if you drop your pen, you know exactly what happened. But in the real world, things happen in steps. You write "One cup" in the book, then you hand over the receipt. If a sudden thunderstorm knocks you out after you write the number but before you hand over the receipt, you have a problem. When you wake up, you look at your book, see the cup was sold, and think, "I must have forgotten to give the receipt!" So you hand over a second one. Now the customer has two receipts for one cup.

This is the world of "dual writes." It's the tricky situation where a computer system has to update two different places (like a database and a message queue) separately. If the computer crashes in the tiny gap between those two updates, it gets confused. It doesn't know if the second place already got the message or not. For years, engineers have tried to fix this with clever tricks like "idempotency keys" (special tags that say "I've seen this before") or "fencing" (a barrier that stops old messages). But until now, no one had a perfect, mathematical map of exactly when these tricks work and when they fail. This paper is that map. It uses a super-strict type of math called "formal verification" to prove, with absolute certainty, that you can't just look at your own notebook to know if the other side got the message. You have to ask the other side directly, and even then, you have to be careful about timing.

The Mystery of the Ghost Email

Let's dive into the story this paper tells. Imagine a computer program that processes orders. It does two things: it saves the order to a database, and then it sends an email confirmation. The program is designed to be "exactly-once," meaning every customer gets exactly one email, no more, no less.

One day, the program crashes. It saved the order to the database, sent the email, but died right before it could write a note in its own "checkpoint" log saying, "Okay, I sent that email." When the program wakes up, it looks at its checkpoint. It sees, "Oh, I haven't sent the email for Order #5 yet!" So, it sends the email again. The customer gets two emails. The engineers are confused: "But we checked the database! The order was there! Why did we send it twice?"

The paper says: Stop blaming the checkpoint. The checkpoint was doing its job perfectly. The problem is that the checkpoint is looking at the wrong thing. It's looking at the sender's memory, but the answer lies in the receiver's memory.

The author built a mathematical model to prove that no matter how smart your "checkpoint" or "cursor" is, if you only look at your own side of the conversation, you are doomed to make a mistake. They created two imaginary worlds that look identical to the crashed computer. In World A, the email was successfully delivered before the crash. In World B, the email was never delivered. To the crashed computer, both worlds look exactly the same. It can't tell the difference. So, if it decides to resend the email, it might accidentally duplicate it in World A. If it decides not to resend, it might lose the order in World B.

The Big Discovery: You cannot solve this by looking at your own logs. You must look at the receiver's "accepted record." Did the email provider say, "Yes, I got it"? If you can read that record, you can fix the problem.

The Zombie Problem and the Magic Fence

But wait! It gets more complicated. Imagine the email was sent, but it got stuck in a "retry queue" (like a mailbox that hasn't been opened yet). The computer crashes, wakes up, checks the receiver's record, sees the email wasn't there yet, and sends it again. Then, the old, stuck email finally arrives. Now the receiver has two emails again. This is called a "straggler" or a "zombie" message.

The paper proves that simply reading the receiver's record isn't enough if old messages can still arrive later. To fix this, the author proposes a "fence." Think of a fence like a bouncer at a club. When the computer wakes up, it doesn't just send the email; it also raises a fence. It tells the receiver, "I am now in a new generation (a new shift). If any old messages from the previous shift try to enter, the bouncer kicks them out."

This fence is a trade-off. It guarantees that you won't get duplicates, but it might mean you lose a message that was actually still on its way. The paper proves mathematically that this is the only way to be sure. You can't have both "perfect safety" and "perfect rescue" of old messages at the same time; you have to choose which frontier (which point in time) you want to be safe at.

The Double-Header Problem

There's one more twist. What if two computers wake up at the same time, both thinking they are the only ones? They both read the receiver's record, both see the same thing, and both decide to send the email. Now you have a "double-header" disaster.

The paper shows that even if you make the computers take turns in a strict order, it's not enough. One might crash halfway through its job, and the other might finish, leading to a duplicate. The solution is a "claim." Before sending anything, a computer must shout, "I am the boss now!" and lock the door. It does this in one single, atomic step: it claims the spot, reads the record, and prepares the message all at once. If another computer tries to claim the spot, it gets blocked. This ensures that only one computer is ever working on the problem at a time.

The Shelf Life of Proof

Finally, the paper asks: How long does this proof last? The "receipts" and "logs" the computers use to check their work don't last forever. If the receiver deletes old receipts after 24 hours, and the computer is down for 48 hours, the proof is gone. The computer wakes up, sees no record of the email, and sends it again. But the receiver, having deleted the old receipt, thinks it's a new email and accepts it. Now you have a duplicate.

The paper proves that "exactly-once" is only possible if you keep your evidence (the logs and receipts) longer than the longest possible crash. If you delete the evidence, you lose the guarantee. It's like trying to prove you paid your taxes by looking at a receipt you threw away last week.

The Takeaway for the Real World

This paper doesn't just say "be careful." It gives a strict, machine-checked rulebook. It tells engineers:

  1. Don't trust your own notes: Your checkpoint can't tell you if the other side got the message.
  2. Ask the receiver: You must read the receiver's "accepted record."
  3. Build a fence: If old messages can still arrive, you must block them with a generation fence.
  4. Claim your spot: If multiple computers might wake up, they must fight for a "claim" before doing any work.
  5. Keep your receipts: You must keep your logs and receipts longer than the longest possible outage.

The author used a powerful math tool called Isabelle/HOL to check every single step of their logic. They didn't just guess; they proved that without these specific steps, duplicates or lost messages are mathematically inevitable. They also proved that common shortcuts, like just "reading the sink" without a fence, or "ordering the steps" without a claim, will fail in specific, tricky scenarios.

So, the next time you get two emails for one order, don't blame the database. Blame the fact that the system didn't ask the right question, didn't build the right fence, or didn't keep the receipt long enough. This paper gives us the exact blueprint to build systems that never make that mistake again.

Drowning in papers in your field?

Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.

Try Digest →