Files
mtusi2026lab5/evidence/pipeline-faults-2026-10-02.md
T

4.3 KiB
Raw Blame History

Versioned pipeline fault injection — 2026-10-02

Hypothesis and method

A process death before or after an S3 side effect, a duplicate delivery, an expired lease, and a reordered older-version delivery should leave one logical variant set per (attachment_id, pipeline_version, name). A failed current job should replay only by an explicit audited operator action. RabbitMQ remains at-least-once: duplicate messages are expected; the durable PostgreSQL state and deterministic S3 keys make their effects idempotent.

student-tests/test_pipeline_faults.py creates synthetic 320×200 PNG uploads in the same PostgreSQL/MinIO stand as the application. It runs the real src.worker.process_message in child processes with LAB5_FAULT_POINT and LAB5_FAULT_JOB_ID; os._exit(72) terminates the child at the selected durable boundary. The parent checks database state, expires a simulated dead worker lease, runs recovery, redelivers the same logical job with the next managed attempt, and compares variant rows/checksums. The normal worker and publisher are stopped while injecting faults so their consumers cannot race the test. The test also forces a bounded temporary failure, verifies terminal failed, then uses the audited replay operation. No broker message is fabricated by the test; separate handoff/outbox tests exercise publication and confirm.

Fault points in worker code: after_claim_before_s3, after_s3_before_result_commit, after_result_commit_before_ack. Each is disabled unless both environment variables name a point and exact synthetic job ID. The test runs once on the existing educational volumes and once on a fresh, isolated Compose project. The isolated project had zero attachment_jobs and zero attachment_job_replays before the run; its volumes were removed afterward. Main lab5 volumes were preserved.

Reproduce

# Existing local stand, with worker and publisher stopped:
docker compose --env-file .env stop worker publisher
docker compose --env-file .env run --rm --build --no-deps -T worker python - < student-tests/test_pipeline_faults.py

# Fresh, isolated PostgreSQL and S3 volumes; no API port and no normal consumer:
docker compose -p mtusi2026lab5fresh --env-file .env up -d --build postgres migrate s3-bootstrap
docker compose -p mtusi2026lab5fresh --env-file .env run --rm --build --no-deps -T worker python - < student-tests/test_pipeline_faults.py
docker compose -p mtusi2026lab5fresh --env-file .env down -v

On this host Docker builds used the ignored compose.local.yaml DNS override via COMPOSE_FILE=compose.yaml:compose.local.yaml; it does not alter application behavior. The first attempt to use up --wait on the isolated project exited 1 because Docker Compose treated the completed one-shot migrate service as not running; inspection showed migrate exited 0, PostgreSQL/S3 were healthy, and both relevant tables contained zero rows before the fault test.

Observed result

Both runs returned the same anonymized raw summary (one JSON line per run):

{"after_result_commit_before_ack_duplicate":"pass","after_s3_before_result_commit":"pass","before_side_effect_lease_recovery":"pass","bounded_transient_retry_then_replay":"pass","duplicate_reorder_new_version":"pass","failed_registry_operator_replay":"pass"}

For each ready version, the test found exactly the four expected variant names (original, thumbnail, crop, optimized), a matching original SHA-256, and the expected current pipeline_version. Replaying an already ready job returned duplicate_or_stale. After a second version became ready, an older delivery left its checksums and current version unchanged; version 1 rows remained available as history. The failed-job replay wrote one audit row and used a new attempt without deleting prior outbox history. The transient retry test exhausted a two-attempt budget, recorded failed, then succeeded only after replay reset that budget.

The controlled process death checks durable boundaries, not the probability of such a crash under load. The local stand has one MinIO and one PostgreSQL instance, so this result does not prove service availability during their outage or exactly-once delivery. The broker outage/confirm boundary is tested separately; this matrix checks the worker effect boundary against real S3 and PostgreSQL.