Learn Labs
Durability

The Durability Drill

Stopping servers under 200 checksummed objects and counting what survives

Replication settings are claims. A drill checks them: write data you can verify, break things on purpose, and count. labs/durability.py writes 200 objects (20 KB to 40 KB each), each with its SHA-256 in its S3 metadata, then checks every one.

body = os.urandom(20_000 + i * 97)c.put_object(Bucket="drill", Key=f"obj-{i:04d}", Body=body,Metadata={"sha256": hashlib.sha256(body).hexdigest()})kept by the filercheck: list, GET each, compare, then try one new writer = c.get_object(Bucket="drill", Key=key)ok = hashlib.sha256(r["Body"].read()).hexdigest() == r["Metadata"]["sha256"]

Keeping the checksum in each object's metadata matters: the metadata lives in the filer, so the check can still say which objects are unreadable when their bytes are on stopped servers. An earlier version kept all the checksums in one manifest object, and the check crashed whenever that manifest happened to be on a stopped server.

The run

docker compose -f compose_prod.yaml run --rm labs python durability.py write
wrote 200 objects, each with its checksum in metadata

docker stop volume-2
docker compose -f compose_prod.yaml run --rm labs python durability.py check
listed 200: 200 intact, 0 corrupt, 0 unreadable
new 50 KB write during the outage: accepted

docker stop volume-3
docker compose -f compose_prod.yaml run --rm labs python durability.py check
listed 200: 162 intact, 0 corrupt, 38 unreadable (76.6s)
new 50 KB write during the outage: InternalError

docker start volume-2 volume-3
docker compose -f compose_prod.yaml run --rm labs python durability.py check
listed 200: 200 intact, 0 corrupt, 0 unreadable
volume-2 stopped: writes accepted200 objects
  • intact: 200
volume-2 and volume-3 stopped: new write → InternalError, check took 76.6 s200 objects
  • intact: 162
  • unreadable: 38
both started again200 objects
  • intact: 200
  • One server down: everything readable, writes accepted. Exactly what 010 promises.
  • Two servers down: the 38 unreadable objects were in the volume whose both copies were on volume-2 and volume-3. The other 162 had at least one copy on a live server. Nothing was corrupt: unavailable isn't the same as lost.
  • The check took 76.6 s instead of about a second: each failing GET waited on timeouts and SDK retries. In an application, that's a request thread stuck for seconds per object. Set client timeouts.
  • Both back: all 200 intact. The data was never lost, only out of reach.

The drill that lied first

The first time this drill ran, two servers were stopped and the check reported 200 intact. That would have been a remarkable result for two copies on four servers. It was wrong.

youdocker composelabs containervolume-2, volume-3docker stoprun --rm labs … checkstart dependencies (depends_on)silently back upstart200 intact (wrong)

The labs service had depends_on: [filer], and the filer depended on the volume servers. docker compose run starts a service's dependencies, so every check quietly restarted the stopped volume servers before running. The fix was to remove depends_on from labs (the comment in compose_prod.yaml explains why).

What would change the numbers

ChangeTwo servers down
Replication 001 (other server, same rack) on 4 servers in 2 racksLosing one rack loses both copies of some volumes
Replication 020 (3 copies, 3 racks)All 200 readable; costs 3× storage
Erasure coding 10+4Survives any 4 lost shards, if they're spread out (next lesson)
More, smaller volume serversFewer objects per volume pair, so less unavailable per incident

Lab

  1. Run the drill as shown. Which volume held the 38 objects? Use /dir/lookup on the volume ids of a failing object's chunks.
  2. Re-run the two-server check with durability.py using a client with a 2-second read timeout and no retries. How long does it take now?
  3. Stop volume-1 and volume-4 instead. Is it a different set of objects?

On this page