What does Single-Host Hot Migration and the Ten-Second Contract conclude, in numbers, about “Lossless Evolution of a Production Database: Backfill Pace, Dual-Write Verification and the Write-Freeze Window”?
Answer: Chapter 5 gives the backfill batch size, chunked-hash verification and the write freeze; a random sample of 1000 rows has only a 0.3017 chance of seeing one of 7 bad rows.
Scope of the numbers: Examples use fictional names, parameters are illustrative, and all calculations come from the book's programs, which connect to no server. Marked boxes separate published evidence, runnable Python calculations (22 programs), classical sources and the author's hypotheses.
Data table
The numbers below are printed verbatim by the chapter's Python program and can be reproduced by running it. standard-library Python onlyprinted values that match the answer: 0.3017, 1000
| chunked hashing | 360 hashes, 7 bad rows found of 7 |
| rows compared one by one after drilling | 175 |
| random sampling, chance to see one of the 7 bad rows: | |
| sample | 100 rows -> 0.0345 |
| sample | 1000 rows -> 0.3017 |
| sample | 2995 rows -> 0.6788 |
| sample 10000 rows | 0.9922 |
| rows to sample for 95 per cent at divergence rate q: | |
| q | 0.0100 -> 299 rows |
| q | 0.0010 -> 2995 rows |
| q | 0.0001 -> 29956 rows |
Show the full program
# Chapter 5. p52: proving that old and new columns agree after a dual
# write: chunked hashes against random sampling.
# Model: a fictional table of 20000 rows is written to the old and the
# new column; a seeded fault corrupts 7 rows of the new copy. Method 1
# hashes chunks of 500 rows on both sides with SHA-256 (hashlib) and
# drills into differing chunks with sub-chunks of 25 rows. Method 2
# samples n rows at random; the chance that it sees at least one of the
# d bad rows is 1 - C(N - d, n) / C(N, n). The sample size that catches
# a divergence rate q with 95 per cent confidence is ln 0.05 / ln(1 - q).
# Table sizes, fault count and chunk sizes are illustrative.
import hashlib
import math
import random
rng = random.Random(20261113)
N = 20000
BAD = 7
CHUNK = 500
SUB = 25
old = ["row-%05d|v=%d" % (i, (i * 7919) % 10007) for i in range(N)]
new = list(old)
for i in sorted(rng.sample(range(N), BAD)):
new[i] = new[i] + "|x"
def digest(rows):
h = hashlib.sha256()
for r in rows:
h.update(r.encode("ascii"))
h.update(b"\n")
return h.hexdigest()
hashes = 0
found = []
for c in range(0, N, CHUNK):
hashes += 2
if digest(old[c:c + CHUNK]) != digest(new[c:c + CHUNK]):
for s in range(c, c + CHUNK, SUB):
hashes += 2
if digest(old[s:s + SUB]) != digest(new[s:s + SUB]):
found += [i for i in range(s, s + SUB)
if old[i] != new[i]]
print("chunked hashing: %d hashes, %d bad rows found of %d" % (
hashes, len(found), BAD))
print("rows compared one by one after drilling: %d" % (
SUB * len({i // SUB for i in found})))
def p_see(n, d=BAD, total=N):
log_miss = math.fsum(math.log((total - d - k) / (total - k))
for k in range(n))
return 1.0 - math.exp(log_miss)
print("random sampling, chance to see one of the %d bad rows:" % BAD)
for n in (100, 1000, 2995, 10000):
print(" sample %5d rows -> %.4f" % (n, p_see(n)))
print("rows to sample for 95 per cent at divergence rate q:")
for q in (0.01, 0.001, 0.0001):
print(" q = %.4f -> %d rows" % (
q, math.ceil(math.log(0.05) / math.log(1.0 - q))))Single source and citation
Fan, Y. (2026). Zero-Downtime Hot Migration and Rollback on Multi-Container Single Hosts: Lossless Schema Evolution behind a Shared Tunnel and a Ten-Second Stop-the-Bleeding Contract (Version 1.0.0), Chapter 5: Lossless Evolution of a Production Database: Backfill Pace, Dual-Write Verification and the Write-Freeze Window. 5D Library. DOI pending
DOI pending · monograph page goes live after publication · 5DL-B-269 · v1.0.0 · CC-BY-NC-ND-4.0
BibTeX
@book{fan2026269,
author = {Fan, Yafu},
title = {Zero-Downtime Hot Migration and Rollback on Multi-Container Single Hosts: Lossless Schema Evolution behind a Shared Tunnel and a Ten-Second Stop-the-Bleeding Contract},
year = {2026},
publisher = {5D Library},
edition = {1.0.0},
note = {DOI pending}
}Other chapter answers in this book
- Chapter 1 · Blue-Green Is Not Zero Downtime: the Interruption Window Set by Health Checks, Failure Thresholds and Connection Drain
- Chapter 2 · Expand-Contract Migration: the Rollbackability Graph and Pushing Irreversible Steps to the End
- Chapter 3 · The Availability Markov Chain: How Repair Time Eats the Yearly Budget
- Chapter 4 · Many Containers on One Host behind a Shared Tunnel: Common-Cause Failure, Reconnect Backoff and Memory Headroom for Dual Running
- Chapter 6 · The Ten-Second Stop-the-Bleeding Contract: Convolving the Time Budget, False and Missed Alarms, and the Rot of Rollback Paths
- Chapter 7 · The Classical Sources Examined: "When a Course Runs Out, Change" and the Ship of Theseus
- Chapter 8 · The Empirical Loop: a Local Drill Checklist, the Hot-Migration Interruption Window Calculator and a Pre-Registered Test