Apply completed lab 6 implementation

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
HellsTomato
2026-10-31 01:46:08 +03:00
co-authored by Copilot
parent 470d9d6f1e
commit f2b4d77be4
50 changed files with 7983 additions and 15 deletions
+398
View File
@@ -0,0 +1,398 @@
{
"worker_stop": {
"stopped_at": 42.4,
"started_at": 195.4,
"backlog_drained_at": 255.8,
"queue": [
{
"t": 54.3,
"depth": 4.0,
"oldest_age_s": 6.3752
},
{
"t": 64.4,
"depth": 8.0,
"oldest_age_s": 16.3758
},
{
"t": 74.4,
"depth": 13.0,
"oldest_age_s": 26.3814
},
{
"t": 85.0,
"depth": 17.0,
"oldest_age_s": 36.376
},
{
"t": 95.0,
"depth": 22.0,
"oldest_age_s": 46.3741
},
{
"t": 105.0,
"depth": 27.0,
"oldest_age_s": 56.3743
},
{
"t": 115.0,
"depth": 32.0,
"oldest_age_s": 66.3743
},
{
"t": 125.1,
"depth": 36.0,
"oldest_age_s": 76.3787
},
{
"t": 135.2,
"depth": 41.0,
"oldest_age_s": 86.376
},
{
"t": 145.2,
"depth": 46.0,
"oldest_age_s": 96.3853
},
{
"t": 155.2,
"depth": 51.0,
"oldest_age_s": 106.3763
},
{
"t": 165.3,
"depth": 56.0,
"oldest_age_s": 116.3741
},
{
"t": 175.3,
"depth": 61.0,
"oldest_age_s": 126.3746
},
{
"t": 185.4,
"depth": 66.0,
"oldest_age_s": 136.3763
},
{
"t": 195.4,
"depth": 70.0,
"oldest_age_s": 146.377
},
{
"t": 205.5,
"depth": 75.0,
"oldest_age_s": 156.3825
},
{
"t": 210.6,
"depth": 75.0,
"oldest_age_s": 156.3825
},
{
"t": 215.6,
"depth": 80.0,
"oldest_age_s": 166.3826
},
{
"t": 220.6,
"depth": 81.0,
"oldest_age_s": 169.4459
},
{
"t": 225.6,
"depth": 23.0,
"oldest_age_s": 46.3507
},
{
"t": 230.7,
"depth": 23.0,
"oldest_age_s": 46.3507
},
{
"t": 235.7,
"depth": 1.0,
"oldest_age_s": 0.4415
},
{
"t": 240.7,
"depth": 1.0,
"oldest_age_s": 0.4415
},
{
"t": 245.7,
"depth": 1.0,
"oldest_age_s": 0.0882
},
{
"t": 250.8,
"depth": 1.0,
"oldest_age_s": 0.0882
},
{
"t": 255.8,
"depth": 0.0,
"oldest_age_s": 0.0
}
]
},
"db_lock": {
"locked_at": 255.8,
"lock_s": 20,
"slow_traces": [
{
"trace_id": "1ccc84c51eb31bcc7041a55932f066fd",
"root": "POST /api/v1/chats/{id}/messages",
"server_s": 14.66,
"slowest_db_span": "INSERT messenger.messages",
"db_s": 14.64
},
{
"trace_id": "129f48bf429d60bc08ff140618078ba9",
"root": "POST /api/v1/chats/{id}/messages",
"server_s": 14.67,
"slowest_db_span": "INSERT messenger.messages",
"db_s": 14.65
},
{
"trace_id": "a50f369854f74ae199c0500f10a2443c",
"root": "POST /api/v1/chats/{id}/messages",
"server_s": 19.66,
"slowest_db_span": "INSERT messenger.messages",
"db_s": 19.65
}
],
"p99_messages_s_2m": 8.125,
"max_pending_connections_2m": 0.0,
"requests": {
"db_locked": {
"ok": 2,
"failed": 6
},
"db_recovered": {
"ok": 224
}
}
},
"telemetry_down": {
"down_s": 120,
"collector": [
{
"t": 315.7,
"collector_mem": "88.48MiB / 256MiB",
"queue_batches": 0.0,
"refused_spans": null
},
{
"t": 326.9,
"collector_mem": "88.5MiB / 256MiB",
"queue_batches": 0.0,
"refused_spans": null
},
{
"t": 338.6,
"collector_mem": "88.55MiB / 256MiB",
"queue_batches": 2.0,
"refused_spans": null
},
{
"t": 350.7,
"collector_mem": "99.13MiB / 256MiB",
"queue_batches": 9.0,
"refused_spans": null
},
{
"t": 361.9,
"collector_mem": "99.14MiB / 256MiB",
"queue_batches": 13.0,
"refused_spans": null
},
{
"t": 373.4,
"collector_mem": "98.91MiB / 256MiB",
"queue_batches": 16.0,
"refused_spans": null
},
{
"t": 384.6,
"collector_mem": "99.36MiB / 256MiB",
"queue_batches": 16.0,
"refused_spans": null
},
{
"t": 396.5,
"collector_mem": "88.94MiB / 256MiB",
"queue_batches": 20.0,
"refused_spans": null
},
{
"t": 407.7,
"collector_mem": "88.92MiB / 256MiB",
"queue_batches": 25.0,
"refused_spans": null
},
{
"t": 419.4,
"collector_mem": "89.33MiB / 256MiB",
"queue_batches": 32.0,
"refused_spans": null
},
{
"t": 430.7,
"collector_mem": "89.37MiB / 256MiB",
"queue_batches": 32.0,
"refused_spans": null
}
],
"lost_before": {
"spans": 0,
"log_records": 0
},
"lost_after": {
"spans": 0,
"log_records": 0
},
"requests": {
"telemetry_down": {
"ok": 646
},
"telemetry_recovered": {
"ok": 374
}
},
"loss_counters": {
"window_utc": [
"21:54:30",
"21:59:30"
],
"increase": {
"otelcol_exporter_sent_spans": 7643.0,
"otelcol_exporter_send_failed_spans": 7845.0,
"otelcol_exporter_sent_log_records": 1521.0,
"otelcol_exporter_send_failed_log_records": 264.0,
"otelcol_exporter_sent_metric_points": 5729.0,
"otelcol_exporter_send_failed_metric_points": 0.0,
"otelcol_receiver_refused_spans": 0.0,
"otelcol_receiver_refused_log_records": 0.0,
"otelcol_receiver_accepted_spans": 15314.0,
"otelcol_receiver_accepted_log_records": 1793.0
},
"max_queue_batches": {
"otlphttp/loki": 33,
"otlp/tempo": 10,
"otlphttp/prometheus": 0
},
"note": "lost_before/lost_after were queried with *_total names that Collector 0.115 does not export (no suffix), hence 0; corrected values from Prometheus history are here"
}
},
"alerts": {
"QueueLagHigh": [
[
147.8,
228.9
]
],
"TimeToReadyFastBurn": [
[
239.0,
259.2
]
],
"TimeToReadySlowBurn": [
[
239.0,
319.9
]
],
"WorkerAbsent": [
[
108.4,
218.8
]
]
},
"uploads": {
"accepted": 242,
"failed": 0
},
"requests": {
"warmup": {
"ok": 200
},
"worker_stopped": {
"ok": 766
},
"worker_recovering": {
"ok": 302
},
"db_locked": {
"ok": 2,
"failed": 6
},
"db_recovered": {
"ok": 224
},
"telemetry_down": {
"ok": 646
},
"telemetry_recovered": {
"ok": 374
}
},
"events": [
{
"t": 108.4,
"alert": "WorkerAbsent",
"from": "inactive",
"to": "firing"
},
{
"t": 119.4,
"alert": "QueueLagHigh",
"from": "inactive",
"to": "pending"
},
{
"t": 147.8,
"alert": "QueueLagHigh",
"from": "pending",
"to": "firing"
},
{
"t": 218.8,
"alert": "WorkerAbsent",
"from": "firing",
"to": "inactive"
},
{
"t": 228.9,
"alert": "QueueLagHigh",
"from": "firing",
"to": "inactive"
},
{
"t": 239.0,
"alert": "TimeToReadySlowBurn",
"from": "inactive",
"to": "firing"
},
{
"t": 239.0,
"alert": "TimeToReadyFastBurn",
"from": "inactive",
"to": "firing"
},
{
"t": 259.2,
"alert": "TimeToReadyFastBurn",
"from": "firing",
"to": "inactive"
},
{
"t": 319.9,
"alert": "TimeToReadySlowBurn",
"from": "firing",
"to": "inactive"
}
]
}
+29
View File
@@ -0,0 +1,29 @@
== negative
PASS variants: original/thumbnail/crop/optimized 200 with own types, garbage 400
PASS S3 down: attachments 503, messages/ready OK, no rows left; recovered after start
PASS upload replica b805dae52d5c stopped: other replica serves identical bytes
PASS: 12 attachment checks
exit
-- nginx errors:
nginx-1 | 192.168.229.1 - - [30/Oct/2026:22:27:15 +0000] "GET /api/v1/attachments/2b92fc3f-8a83-44d1-b591-48e82ddfb3cd/content HTTP/1.1" 502 157 "-" "Python-urllib/3.15" "-"
nginx-1 | 192.168.229.1 - - [30/Oct/2026:22:27:16 +0000] "GET /api/v1/attachments/2b92fc3f-8a83-44d1-b591-48e82ddfb3cd/content HTTP/1.1" 502 157 "-" "Python-urllib/3.15" "-"
nginx-1 | 2026/10/30 22:27:16 [error] 27#27: *184 no live upstreams while connecting to upstream, client: 192.168.229.1, server: localhost, request: "GET /api/v1/attachments/2b92fc3f-8a83-44d1-b591-48e82ddfb3cd/content HTTP/1.1", upstream: "http://api_backend
nginx-1 | 2026/10/30 22:27:17 [warn] 27#27: *187 a client request body is buffered to a temporary file /var/cache/nginx/client_temp/0000000028, client: 192.168.229.1, server: localhost, request: "POST /api/v1/chats/1e8097c5-0a45-4712-8757-00fcbbf68c74/attachm
nginx-1 | 2026/10/30 22:27:20 [error] 27#27: *192 upstream timed out (110: Operation timed out) while connecting to upstream, client: 192.168.229.1, server: localhost, request: "GET /api/v1/attachments/312a7fb3-1c5a-4ef9-807f-9dd8a7a4d327/content HTTP/1.1", u
nginx-1 | 2026/10/30 22:27:21 [error] 27#27: *195 upstream timed out (110: Operation timed out) while connecting to upstream, client: 192.168.229.1, server: localhost, request: "GET /api/v1/attachments/312a7fb3-1c5a-4ef9-807f-9dd8a7a4d327/content HTTP/1.1", u
== failover
{"observed_instances_before": 2, "successful_writes": 118, "failed_attempts": 0, "first_recovery_seconds": 1.847}
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
== persistence
Executing explicit persistence hook; hook output suppressed to avoid leaking secrets.
PASS: persistence preserved confirmed data and existing session. Hook scope needs operator evidence.
took 82s
== pipeline
PASS A: worker down -> 202/409/message 201 -> API+broker restart keeps job -> worker -> ready
PASS B: crash windows recovered, duplicates dropped, backoff [781, 1147, 3292, 6579] ms -> retry_exhausted -> replay -> ready, invalid_image not retried
PASS C: v2 committed first, late v1 committed as superseded, pointer stays 2, duplicates dropped
PASS invariants: 9 attachments final, 27 variant objects = DB rows, checksums equal, every done job committed once, dropped {'duplicate_done': 4, 'duplicate_in_progress': 6, 'stale_attempt': 1}
exit
== smoke
PASS: lab6 public API scenario; infrastructure and grading evidence remain separate.
api-1 Up 55 seconds (healthy);api-2 Up 55 seconds (healthy);grafana Up 5 minutes;loki Up 5 minutes (healthy);nginx Up 5 minutes;otel-collector Up 5 minutes;postgres Up 5 minutes (healthy);prometheus Up 5 minutes (healthy);rabbitmq Up 4 minutes (healthy);redis Up 5 minutes (healthy);s3 Up 5 minutes (healthy);tempo Up 5 minutes;worker Up 55 seconds (healthy);
+403
View File
@@ -0,0 +1,403 @@
{
"experiment": "lab5 pipeline: grade 3/4 scenarios and track 2 idempotency",
"lease_seconds": 6,
"scenarios": {
"A_worker_down_restart": {
"attachment_id": "37a07cde-cb88-4957-a8ce-bcea293ae9b2",
"job_id": "4e122ef2-b0ac-48de-917c-af4b3a28f3ab",
"message_id": "2a8b0831-cfa7-4d30-b865-4665aa4d7db3",
"queue_before_restart": {
"attachments.process": 1,
"attachments.dlq": 0
},
"queue_after_restart": {
"attachments.process": 1,
"attachments.dlq": 0
},
"content_while_queued": 409,
"seconds": 51.8,
"result": "PASS"
},
"B_faults": {
"fired_points": [
"crash-after-claim",
"crash-after-commit",
"crash-after-publish",
"crash-after-s3",
"crash-before-publish"
],
"audit": {
"crash-before-publish": [
[
1,
"accepted",
""
],
[
1,
"claimed",
""
],
[
1,
"done",
"current"
]
],
"crash-after-publish": [
[
1,
"accepted",
""
],
[
1,
"claimed",
""
],
[
1,
"done",
"current"
],
[
1,
"duplicate_done",
""
]
],
"crash-after-claim": [
[
1,
"accepted",
""
],
[
1,
"claimed",
""
],
[
1,
"duplicate_in_progress",
""
],
[
1,
"lease_expired",
"next_attempt=2 delay_ms=0 error=lease expired"
],
[
2,
"claimed",
""
],
[
2,
"done",
"current"
]
],
"crash-after-s3": [
[
1,
"accepted",
""
],
[
1,
"claimed",
""
],
[
1,
"duplicate_in_progress",
""
],
[
1,
"lease_expired",
"next_attempt=2 delay_ms=0 error=lease expired"
],
[
2,
"claimed",
""
],
[
2,
"duplicate_in_progress",
""
],
[
2,
"lease_expired",
"next_attempt=3 delay_ms=0 error=lease expired"
],
[
3,
"claimed",
""
],
[
3,
"done",
"current"
]
],
"crash-after-commit": [
[
1,
"accepted",
""
],
[
1,
"claimed",
""
],
[
1,
"done",
"current"
],
[
1,
"duplicate_done",
""
]
]
},
"transient": {
"job_id": "3dc87e66-b861-4cab-915b-55de7bc47eb4",
"backoff_delays_ms": [
781,
1147,
3292,
6579
],
"audit": [
[
1,
"accepted",
""
],
[
1,
"claimed",
""
],
[
1,
"retry_scheduled",
"next_attempt=2 delay_ms=781 error=java.io.IOException: injected transient fault"
],
[
1,
"stale_attempt",
""
],
[
2,
"claimed",
""
],
[
2,
"retry_scheduled",
"next_attempt=3 delay_ms=1147 error=java.io.IOException: injected transient fault"
],
[
3,
"claimed",
""
],
[
3,
"retry_scheduled",
"next_attempt=4 delay_ms=3292 error=java.io.IOException: injected transient fault"
],
[
4,
"claimed",
""
],
[
4,
"retry_scheduled",
"next_attempt=5 delay_ms=6579 error=java.io.IOException: injected transient fault"
],
[
5,
"claimed",
""
],
[
5,
"failed",
"retry_exhausted"
],
[
6,
"replayed",
"operator"
],
[
6,
"claimed",
""
],
[
6,
"done",
"current"
]
],
"replay": {
"3dc87e66-b861-4cab-915b-55de7bc47eb4": "queued as attempt 6",
"d43dec57-ac25-4db7-b151-90bd90c22e03": "skipped: job is done"
},
"replay_again": {
"3dc87e66-b861-4cab-915b-55de7bc47eb4": "skipped: job is done"
}
},
"invalid_image": {
"job_id": "3a58faf4-4e63-43f1-9bd7-f4c003954ba3",
"audit": [
[
1,
"accepted",
""
],
[
1,
"claimed",
""
],
[
1,
"failed",
"invalid_image"
]
]
},
"seconds": 74.2,
"result": "PASS"
},
"C_stale_version": {
"attachment_id": "c2191b04-2593-43c2-bf73-0c17d83677a5",
"v1_job": "8160092d-cf5c-45b4-9f2b-cda2342f88d9",
"v2_job": "d59b03be-12ea-4049-b9e3-dc206c0468e0",
"reprocess": {
"jobs_created": 1
},
"v1_audit": [
[
1,
"accepted",
""
],
[
1,
"claimed",
""
],
[
1,
"duplicate_in_progress",
""
],
[
1,
"duplicate_in_progress",
""
],
[
1,
"duplicate_in_progress",
""
],
[
1,
"done",
"superseded"
],
[
1,
"duplicate_done",
""
],
[
1,
"duplicate_done",
""
]
],
"v2_audit": [
[
1,
"claimed",
""
],
[
1,
"done",
"current"
]
],
"pointer": 2,
"seconds": 46.0,
"result": "PASS"
}
},
"invariants": {
"I1_no_lost_accepted_work": {
"caa80c9b-40c3-4e75-ae16-3da8483608d5": "failed",
"0e715743-76d1-4e60-8dee-28657b6c19ac": "ready",
"c2191b04-2593-43c2-bf73-0c17d83677a5": "ready",
"37a07cde-cb88-4957-a8ce-bcea293ae9b2": "ready",
"93bd6905-8ece-4da6-898f-621b2f169bbb": "ready",
"7afa8d8b-3247-459b-a836-5abe12c18147": "ready",
"c1b37b43-00c4-4c19-9d5d-1de1bde7bce1": "ready",
"30418140-0300-4f0c-bcea-919188af4ee5": "ready",
"40d6632d-8c50-4bbb-80b8-6deefaab7e50": "ready"
},
"I2_variants_per_effect_key": {
"c2191b04-2593-43c2-bf73-0c17d83677a5/v1": 3,
"0e715743-76d1-4e60-8dee-28657b6c19ac/v1": 3,
"40d6632d-8c50-4bbb-80b8-6deefaab7e50/v1": 3,
"37a07cde-cb88-4957-a8ce-bcea293ae9b2/v1": 3,
"c2191b04-2593-43c2-bf73-0c17d83677a5/v2": 3,
"30418140-0300-4f0c-bcea-919188af4ee5/v1": 3,
"c1b37b43-00c4-4c19-9d5d-1de1bde7bce1/v1": 3,
"93bd6905-8ece-4da6-898f-621b2f169bbb/v1": 3,
"7afa8d8b-3247-459b-a836-5abe12c18147/v1": 3
},
"I2_s3_variant_objects": 27,
"I3_checksums_equal": 27,
"I4_commits_per_job": [
0,
1,
1,
1,
1,
1,
1,
1,
1,
1
],
"I5_staging": {
"staging_left_for_run": [
"caa80c9b-40c3-4e75-ae16-3da8483608d5"
]
},
"duplicates_dropped": {
"duplicate_done": 4,
"duplicate_in_progress": 6,
"stale_attempt": 1
},
"result": "PASS"
},
"seconds_total": 216.7
}
File diff suppressed because it is too large Load Diff
+143
View File
@@ -0,0 +1,143 @@
{
"controlled_request": {
"trace_id": "8461974b8914ca8c5a34e08e3e4b7750",
"request_id": "94712dff-a1c8-4f1c-adb1-ca79a23f1787",
"spans": [
{
"service": "messenger-api",
"kind": "SERVER",
"name": "POST /api/v1/chats/{id}/messages",
"ms": 13.3,
"status": "UNSET"
},
{
"service": "messenger-api",
"kind": "CLIENT",
"name": "GET",
"ms": 0.6,
"status": "UNSET"
},
{
"service": "messenger-api",
"kind": "CLIENT",
"name": "SELECT messenger",
"ms": 0.3,
"status": "UNSET"
},
{
"service": "messenger-api",
"kind": "CLIENT",
"name": "INSERT messenger.idempotency_keys",
"ms": 0.6,
"status": "UNSET"
},
{
"service": "messenger-api",
"kind": "CLIENT",
"name": "INSERT messenger.messages",
"ms": 1.1,
"status": "UNSET"
}
],
"logs": [
{
"ts": "1793396891770396773",
"line": "POST /api/v1/chats/{id}/messages -> 201 in 12 ms",
"event": "http.request",
"severity_text": "INFO",
"trace_id": "8461974b8914ca8c5a34e08e3e4b7750",
"span_id": "7d5500ec633602f8",
"request_id": "94712dff-a1c8-4f1c-adb1-ca79a23f1787",
"http_route": "/api/v1/chats/{id}/messages",
"http_response_status_code": "201"
}
]
},
"upload_with_retry": {
"trace_id": "0a4cc3901adee435a0471add15968a77",
"attachment_status": "ready",
"chain": [
{
"service": "messenger-api",
"kind": "SERVER",
"name": "POST /api/v1/chats/{id}/attachments",
"parent": null,
"ms": 57.2,
"status": "UNSET"
},
{
"service": "messenger-api",
"kind": "PRODUCER",
"name": "attachments publish",
"parent": "POST /api/v1/chats/{id}/attachments",
"ms": 1.9,
"status": "UNSET"
},
{
"service": "messenger-worker",
"kind": "CONSUMER",
"name": "attachments.process process",
"parent": "attachments publish",
"ms": 116.2,
"status": "STATUS_CODE_ERROR",
"job.attempt": "1",
"job.outcome": "retry"
},
{
"service": "messenger-worker",
"kind": "PRODUCER",
"name": "attachments publish",
"parent": "attachments.process process",
"ms": 8.1,
"status": "UNSET"
},
{
"service": "messenger-worker",
"kind": "CONSUMER",
"name": "attachments.process process",
"parent": "attachments publish",
"ms": 163.6,
"status": "UNSET",
"job.attempt": "2",
"job.outcome": "done"
}
],
"worker_effect_spans": [
"INSERT messenger.attachment_variants",
"INSERT messenger.job_audit",
"INSERT messenger.outbox",
"S3.CopyObject",
"S3.DeleteObject",
"S3.GetObject",
"S3.HeadObject",
"S3.PutObject",
"UPDATE messenger.attachments",
"UPDATE messenger.jobs"
],
"logs": [
{
"event": "http.request",
"severity_text": "INFO",
"line": "POST /api/v1/chats/{id}/attachments -> 202 in 54 ms",
"span_id": "e0f77957eeff84f5"
},
{
"event": "job.done",
"severity_text": "INFO",
"line": "job 70d78d27-d995-4c90-a747-330481717138 attempt 2 done: attachment 4ecc20d9-4f98-4a39-82c1-4d3a2710e381 v1",
"span_id": "3c3f5c2b536d5828"
},
{
"event": "job.retry",
"severity_text": "WARN",
"line": "job 70d78d27-d995-4c90-a747-330481717138 attempt 1 failed: java.io.IOException: injected transient fault, attempt 1 only",
"span_id": "1e612c3539aa180c"
}
]
},
"leak_check": {
"message_text_in_logs_or_traces": 0,
"session_token_in_logs_or_traces": 0,
"message_text_in_loki_all_logs": 0
}
}
+39
View File
@@ -0,0 +1,39 @@
{
"uploads": 30,
"p50_s": 0.67,
"p95_s": 1.03,
"max_s": 1.15,
"over_10s": 0,
"all_s": [
0.64,
0.65,
0.65,
0.65,
0.65,
0.65,
0.65,
0.65,
0.65,
0.66,
0.66,
0.66,
0.67,
0.67,
0.67,
0.67,
0.67,
0.68,
0.68,
0.68,
0.69,
0.69,
0.69,
0.74,
0.87,
0.88,
0.96,
0.98,
1.03,
1.15
]
}