3,112 events vanished in a release INC-2355

Open2 versionsContainers · Medium · Fix · about 30 min ·Linux + Docker

Lab machine

A private Linux machine with Docker Engine. Starting takes about 30 seconds. Sessions last up to 60 minutes.
Teo Marin opened INC-2355 at 07:30SEV-2

The 02:00 release recreated every container. Docklight's queue went from 3,112 events to zero, and none of them reached a worker. A restart drill last week found no data loss.

A restart keeps a container's filesystem. Recreating it throws the old container away, writable layer and all. The drill tested the event that does not lose data.

"We tested this. Restart, no loss. What else does a release do?" (Teo)

The stack has three events waiting right now. Find out which lifecycle event loses them, then make the queue survive all of them.

Your task

Give Docklight's data directory durable storage so queued events survive a recreate and a down/up, and the worker still reads each event exactly once.

On the machine

  • compose.yaml
  • From inside the container: /depth, /enqueue, /dequeue on port 7070
  • docker compose restart, up -d --force-recreate, down and up

Timeline

Last TueRestart drill: docker compose restart. No events lost. Signed off.
02:00Release 4.2: docker compose up -d recreates every container.
02:01Queue depth 3,112 → 0.
07:30Depots report missing parcel events. INC-2355.

Done when

  1. A queued event survives docker compose up --force-recreate.
  2. Each event reaches the worker exactly once.
  3. Queued events also survive docker compose down and up.

Hints

Hint 1

A container's writable layer is thrown away when the container is recreated.

Hint 2

Find the directory Docklight writes its queue to, and what is mounted there (`docker inspect` → Mounts).

Hint 3

A named volume keeps data only for the path it is mounted at.

Hint 4

Recreate, not merely restart, in your test.

Show the solution

Docklight keeps its queue in `/var/lib/docklight`. `docker inspect` shows what is mounted: nothing, or a named volume at a different path such as `/var/lib/docklight-data`. Mount a named volume at `/var/lib/docklight` (top-level `volumes: {docklight-data: {}}` and `docklight-data:/var/lib/docklight` under the service), run `docker compose up -d`, enqueue an event, then try `docker compose up -d --force-recreate` and `docker compose down` followed by `up -d`. The event should survive both and be delivered once.