Аудит F01, F11, F12, F13: гонка janitor/replay, версия pipeline, схема сообщения, срок задания

- F01: janitor под блокировкой jobs+attachments перепроверяет условие, снимает
  staging_key и только после COMMIT удаляет объект; replay перечитывает
  staging_key отдельным запросом под блокировкой вложения (в READ COMMITTED
  соединённые колонки могли остаться из старого снимка); тест трёх порядков,
  включая чередование из аудита (учебная пауза JANITOR_PAUSE_AFTER_SELECT_SECONDS)
- F11: pipeline_version пишется при создании вложения; API не стартует с
  неподдерживаемой версией
- F12: строгий разбор по jobs.schema.json (bool, RFC 3339, traceparent,
  tracestate); 17 случаев совпадают с jsonschema Draft 2020-12
- F13: единый срок задания на чтение staging, transform и запись; после срока
  аренда не продлевается, работа прерывается как processing_timeout
This commit is contained in:
2026-11-13 20:56:05 +03:00
parent 79430df3bf
commit a71b445019
11 changed files with 683 additions and 91 deletions
+122
View File
@@ -0,0 +1,122 @@
{
"scenario": "janitor staging cleanup vs operator replay",
"date_utc": "2026-11-13T17:53:11+00:00",
"steps": [
{
"t": 18.13,
"utc": "17:52:44.531",
"step": "three failed attachments prepared",
"ids": [
"8c358e55-93cd-4c94-b009-740edea9cbfd",
"556e0db9-9aea-4c19-81bf-8bb613cb1acf",
"d575d080-f819-4f4c-9b2f-4fa30ab055d8"
]
},
{
"t": 26.93,
"utc": "17:52:53.329",
"step": "C: janitor selected z, replay committed, janitor rechecked under lock and skipped -> ready",
"attachment_id": "8c358e55-93cd-4c94-b009-740edea9cbfd",
"janitor_candidates_included_z": true,
"replay": "replayed",
"janitor_staging_skipped_changed": 1,
"janitor_staging_failed_expired": 0,
"final": "ready",
"janitor_released_staging": false,
"events": [
"enqueued",
"claimed",
"retry_scheduled",
"claimed",
"retry_scheduled",
"claimed",
"retry_scheduled",
"claimed",
"retry_scheduled",
"claimed",
"failed",
"replayed",
"claimed",
"ready",
"staging_deleted"
]
},
{
"t": 33.23,
"utc": "17:52:59.629",
"step": "A: replay first -> janitor leaves it -> ready",
"attachment_id": "556e0db9-9aea-4c19-81bf-8bb613cb1acf",
"replay": "replayed",
"staging_object_present": true,
"final": "ready"
},
{
"t": 38.81,
"utc": "17:53:05.210",
"step": "B: janitor first -> replay refused, no job without source",
"attachment_id": "d575d080-f819-4f4c-9b2f-4fa30ab055d8",
"janitor_staging_failed_expired": 1,
"replay": "refused_staging_expired",
"status": "failed",
"staging_key": null,
"staging_objects": [],
"events": [
"claimed",
"failed",
"staging_released"
]
},
{
"t": 45.41,
"utc": "17:53:11.809",
"step": "workers restored to .env configuration"
}
],
"results": {
"C_janitor_selected_then_replay": {
"attachment_id": "8c358e55-93cd-4c94-b009-740edea9cbfd",
"janitor_candidates_included_z": true,
"replay": "replayed",
"janitor_staging_skipped_changed": 1,
"janitor_staging_failed_expired": 0,
"final": "ready",
"janitor_released_staging": false,
"events": [
"enqueued",
"claimed",
"retry_scheduled",
"claimed",
"retry_scheduled",
"claimed",
"retry_scheduled",
"claimed",
"retry_scheduled",
"claimed",
"failed",
"replayed",
"claimed",
"ready",
"staging_deleted"
]
},
"A_replay_then_janitor": {
"attachment_id": "556e0db9-9aea-4c19-81bf-8bb613cb1acf",
"replay": "replayed",
"staging_object_present": true,
"final": "ready"
},
"B_janitor_then_replay": {
"attachment_id": "d575d080-f819-4f4c-9b2f-4fa30ab055d8",
"janitor_staging_failed_expired": 1,
"replay": "refused_staging_expired",
"status": "failed",
"staging_key": null,
"staging_objects": [],
"events": [
"claimed",
"failed",
"staging_released"
]
}
}
}
+113
View File
@@ -0,0 +1,113 @@
{
"date_time_format_checked": true,
"cases": [
{
"case": "valid minimal",
"jsonschema_valid": true,
"parser_valid": true,
"match": true
},
{
"case": "valid with trace context",
"jsonschema_valid": true,
"parser_valid": true,
"match": true
},
{
"case": "valid created_at with offset and fraction",
"jsonschema_valid": true,
"parser_valid": true,
"match": true
},
{
"case": "schema_version true (audit)",
"jsonschema_valid": false,
"parser_valid": false,
"match": true
},
{
"case": "created_at date only (audit)",
"jsonschema_valid": false,
"parser_valid": false,
"match": true
},
{
"case": "traceparent number (audit)",
"jsonschema_valid": false,
"parser_valid": false,
"match": true
},
{
"case": "tracestate 513 chars (audit)",
"jsonschema_valid": false,
"parser_valid": false,
"match": true
},
{
"case": "attempt true",
"jsonschema_valid": false,
"parser_valid": false,
"match": true
},
{
"case": "attempt 0",
"jsonschema_valid": false,
"parser_valid": false,
"match": true
},
{
"case": "pipeline_version 1.0",
"jsonschema_valid": true,
"parser_valid": true,
"match": true
},
{
"case": "job_id not uuid",
"jsonschema_valid": false,
"parser_valid": false,
"match": true
},
{
"case": "job_id uuid without hyphens",
"jsonschema_valid": false,
"parser_valid": false,
"match": true
},
{
"case": "extra field",
"jsonschema_valid": false,
"parser_valid": false,
"match": true
},
{
"case": "missing created_at",
"jsonschema_valid": false,
"parser_valid": false,
"match": true
},
{
"case": "wrong type",
"jsonschema_valid": false,
"parser_valid": false,
"match": true
},
{
"case": "traceparent bad version",
"jsonschema_valid": false,
"parser_valid": false,
"match": true
},
{
"case": "created_at no timezone",
"jsonschema_valid": false,
"parser_valid": false,
"match": true
}
],
"F11": {
"exit_code": 1,
"message": [
"PIPELINE_VERSION=2 is not supported (supported: 1)"
]
}
}
+108 -51
View File
@@ -1,10 +1,10 @@
{
"scenario": "worker faults, retries, failed registry, replay, DLQ",
"date_utc": "2026-11-13T13:57:15+00:00",
"date_utc": "2026-11-13T17:55:56+00:00",
"steps": [
{
"t": 7.43,
"utc": "13:55:06.128",
"t": 7.38,
"utc": "17:53:33.626",
"step": "workers recreated with fault injection",
"env": {
"WORKER_FAULT_INJECTION": "1",
@@ -13,8 +13,8 @@
}
},
{
"t": 43.87,
"utc": "13:55:42.572",
"t": 41.67,
"utc": "17:54:07.922",
"step": "crash-after-claim",
"events": [
"enqueued",
@@ -42,8 +42,8 @@
}
},
{
"t": 79.44,
"utc": "13:56:18.141",
"t": 76.8,
"utc": "17:54:43.051",
"step": "crash-after-s3-put",
"events": [
"enqueued",
@@ -71,8 +71,8 @@
}
},
{
"t": 84.1,
"utc": "13:56:22.802",
"t": 81.11,
"utc": "17:54:47.360",
"step": "crash-after-commit",
"events": [
"enqueued",
@@ -80,7 +80,7 @@
"ready",
"fault_injected",
"duplicate_ignored",
"staging_deleted"
"staging_released"
],
"invariants": {
"variants": [
@@ -97,21 +97,21 @@
}
},
{
"t": 84.24,
"utc": "13:56:22.943",
"t": 81.24,
"utc": "17:54:47.489",
"step": "worker containers after crashes (restart: unless-stopped)",
"containers": [
"/mtusi-lab5-fresh-worker-1 2 running",
"/mtusi-lab5-fresh-worker-2 1 running"
"/mtusi-lab5-worker-1 1 running",
"/mtusi-lab5-worker-2 2 running"
]
},
{
"t": 88.58,
"utc": "13:56:27.276",
"t": 85.49,
"utc": "17:54:51.743",
"step": "transient-2: retried with backoff",
"delays": [
0.941,
1.489
0.72,
1.133
],
"bounds": [
[
@@ -138,14 +138,14 @@
}
},
{
"t": 90.68,
"utc": "13:56:29.384",
"t": 87.52,
"utc": "17:54:53.769",
"step": "unexpected exception -> processing_failed -> retry -> ready",
"attachment_id": "8fbaeec2-25eb-40a3-9a33-308326d803c2",
"attachment_id": "fa2eb139-4738-48c7-afd9-0b555d748c2b",
"retry_error_codes": [
"processing_failed"
],
"seconds_to_ready": 1.24,
"seconds_to_ready": 1.27,
"events": [
"enqueued",
"claimed",
@@ -169,30 +169,30 @@
}
},
{
"t": 107.92,
"utc": "13:56:46.618",
"t": 103.32,
"utc": "17:55:09.568",
"step": "transient-always: failed after max attempts",
"error_code": "retry_exhausted",
"attempts": 5,
"content": 409,
"attach": 409,
"registry_entry": {
"attachment_id": "8120ba5a-baa5-40d6-bb68-4f6913dacbb7",
"job_id": "ecb422b5-b84b-43eb-9d5d-5d064612970d",
"attachment_id": "663cfcb8-6d2a-46e4-8f8b-09ab2733c642",
"job_id": "51eda108-3eee-46e4-96be-5bfca56c0a1c",
"error_code": "retry_exhausted",
"attempt": 5,
"max_attempts": 5,
"replay_count": 0,
"last_error": "last error: storage_unavailable injected transient error",
"updated_at": "2026-11-13T13:56:44.554290Z",
"updated_at": "2026-11-13T17:55:07.923464Z",
"replayable": true
}
},
{
"t": 111.66,
"utc": "13:56:50.361",
"t": 106.82,
"utc": "17:55:13.072",
"step": "replay -> ready; replay of ready refused",
"attachment_id": "8120ba5a-baa5-40d6-bb68-4f6913dacbb7",
"attachment_id": "663cfcb8-6d2a-46e4-8f8b-09ab2733c642",
"dry_run": "would_replay",
"replay": "replayed",
"second_replay": "refused_status_ready",
@@ -229,10 +229,10 @@
}
},
{
"t": 121.03,
"utc": "13:56:59.727",
"t": 115.6,
"utc": "17:55:21.852",
"step": "tampered staging -> failed without retries",
"attachment_id": "d098c501-ff73-4036-a5c7-60302e9e450b",
"attachment_id": "b6e7e80e-6b67-4e72-a034-e811f6f99b05",
"error_code": "staging_corrupted",
"attempts": 1,
"events": [
@@ -242,8 +242,8 @@
]
},
{
"t": 129.39,
"utc": "13:57:08.092",
"t": 126.17,
"utc": "17:55:32.419",
"step": "poison message dead-lettered and purged",
"dlq_before": 0,
"dlq_after_publish": 1,
@@ -261,14 +261,44 @@
"dlq_after_purge": 0
},
{
"t": 136.41,
"utc": "13:57:15.109",
"t": 143.17,
"utc": "17:55:49.417",
"step": "job deadline exceeded -> processing_timeout -> retry -> ready",
"attachment_id": "2fd55b68-dab6-4549-92ca-f65dbfdef0c7",
"retry_error_codes": [
"processing_timeout"
],
"events": [
"enqueued",
"claimed",
"retry_scheduled",
"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": 2
}
},
{
"t": 149.95,
"utc": "17:55:56.200",
"step": "workers restored to .env configuration"
}
],
"results": {
"crash-after-claim": {
"attachment_id": "033b0e03-a599-4110-937e-6a37c45c41e7",
"attachment_id": "e4f486a2-e2cc-4630-afbc-6eec514458b7",
"events": [
"enqueued",
"claimed",
@@ -295,7 +325,7 @@
}
},
"crash-after-s3-put": {
"attachment_id": "69421764-cfd2-48ef-8dc1-097399edb0b8",
"attachment_id": "d694f1a9-29e2-4d50-a2a4-20472eafa047",
"events": [
"enqueued",
"claimed",
@@ -322,14 +352,14 @@
}
},
"crash-after-commit": {
"attachment_id": "3a9afd6b-4e6d-46bd-8d25-bfd3b7e225a0",
"attachment_id": "1a077be1-1153-4a03-b0d2-ed65a91d1f8d",
"events": [
"enqueued",
"claimed",
"ready",
"fault_injected",
"duplicate_ignored",
"staging_deleted"
"staging_released"
],
"invariants": {
"variants": [
@@ -346,10 +376,10 @@
}
},
"transient-2": {
"attachment_id": "d4e7f4b2-faeb-449c-94a1-edd75e1b0bd3",
"attachment_id": "797a8154-56d0-421d-a46a-2fecd999c3f0",
"delays": [
0.941,
1.489
0.72,
1.133
],
"bounds": [
[
@@ -362,9 +392,9 @@
]
],
"claims_at": [
"2026-11-13T13:56:22.965351Z",
"2026-11-13T13:56:23.984778Z",
"2026-11-13T13:56:26.030551Z"
"2026-11-13T17:54:47.512858Z",
"2026-11-13T17:54:48.520912Z",
"2026-11-13T17:54:50.561214Z"
],
"invariants": {
"variants": [
@@ -381,11 +411,11 @@
}
},
"bug": {
"attachment_id": "8fbaeec2-25eb-40a3-9a33-308326d803c2",
"attachment_id": "fa2eb139-4738-48c7-afd9-0b555d748c2b",
"retry_error_codes": [
"processing_failed"
],
"seconds_to_ready": 1.24,
"seconds_to_ready": 1.27,
"events": [
"enqueued",
"claimed",
@@ -409,7 +439,7 @@
}
},
"transient-always+replay": {
"attachment_id": "8120ba5a-baa5-40d6-bb68-4f6913dacbb7",
"attachment_id": "663cfcb8-6d2a-46e4-8f8b-09ab2733c642",
"dry_run": "would_replay",
"replay": "replayed",
"second_replay": "refused_status_ready",
@@ -446,7 +476,7 @@
}
},
"staging-tamper": {
"attachment_id": "d098c501-ff73-4036-a5c7-60302e9e450b",
"attachment_id": "b6e7e80e-6b67-4e72-a034-e811f6f99b05",
"error_code": "staging_corrupted",
"attempts": 1,
"events": [
@@ -470,6 +500,33 @@
"purged_invalid"
],
"dlq_after_purge": 0
},
"deadline": {
"attachment_id": "2fd55b68-dab6-4549-92ca-f65dbfdef0c7",
"retry_error_codes": [
"processing_timeout"
],
"events": [
"enqueued",
"claimed",
"retry_scheduled",
"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": 2
}
}
}
}