Files
mtusi2026lab5/evidence/outbox-gap.json
T
zemiles 13bec4ab8b ЛР 5 — БПИ2303 — Лазарев — на 4
Асинхронная обработка вложений: RabbitMQ 4.1 (quorum-очереди, publisher
confirms, manual ack, DLQ), transactional outbox, отдельный worker.

- upload: оригинал в staging S3, затем одной транзакцией queued + jobs +
  outbox -> 202; API к брокеру не подключается
- relay: публикация outbox с confirm, reaper истёкших аренд, redrive
- worker: claim по строке jobs, аренда с heartbeat и fencing по
  lease_token, transform в подпроцессе с RLIMIT_AS/RLIMIT_CPU/таймаутом,
  thumbnail 256, crop 128, WebP 1280 по детерминированным ключам
- retry с backoff и jitter, постоянные/временные ошибки, реестр failed,
  ops replay (ready не повторяется), DLQ для невалидных сообщений
- janitor: очистка staging и сирот; миграция 004 с backfill вложений lab4
- тесты отказов: окна COMMIT/publish, крахи worker до/после S3 и ack,
  заморозка worker, всплеск загрузок, права брокера; evidence/ и REPORT.md
2026-11-13 16:28:18 +03:00

359 lines
7.3 KiB
JSON

{
"scenario": "outbox: COMMIT/publish gap and API crash windows",
"date_utc": "2026-11-13T13:24:33+00:00",
"steps": [
{
"t": 6.31,
"utc": "13:23:24.684",
"step": "A: relay stopped, upload 202",
"attachment_id": "41a53cd8-7e57-44b8-9c9f-12320b323750",
"outbox": [
{
"id": 105,
"attempt": "1",
"available_at": "2026-11-13T13:23:19.956776Z",
"created_at": "2026-11-13T13:23:19.956776Z",
"published_at": null,
"publish_count": 0
}
],
"queue": {
"messages": 0,
"messages_ready": 0,
"messages_unacknowledged": 0,
"consumers": 4
}
},
{
"t": 12.77,
"utc": "13:23:31.150",
"step": "A: relay started -> ready, same single job",
"attachment_id": "41a53cd8-7e57-44b8-9c9f-12320b323750",
"events": [
"enqueued",
"claimed",
"ready",
"staging_deleted"
],
"outbox": [
{
"id": 105,
"attempt": "1",
"available_at": "2026-11-13T13:23:19.956776Z",
"created_at": "2026-11-13T13:23:19.956776Z",
"published_at": "2026-11-13T13:23:26.328881Z",
"publish_count": 1
}
],
"jobs": 1,
"invariants": {
"variants": [
"crop",
"optimized",
"thumbnail"
],
"variants_ok": true,
"final_objects": 4,
"final_objects_ok": true,
"staging_left": false,
"job_status": "ready",
"attempt": 1
}
},
{
"t": 23.48,
"utc": "13:23:41.861",
"step": "B: relay crashed between COMMIT and publish -> restarted -> ready",
"attachment_id": "a2401b04-a5db-4026-adc4-01d5040fdd2c",
"relay_restart_count": [
[
0
],
[
1
]
],
"events": [
"enqueued",
"claimed",
"ready",
"staging_deleted"
],
"outbox": [
{
"id": 106,
"attempt": "1",
"available_at": "2026-11-13T13:23:38.382769Z",
"created_at": "2026-11-13T13:23:38.382769Z",
"published_at": "2026-11-13T13:23:40.445416Z",
"publish_count": 1
}
],
"invariants": {
"variants": [
"crop",
"optimized",
"thumbnail"
],
"variants_ok": true,
"final_objects": 4,
"final_objects_ok": true,
"staging_left": false,
"job_status": "ready",
"attempt": 1
}
},
{
"t": 32.98,
"utc": "13:23:51.354",
"step": "C: published twice (crash before marking) -> duplicate is a no-op",
"attachment_id": "85b3ce6d-b06a-49ab-bc80-07be18cfd5d9",
"relay_restart_count": [
1
],
"events": [
"enqueued",
"claimed",
"ready",
"staging_deleted",
"duplicate_ignored"
],
"outbox": [
{
"id": 107,
"attempt": "1",
"available_at": "2026-11-13T13:23:48.361567Z",
"created_at": "2026-11-13T13:23:48.361567Z",
"published_at": "2026-11-13T13:23:49.734047Z",
"publish_count": 1
}
],
"invariants": {
"variants": [
"crop",
"optimized",
"thumbnail"
],
"variants_ok": true,
"final_objects": 4,
"final_objects_ok": true,
"staging_left": false,
"job_status": "ready",
"attempt": 1
}
},
{
"t": 49.85,
"utc": "13:24:08.230",
"step": "D: API died after COMMIT before 202 -> work still completed",
"attachment_id": "5778567a-0d6c-4322-b0e0-31a17a40994f",
"client_saw": "missing X-Instance-Id",
"events": [
"enqueued",
"claimed",
"ready",
"staging_deleted"
],
"invariants": {
"variants": [
"crop",
"optimized",
"thumbnail"
],
"variants_ok": true,
"final_objects": 4,
"final_objects_ok": true,
"staging_left": false,
"job_status": "ready",
"attempt": 1
}
},
{
"t": 50.15,
"utc": "13:24:08.530",
"step": "E: API died after staging before COMMIT",
"attachment_id": "5b7070f4-ece0-49d9-bef4-1d704222955f",
"client_saw": "missing X-Instance-Id",
"status": "pending",
"jobs": 0,
"api_get": 404
},
{
"t": 58.86,
"utc": "13:24:17.232",
"step": "E: janitor removed pending row and staging object",
"attachment_id": "5b7070f4-ece0-49d9-bef4-1d704222955f",
"janitor_dry_run": {
"abandoned_pending": 1,
"orphan_objects": 0,
"deleted_objects": 0,
"deleted_rows": 0
},
"janitor": {
"abandoned_pending": 1,
"orphan_objects": 0,
"deleted_objects": 1,
"deleted_rows": 1,
"missing_objects": 0
},
"row_gone": true
},
{
"t": 74.96,
"utc": "13:24:33.332",
"step": "relay and api restored to .env configuration"
}
],
"results": {
"A": {
"attachment_id": "41a53cd8-7e57-44b8-9c9f-12320b323750",
"events": [
"enqueued",
"claimed",
"ready",
"staging_deleted"
],
"outbox": [
{
"id": 105,
"attempt": "1",
"available_at": "2026-11-13T13:23:19.956776Z",
"created_at": "2026-11-13T13:23:19.956776Z",
"published_at": "2026-11-13T13:23:26.328881Z",
"publish_count": 1
}
],
"jobs": 1,
"invariants": {
"variants": [
"crop",
"optimized",
"thumbnail"
],
"variants_ok": true,
"final_objects": 4,
"final_objects_ok": true,
"staging_left": false,
"job_status": "ready",
"attempt": 1
}
},
"B": {
"attachment_id": "a2401b04-a5db-4026-adc4-01d5040fdd2c",
"relay_restart_count": [
[
0
],
[
1
]
],
"events": [
"enqueued",
"claimed",
"ready",
"staging_deleted"
],
"outbox": [
{
"id": 106,
"attempt": "1",
"available_at": "2026-11-13T13:23:38.382769Z",
"created_at": "2026-11-13T13:23:38.382769Z",
"published_at": "2026-11-13T13:23:40.445416Z",
"publish_count": 1
}
],
"invariants": {
"variants": [
"crop",
"optimized",
"thumbnail"
],
"variants_ok": true,
"final_objects": 4,
"final_objects_ok": true,
"staging_left": false,
"job_status": "ready",
"attempt": 1
}
},
"C": {
"attachment_id": "85b3ce6d-b06a-49ab-bc80-07be18cfd5d9",
"relay_restart_count": [
1
],
"events": [
"enqueued",
"claimed",
"ready",
"staging_deleted",
"duplicate_ignored"
],
"outbox": [
{
"id": 107,
"attempt": "1",
"available_at": "2026-11-13T13:23:48.361567Z",
"created_at": "2026-11-13T13:23:48.361567Z",
"published_at": "2026-11-13T13:23:49.734047Z",
"publish_count": 1
}
],
"invariants": {
"variants": [
"crop",
"optimized",
"thumbnail"
],
"variants_ok": true,
"final_objects": 4,
"final_objects_ok": true,
"staging_left": false,
"job_status": "ready",
"attempt": 1
}
},
"D": {
"attachment_id": "5778567a-0d6c-4322-b0e0-31a17a40994f",
"client_saw": "missing X-Instance-Id",
"events": [
"enqueued",
"claimed",
"ready",
"staging_deleted"
],
"invariants": {
"variants": [
"crop",
"optimized",
"thumbnail"
],
"variants_ok": true,
"final_objects": 4,
"final_objects_ok": true,
"staging_left": false,
"job_status": "ready",
"attempt": 1
}
},
"E": {
"attachment_id": "5b7070f4-ece0-49d9-bef4-1d704222955f",
"janitor_dry_run": {
"abandoned_pending": 1,
"orphan_objects": 0,
"deleted_objects": 0,
"deleted_rows": 0
},
"janitor": {
"abandoned_pending": 1,
"orphan_objects": 0,
"deleted_objects": 1,
"deleted_rows": 1,
"missing_objects": 0
},
"row_gone": true
}
}
}