A checksum is a short fingerprint of a stream of bytes: recompute it on the other side and you know whether the data survived the trip. When we first supported AWS S3’s additive integrity checksums, we implemented the verification inside the S3 transport adapter — the code that speaks the S3 HTTP protocol. It worked, for S3 clients. It was also a trap.
The trap: integrity was treated as a transport feature rather than a storage invariant. If an upload arrived over momo’s native binary protocol, or was forwarded between nodes during replication, it bypassed the S3 layer entirely — and with it, every integrity check. Worse, a corrupted primary node would happily replicate its corrupted bytes to secondary replicas, spreading the poison across the cluster. Verification that only runs on one of several front doors is not verification; it is a coincidence.
The Real Problem
Storage systems have many doors. S3 clients come in through HTTP; native clients come in over a binary protocol; other nodes come in during replication. If each door decides for itself whether to check integrity, then the guarantee depends on which door you used. We wanted a single, unavoidable checkpoint: no matter how bytes enter, they are verified before they are committed.
Why the Obvious Solutions Failed
“Add the check to each transport.” This is duplication with a drift problem. Each adapter re-implements the same logic against different header names and status codes, and the next protocol someone adds silently misses the check.
“Trust the primary to verify before replicating.” This makes every replica trust the primary’s memory and network card. A single faulty node then becomes a cluster-wide data-corruption event.
“Buffer the upload, verify, then store.” Correct, but it doubles memory and latency: you hold the whole object before committing it.
The Solution: Verification at the Core, in One Pass
We adopted a principle we call the Commodity Protocol Principle: transport adapters are disposable commodities, and all integrity verification belongs in the centralized storage ingest core. The core defines a protocol-agnostic seam — a small interface that any transport can implement to describe what checksums it expects and how to report a mismatch.
| |
Concretely, the server’s ingest routine asks the active connection for a checksum provider — the seam. If the connection offers expectations, the core verifies the incoming stream against them. The stream flows through a tee: one branch goes to the physical blob store, the other to streaming hash engines that compute CRC32, CRC32C, SHA-1, and SHA-256 as the bytes arrive. There is no intermediate buffer and no temporary spool file — the digest is computed in flight.
| |
| |
On a mismatch the core aborts the stream, deletes the partially written blob,
and returns a transport-appropriate error: the S3 adapter translates it into an
AWS-compliant 400 BadDigest, while native connections return the operating
system’s “bad message” code. The rollback is part of the invariant, not an
afterthought.
Replicas re-verify. The other half of the design is zero trust between nodes. When a node forwards a replicated stream, it encodes the expected checksum manifest into a small metadata header. The receiving node runs the same core ingest pipeline, extracts the manifest, and independently verifies the bytes against the original client’s fingerprint. A faulty sender is caught at the receiver before the bad data is indexed.
Tradeoff Analysis: Surface vs. Centralized Core Verification
| Dimension | Surface-Level Verification (Old) | Centralized Core Ingest (New) |
|---|---|---|
| Architectural Purity | Coupled: transport layers dictate storage logic | Decoupled: core enforces invariants; transports are adapters |
| Multi-Protocol Safety | Only S3 uploads were protected | All protocols (S3, TCP, QUIC, replicas) are protected |
| Cluster Blast Radius | Corrupt primary poisons all secondary replicas | Zero-trust: replicas independently verify every byte |
| Rollback Reliability | Ad-hoc cleanup left orphaned temp files | Guaranteed atomicity: immediate delete on mismatch |
| CPU Overhead | Single pass on the primary only | Single pass executed concurrently across replicas |
Engineering Standards
In accordance with docs/CORE/STANDARDS.md:
- ⚡ Bolt (Zero Extra Copies): the tee computes CRC32/SHA-256 digests in flight as network buffers pass directly into disk storage. No intermediate memory buffer or temporary spool file is required.
- 🛡 Sentinel (Fail-Closed Core): core ingest never trusts transport guarantees. Any digest mismatch triggers an immediate rollback and purges the blob address before it can be indexed.