ЛР6: OpenTelemetry, Collector, Prometheus/Loki/Tempo, Grafana, SLO и алерты, инциденты

This commit is contained in:
kalibr456
2026-11-01 21:25:38 +03:00
parent 470d9d6f1e
commit 79ef8807d5
156 changed files with 18393 additions and 35 deletions
+96
View File
@@ -0,0 +1,96 @@
# attachments: lab4: files, limits, damaged images, MIME, filenames, access, attachment_ids
# date: 2026-11-01 20:38:49, commit: 470d9d6 + uncommitted changes
# command: python.exe student-tests/test_attachments.py
# exit code: 0, 10.3 s
sample.png: 111817 bytes, sha256 99ea7533c441..., downloaded by the other member, same bytes
sample.jpg: 1492 bytes, sha256 c310b9a1c208..., downloaded by the other member, same bytes
progressive.jpg: 1081 bytes, sha256 913df01aec84..., downloaded by the other member, same bytes
interlaced.png: 79 bytes, sha256 38149222f78f..., downloaded by the other member, same bytes
1x1.png: 67 bytes, sha256 eaa4a94ea300..., downloaded by the other member, same bytes
PASS: PNG, JPEG, progressive JPEG, interlaced PNG and 1x1 PNG are stored and returned byte for byte
exactly 10485760 bytes (10 MiB) -> 202, then ready
10485761 bytes (10 MiB + 1) with Content-Length -> 413 before reading the body
PASS: the 10 MiB limit is exact
12 MiB without Content-Length (chunked) -> 413 as soon as the 10 MiB limit is passed
PASS: oversized streamed body is cut off, the API keeps working
8000x5000 = 40 000 000 pixels (38957 bytes compressed) -> 202, ready 23200a7c
8001x5000 = 40 005 000 pixels (38962 bytes) -> 413
header claims 100000x100000 in 65 bytes -> 413 from the header, nothing is decoded
PASS: pixel limit is checked before decompression
PNG cut in half (55908 bytes, image/png) -> 415
PNG without IEND (111805 bytes, image/png) -> 415
PNG with a flipped byte in IDAT (CRC mismatch) (111817 bytes, image/png) -> 415
PNG with garbage after IEND (111824 bytes, image/png) -> 415
PNG signature only (8 bytes, image/png) -> 415
PNG with less pixel data than the header says (68 bytes, image/png) -> 415
JPEG cut in half (746 bytes, image/jpeg) -> 415
JPEG header only (20 bytes, image/jpeg) -> 415
random bytes (1600 bytes, image/png) -> 415
plain text (28 bytes, image/jpeg) -> 415
empty body -> 400
PASS: damaged and foreign files are rejected with 415, never 500
PLTE 771 bytes = 257 entries (review case) (850 bytes, valid CRCs) -> 415
PLTE length not a multiple of 3 (83 bytes, valid CRCs) -> 415
empty PLTE (79 bytes, valid CRCs) -> 415
palette larger than bit depth allows (depth 1, 3 entries) (88 bytes, valid CRCs) -> 415
palette image without PLTE (67 bytes, valid CRCs) -> 415
PLTE in a grayscale image (85 bytes, valid CRCs) -> 415
PLTE after IDAT (85 bytes, valid CRCs) -> 415
two PLTE chunks (103 bytes, valid CRCs) -> 415
tRNS longer than the palette (100 bytes, valid CRCs) -> 415
tRNS before PLTE (98 bytes, valid CRCs) -> 415
tRNS of wrong size for RGB (4 bytes instead of 6) (85 bytes, valid CRCs) -> 415
tRNS in an image with alpha channel (82 bytes, valid CRCs) -> 415
IEND with data (70 bytes, valid CRCs) -> 415
unknown critical chunk (81 bytes, valid CRCs) -> 415
IDAT chunks not consecutive (95 bytes, valid CRCs) -> 415
gAMA after IDAT (85 bytes, valid CRCs) -> 415
gAMA of 2 bytes instead of 4 (83 bytes, valid CRCs) -> 415
3 MiB metadata chunk before IDAT (3145809 bytes, valid CRCs) -> 415
private chunk after IDAT (181 bytes, valid CRCs) -> 415
animated PNG frame (fdAT) (91 bytes, valid CRCs) -> 415
tIME of 2 bytes instead of 7 (83 bytes, valid CRCs) -> 415
tEXt without keyword separator (86 bytes, valid CRCs) -> 415
zTXt with broken zlib after IDAT (91 bytes, valid CRCs) -> 415
zTXt text bomb: 50 MB of text in ~50 KB after IDAT (48694 bytes, valid CRCs) -> 415
palette 256 entries + tRNS + tEXt and tIME after IDAT -> 201, downloaded byte for byte
palette depth 2 with 4 entries -> 201, downloaded byte for byte
RGB with 6-byte tRNS and gAMA -> 201, downloaded byte for byte
compressed zTXt (100 KB of text) and iTXt after IDAT -> 201, downloaded byte for byte
PASS: chunk contents are checked, not only CRCs; valid PNGs with metadata are still accepted
PNG bytes sent as image/jpeg -> 415
JPEG bytes sent as image/png -> 415
GIF bytes sent as image/png -> 415
PNG sent as image/gif -> 415
PNG sent as text/html -> 415
PNG sent as application/octet-stream -> 415
PNG sent as multipart/form-data -> 415
PNG sent as 'IMAGE/PNG; charset=binary' -> 201, stored as image/png
PASS: the type is taken from the content; a declared type that does not match is refused
13 dangerous or invalid names (path, slashes, NUL, control characters, empty, 256 chars) -> 400
no filename -> 400
Unicode, 255 chars, leading dots, %20 and ? are kept as display names only
PASS: filename never becomes a path; dangerous names are refused
outsider -> 404 for metadata and bytes (same as a non-existent id); no token -> 401; bad UUID -> 400
upload into someone else's / unknown chat -> 404, without token -> 401
variant=preview -> 400 (not in the contract); original/thumbnail/crop/optimized -> 200 (lab5)
PASS: only chat members can see an attachment
text='' with 2 attachments -> 201, order kept; any member may attach a file uploaded by another member
history returns attachment_ids for every message, [] for a message without files; reuse is allowed
attachment of another chat (author is a member of both) -> 404
own + foreign attachment -> 404
unknown attachment_id -> 404
outsider referencing an attachment of the chat -> 404
duplicate ids -> 400
11 ids -> 400
bad UUID -> 400
empty text without attachments -> 400
whitespace text without attachments -> 400
PASS: only attachments of the same chat can be linked; rejected requests change nothing
same key + same attachments -> same 201; other attachments -> 409; missing field == []
PASS: Idempotency-Key covers attachment_ids
sent 1.1 MB of a declared 5 MB body and closed the connection
the API keeps serving uploads; nothing of the aborted request is visible (DB/S3 side is checked by test_consistency.py)
PASS: an interrupted upload is dropped
12 passed, 0 failed
+18
View File
@@ -0,0 +1,18 @@
# balancing: balancing, shared sessions/data/files, X-Instance-Id
# date: 2026-11-01 20:42:35, commit: 470d9d6 + uncommitted changes
# command: python.exe student-tests/test_balancing.py
# exit code: 0, 2.1 s
20 x GET /users/me with one token -> replicas: {'1db2fedff78f': 10, '171a473b0d28': 10}
PASS: one session works on every replica, no second login (sessions are shared in Redis)
message written by 171a473b0d28; read back by ['171a473b0d28', '1db2fedff78f']
PASS: a message written via one replica is read right away via another (shared PostgreSQL)
logout on 1db2fedff78f; old token then rejected by ['171a473b0d28', '1db2fedff78f']
PASS: logout on one replica revokes the session on all of them
first POST on 1db2fedff78f -> 201 7d2bb742-1417-43a4-aa8b-256930bf08ae; same key on 171a473b0d28 -> 201 7d2bb742-1417-43a4-aa8b-256930bf08ae
PASS: Idempotency-Key is shared: a retry through another replica returns the same message
file uploaded via 1db2fedff78f; downloaded byte for byte via ['171a473b0d28', '1db2fedff78f']
PASS: a file uploaded through one replica is downloaded through another (shared S3, nothing local)
statuses [200, 200, 201, 400, 401, 404, 409]: every answer has X-Instance-Id of a running container ['171a473b0d28', '1db2fedff78f']; api containers: ['171a473b0d28', '1db2fedff78f']
PASS: X-Instance-Id is in every response and points to a real container
6 passed, 0 failed
+6
View File
@@ -0,0 +1,6 @@
# check: offline contract check (make check)
# date: 2026-11-01 20:07:43, commit: 470d9d6 + uncommitted changes
# command: python.exe scripts/check_contract.py
# exit code: 0, 0.1 s
PASS: offline skeleton structure, local refs and Python syntax; application NOT tested.
+32
View File
@@ -0,0 +1,32 @@
# configs: lab6: collector/prometheus/loki/tempo configs by their own tools, alert unit tests, Grafana provisioning
# date: 2026-11-01 20:07:53, commit: 470d9d6 + uncommitted changes
# command: python.exe student-tests/check_configs.py
# exit code: 0, 5.5 s
--- otelcol-contrib validate (infra/otel/collector.yaml): exit 0
--- promtool check config (infra/prometheus/prometheus.yml): exit 0
Checking /etc/prometheus/rules/alerts.yml
SUCCESS: 6 rules found
Checking /etc/prometheus/rules/recording.yml
SUCCESS: 10 rules found
--- promtool check rules (recording + alerts): exit 0
Checking /etc/prometheus/rules/alerts.yml
SUCCESS: 6 rules found
Checking /etc/prometheus/rules/recording.yml
SUCCESS: 10 rules found
--- promtool test rules (unit tests of alert thresholds/windows/for): exit 0
SUCCESS
--- loki -verify-config (infra/loki/loki.yaml): exit 0
--- tempo -config.verify (infra/tempo/tempo.yaml): exit 0
--- Grafana 12.4.14: database ok
datasource prometheus (prometheus): OK Successfully queried the Prometheus API.
datasource loki (loki): OK Data source successfully connected.
datasource tempo (tempo): OK Data source is working
dashboard 'Messenger — lab6 observability' in folder 'Messenger': 34 panels, provisioned=True, datasources ['loki', 'prometheus', 'tempo']
PASS: collector, prometheus (config, rules, unit tests), loki and tempo configs are valid; Grafana provisioned 3 healthy datasources and the dashboard without manual steps
+47
View File
@@ -0,0 +1,47 @@
# consistency: lab4: aborted upload, crash between S3 and DB, janitor, orphans, S3 outage
# date: 2026-11-01 20:41:39, commit: 470d9d6 + uncommitted changes
# command: python.exe student-tests/test_consistency.py
# exit code: 0, 159.9 s
declared 9 000 000 bytes, sent 211817, closed the connection
declared 9 000 000 bytes, sent 3111817, closed the connection
rows in attachments: 63 -> 63; objects in bucket: 240 -> 240
temporary upload files in api containers: {'171a473b0d28': 0, '1db2fedff78f': 0} (removed when the request ends)
api containers have no volumes: the original is never stored locally
PASS: an interrupted upload leaves no row, no object and no local file
crash after S3 PUT: row b1065ae1 state=uploading, object staging/b5763f64729a4b8a8c899bcd7009e599 exists in S3
the half-written attachment is invisible: GET -> 404, attach to a message -> 404
janitor with default grace (3600 s) right away: {"dry_run": false, "grace_seconds": 3600, "stale_uploads": 0, "stale_uploads_deleted": 0, "staging_ready_deleted": 0, "staging_failed_expired": 0, "staging_kept_for_replay": 0, "outbox_rows_deleted": 0, "objects_scanned": 245, "orphan_objects": 0, "orphan_objects_deleted": 0, "missing_objects": 0, "seconds": 0.133} -> fresh row and object are kept (the upload might still be running)
row made 2 h old; janitor --dry-run: {"dry_run": true, "grace_seconds": 3600, "stale_uploads": 1, "stale_uploads_deleted": 0, "staging_ready_deleted": 0, "staging_failed_expired": 0, "staging_kept_for_replay": 0, "outbox_rows_deleted": 0, "objects_scanned": 245, "orphan_objects": 0, "orphan_objects_deleted": 0, "missing_objects": 0, "seconds": 0.132} -> nothing deleted
janitor: {"dry_run": false, "grace_seconds": 3600, "stale_uploads": 1, "stale_uploads_deleted": 1, "staging_ready_deleted": 0, "staging_failed_expired": 0, "staging_kept_for_replay": 0, "outbox_rows_deleted": 0, "objects_scanned": 244, "orphan_objects": 0, "orphan_objects_deleted": 0, "missing_objects": 0, "seconds": 0.101} -> row and object deleted
janitor again: {"dry_run": false, "grace_seconds": 3600, "stale_uploads": 0, "stale_uploads_deleted": 0, "staging_ready_deleted": 0, "staging_failed_expired": 0, "staging_kept_for_replay": 0, "outbox_rows_deleted": 0, "objects_scanned": 244, "orphan_objects": 0, "orphan_objects_deleted": 0, "missing_objects": 0, "seconds": 0.134} -> idempotent
the ready attachment of the same chat is untouched
PASS: S3 written but DB not committed -> invisible, reclaimed by janitor only after the grace period
object staging/23223961df3644dbbaa0fa4f40d57b82 put into the bucket without a row in PostgreSQL
janitor --grace-seconds 3 immediately: {"dry_run": false, "grace_seconds": 3, "stale_uploads": 0, "stale_uploads_deleted": 0, "staging_ready_deleted": 0, "staging_failed_expired": 0, "staging_kept_for_replay": 0, "outbox_rows_deleted": 0, "objects_scanned": 249, "orphan_objects": 0, "orphan_objects_deleted": 0, "missing_objects": 0, "seconds": 0.103} -> fresh object kept
after 4 s, --dry-run: {"dry_run": true, "grace_seconds": 3, "stale_uploads": 0, "stale_uploads_deleted": 0, "staging_ready_deleted": 0, "staging_failed_expired": 0, "staging_kept_for_replay": 0, "outbox_rows_deleted": 0, "objects_scanned": 249, "orphan_objects": 1, "orphan_objects_deleted": 0, "missing_objects": 0, "seconds": 0.123} -> reported, kept
janitor: {"dry_run": false, "grace_seconds": 3, "stale_uploads": 0, "stale_uploads_deleted": 0, "staging_ready_deleted": 0, "staging_failed_expired": 0, "staging_kept_for_replay": 0, "outbox_rows_deleted": 0, "objects_scanned": 249, "orphan_objects": 1, "orphan_objects_deleted": 1, "missing_objects": 0, "seconds": 0.134} -> orphan deleted
ready attachments older than the grace period are untouched (they have rows)
object of a ready attachment deleted behind the API's back: janitor reports missing_objects=1 and keeps the row; download -> 503 (not 500)
PASS: orphans are found and deleted only after the grace period; missing objects are reported
--- S3 stopped (connection refused / name not resolved): docker compose stop s3
upload -> 503 unavailable in 20234 ms, no storage details in the body
download of an existing file -> 503
metadata, messages (also with an already stored attachment) and /health/ready keep working: S3 is needed only for file bytes
uploading rows of this chat: before 0, after the failed upload 1 (kept as a pointer for janitor if the rollback could not reach S3); not visible through the API
docker compose start s3
after S3 recovery the old file downloads byte for byte
new upload -> 201
janitor after grace period: {"dry_run": false, "grace_seconds": 3600, "stale_uploads": 1, "stale_uploads_deleted": 1, "staging_ready_deleted": 0, "staging_failed_expired": 0, "staging_kept_for_replay": 0, "outbox_rows_deleted": 0, "objects_scanned": 259, "orphan_objects": 0, "orphan_objects_deleted": 0, "missing_objects": 1, "seconds": 0.142}
PASS: S3 stopped (connection refused / name not resolved) -> 503 for file operations only, no visible half-uploads, everything cleaned up
--- S3 frozen (no answer, timeouts): docker compose pause s3
upload -> 503 unavailable in 14703 ms, no storage details in the body
download of an existing file -> 503
metadata, messages (also with an already stored attachment) and /health/ready keep working: S3 is needed only for file bytes
uploading rows of this chat: before 0, after the failed upload 1 (kept as a pointer for janitor if the rollback could not reach S3); not visible through the API
docker compose unpause s3
after S3 recovery the old file downloads byte for byte
new upload -> 201
janitor after grace period: {"dry_run": false, "grace_seconds": 3600, "stale_uploads": 1, "stale_uploads_deleted": 1, "staging_ready_deleted": 0, "staging_failed_expired": 0, "staging_kept_for_replay": 0, "outbox_rows_deleted": 0, "objects_scanned": 267, "orphan_objects": 0, "orphan_objects_deleted": 0, "missing_objects": 1, "seconds": 0.192}
PASS: S3 frozen (no answer, timeouts) -> 503 for file operations only, no visible half-uploads, everything cleaned up
5 passed, 0 failed
+36
View File
@@ -0,0 +1,36 @@
# dashboard: lab6: every dashboard/rule query runs on live data, key signals present, no forbidden labels
# date: 2026-11-01 20:09:12, commit: 470d9d6 + uncommitted changes
# command: python.exe student-tests/check_dashboard.py
# exit code: 0, 1.0 s
PromQL: 54 dashboard expressions + 16 rule expressions executed, 0 errors, 15 empty now (no traffic of that kind / Docker-only / no incident)
empty now: CPU контейнеров / лимит
empty now: Collector: потери и отказы
empty now: SDK приложений: экспорт и потери
empty now: alerts.yml: MessengerDbPoolSaturated
empty now: alerts.yml: MessengerHighErrorRate
empty now: alerts.yml: MessengerQueueLagGrowing
empty now: alerts.yml: MessengerWorkerNoConsumers
empty now: alerts.yml: TelemetryCollectorDown
empty now: alerts.yml: TelemetryExportFailing
empty now: Алерты Prometheus (pending/firing)
empty now: Память: RSS процесса и контейнер
LogQL ok: Предупреждения и ошибки (Loki): {service_name=~"messenger-.*"} | detected_level=~"warn|error"
TraceQL ok: Трассы с ошибками (Tempo, TraceQL): { status = error } -> 4 trace(s)
data: http_server_request_duration_seconds_count{job="messenger-api"} 48 series <- HTTP requests/duration (3)
data: messenger_job_duration_seconds_count 3 series <- jobs processed/failed + duration (3)
data: messenger_attachment_time_to_ready_seconds_count 1 series <- end-to-end time to ready (4)
data: messenger_queue_depth 2 series <- queue depth (4)
data: messenger_queue_oldest_age_seconds 1 series <- oldest job age (4)
data: db_client_connection_count 4 series <- DB pool used/idle (4)
data: db_client_connection_pending_requests 2 series <- DB pool waiting (4)
data: messenger_worker_busy 1 series <- worker busy (4)
data: messenger_worker_capacity 1 series <- worker capacity (4)
data: process_cpu_time_seconds_total 12 series <- process CPU (4)
data: process_memory_usage_bytes 6 series <- process RAM (4)
data: otelcol_exporter_queue_size 3 series <- collector queue (4)
labels used by application metrics: __name__, cpu_mode, db_client_connection_pool_name, db_client_connection_state, deployment_environment_name, http_request_method, http_response_status_class, http_response_status_code, http_route, instance, job, job_type, le, messaging_destination_name, otel_component_name, otel_component_type, otel_span_parent_origin, otel_span_sampling_result, outcome, server_address, server_port, service_version, status, telemetry_sdk_language, telemetry_sdk_name, telemetry_sdk_version
http_route values (templates, not URLs): ['/api/v1/attachments/{attachment_id}', '/api/v1/attachments/{attachment_id}/content', '/api/v1/auth/sessions', '/api/v1/auth/sessions/current', '/api/v1/chats', '/api/v1/chats/{chat_id}', '/api/v1/chats/{chat_id}/attachments', '/api/v1/chats/{chat_id}/messages', '/api/v1/users', '/api/v1/users/me', '/health/live', '/health/ready']
PASS: every dashboard/rule query runs, key signals have data, no forbidden labels
+21
View File
@@ -0,0 +1,21 @@
# db: PostgreSQL: rollback, FK, Argon2id, unique keys, migrations
# date: 2026-11-01 20:42:53, commit: 470d9d6 + uncommitted changes
# command: python.exe student-tests/test_db.py
# exit code: 0, 11.6 s
chat with unknown member -> 400; rows with this title: 0; chats without members: 0; chats insert counter: 71 -> 72
PASS: chat row was inserted and then rolled back together with members
direct INSERT of a message from a non-member -> exit code 1: ERROR: insert or update on table "messages" violates foreign key constraint "messages_chat_id_sender_id_fkey"
PASS: the database itself rejects a message from a non-member
stored password: $argon2id$v=19$m=12288,t=3,p=1$... (length 97)
PASS: password is stored as Argon2id hash
unique constraint on users: UNIQUE (username)
PASS: username is unique in the database
applied migrations: 001_init.sql,002_text_as_bytes.sql,003_idempotency.sql,004_attachments.sql,005_jobs.sql; running the migrate service once more
after the second run: 001_init.sql,002_text_as_bytes.sql,003_idempotency.sql,004_attachments.sql,005_jobs.sql; log: Migrations applied: none (schema is up to date)
PASS: migrations are applied once, a repeated run does nothing
api replicas that checked the schema at start: 10; api log lines 'Migrations applied': 0; migrate service: Exited (0) 4 minutes ago
PASS: only the migrate service applies migrations, replicas wait for the schema
unique constraint for Idempotency-Key: UNIQUE (chat_id, sender_id, idempotency_key)
PASS: one message per (chat, sender, Idempotency-Key) is enforced by the database
7 passed, 0 failed
+109
View File
@@ -0,0 +1,109 @@
=== Data volume
messages_total | messages_in_big_chat
----------------+----------------------
68448 | 15000
=== History index
indexdef
----------------------------------------------------------------------------------------
CREATE INDEX messages_history ON public.messages USING btree (chat_id, created_at, id)
=== 1. First page: limit=50, the app asks for 51 rows to know if there is a next page
QUERY PLAN
------------------------------------------------------------------------------------------------
Limit (actual time=0.007..0.019 rows=51 loops=1)
Buffers: shared hit=54
-> Index Scan using messages_history on messages (actual time=0.007..0.016 rows=51 loops=1)
Index Cond: (chat_id = '2ce6ad8d-9425-42cb-aa5f-94f2857a7f39'::uuid)
Buffers: shared hit=54
Planning:
Buffers: shared hit=8
Planning Time: 0.067 ms
Execution Time: 0.026 ms
=== 2. Page after the 10000th message by keyset cursor (this is what the app does)
QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Limit (actual time=0.007..0.012 rows=51 loops=1)
Buffers: shared hit=5
-> Index Scan using messages_history on messages (actual time=0.006..0.009 rows=51 loops=1)
Index Cond: ((chat_id = '2ce6ad8d-9425-42cb-aa5f-94f2857a7f39'::uuid) AND (ROW(created_at, id) > ROW('2026-09-01 02:46:40+00'::timestamp with time zone, '09b0c717-4cc7-469c-afb2-fc088519bea2'::uuid)))
Buffers: shared hit=5
Planning Time: 0.083 ms
Execution Time: 0.047 ms
=== 2b. The same page exactly as the app sends it since lab4: with attachment_ids of every message
QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Limit (actual time=0.024..0.176 rows=51 loops=1)
Buffers: shared hit=59
-> Index Scan using messages_history on messages m (actual time=0.024..0.173 rows=51 loops=1)
Index Cond: ((chat_id = '2ce6ad8d-9425-42cb-aa5f-94f2857a7f39'::uuid) AND (ROW(created_at, id) > ROW('2026-09-01 02:46:40+00'::timestamp with time zone, '09b0c717-4cc7-469c-afb2-fc088519bea2'::uuid)))
Buffers: shared hit=59
SubPlan 1
-> Sort (actual time=0.002..0.002 rows=0 loops=51)
Sort Key: a."position"
Sort Method: quicksort Memory: 25kB
Buffers: shared hit=54
-> Bitmap Heap Scan on message_attachments a (actual time=0.000..0.000 rows=0 loops=51)
Recheck Cond: (message_id = m.id)
Buffers: shared hit=51
-> Bitmap Index Scan on message_attachments_message_id_attachment_id_key (actual time=0.000..0.000 rows=0 loops=51)
Index Cond: (message_id = m.id)
Buffers: shared hit=51
Planning:
Buffers: shared hit=63
Planning Time: 0.210 ms
Execution Time: 0.193 ms
=== 3. The same page with OFFSET 10000 (the app does NOT do this)
QUERY PLAN
--------------------------------------------------------------------------------
Limit (actual time=4.087..4.090 rows=51 loops=1)
Buffers: shared hit=1255
-> Sort (actual time=3.670..3.904 rows=10051 loops=1)
Sort Key: created_at, id
Sort Method: quicksort Memory: 2377kB
Buffers: shared hit=1255
-> Seq Scan on messages (actual time=0.006..2.281 rows=15000 loops=1)
Filter: (chat_id = '2ce6ad8d-9425-42cb-aa5f-94f2857a7f39'::uuid)
Rows Removed by Filter: 53448
Buffers: shared hit=1255
Planning Time: 0.041 ms
Execution Time: 4.136 ms
=== 4. Query 2 without the index (index is dropped only inside this transaction)
QUERY PLAN
-----------------------------------------------------------------------------------------------------------------------------------------------------
Limit (actual time=1.375..1.378 rows=51 loops=1)
Buffers: shared hit=1006
-> Sort (actual time=1.374..1.376 rows=51 loops=1)
Sort Key: created_at, id
Sort Method: top-N heapsort Memory: 31kB
Buffers: shared hit=1006
-> Bitmap Heap Scan on messages (actual time=0.726..1.001 rows=5000 loops=1)
Recheck Cond: (chat_id = '2ce6ad8d-9425-42cb-aa5f-94f2857a7f39'::uuid)
Filter: (ROW(created_at, id) > ROW('2026-09-01 02:46:40+00'::timestamp with time zone, '09b0c717-4cc7-469c-afb2-fc088519bea2'::uuid))
Rows Removed by Filter: 10000
Heap Blocks: exact=991
Buffers: shared hit=1006
-> Bitmap Index Scan on messages_idempotency_key (actual time=0.217..0.217 rows=15000 loops=1)
Index Cond: (chat_id = '2ce6ad8d-9425-42cb-aa5f-94f2857a7f39'::uuid)
Buffers: shared hit=15
Planning:
Buffers: shared hit=4
Planning Time: 0.057 ms
Execution Time: 1.395 ms
=== ROLLBACK: test data removed, index is back
explain_users_left
--------------------
0
+46
View File
@@ -0,0 +1,46 @@
# explain: EXPLAIN of the history page (full plans: explain-history.txt)
# date: 2026-11-01 20:42:57, commit: 470d9d6 + uncommitted changes
# command: python.exe student-tests/explain.py
# exit code: 0, 1.2 s
=== Data volume
=== History index
=== 1. First page: limit=50, the app asks for 51 rows to know if there is a next page
Buffers: shared hit=54
-> Index Scan using messages_history on messages (actual time=0.007..0.016 rows=51 loops=1)
Buffers: shared hit=54
Buffers: shared hit=8
Execution Time: 0.026 ms
=== 2. Page after the 10000th message by keyset cursor (this is what the app does)
Buffers: shared hit=5
-> Index Scan using messages_history on messages (actual time=0.006..0.009 rows=51 loops=1)
Buffers: shared hit=5
Execution Time: 0.047 ms
=== 2b. The same page exactly as the app sends it since lab4: with attachment_ids of every message
Buffers: shared hit=59
-> Index Scan using messages_history on messages m (actual time=0.024..0.173 rows=51 loops=1)
Buffers: shared hit=59
Buffers: shared hit=54
-> Bitmap Heap Scan on message_attachments a (actual time=0.000..0.000 rows=0 loops=51)
Buffers: shared hit=51
-> Bitmap Index Scan on message_attachments_message_id_attachment_id_key (actual time=0.000..0.000 rows=0 loops=51)
Buffers: shared hit=51
Buffers: shared hit=63
Execution Time: 0.193 ms
=== 3. The same page with OFFSET 10000 (the app does NOT do this)
Buffers: shared hit=1255
Buffers: shared hit=1255
-> Seq Scan on messages (actual time=0.006..2.281 rows=15000 loops=1)
Buffers: shared hit=1255
Execution Time: 4.136 ms
=== 4. Query 2 without the index (index is dropped only inside this transaction)
Buffers: shared hit=1006
Buffers: shared hit=1006
-> Bitmap Heap Scan on messages (actual time=0.726..1.001 rows=5000 loops=1)
Buffers: shared hit=1006
-> Bitmap Index Scan on messages_idempotency_key (actual time=0.217..0.217 rows=15000 loops=1)
Buffers: shared hit=15
Buffers: shared hit=4
Execution Time: 1.395 ms
=== ROLLBACK: test data removed, index is back
PASS: full plans saved to evidence\explain-history.txt
+33
View File
@@ -0,0 +1,33 @@
# failover: public failover test for every replica, file downloaded via the other one (make test-failover)
# date: 2026-11-01 20:43:39, commit: 470d9d6 + uncommitted changes
# command: python.exe student-tests/run_failover.py
# exit code: 0, 42.0 s
hook: scripts\stop-one.cmd; api replicas: ['171a473b0d28', '1db2fedff78f']
=== run 1: api containers before
SERVICE CONTAINER ID STATUS
api 171a473b0d28 Up 41 seconds (healthy)
api 1db2fedff78f Up 41 seconds (healthy)
Executing explicit failover hook; hook output suppressed to avoid leaking secrets.␍
{"observed_instances_before": 2, "successful_writes": 127, "failed_attempts": 0, "first_recovery_seconds": 4.75}␍
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
api containers after
SERVICE CONTAINER ID STATUS
api 171a473b0d28 Exited (0) 11 seconds ago
api 1db2fedff78f Up 58 seconds (healthy)
the hook stopped 171a473b0d28 (X-Instance-Id of that replica = container ID); other api containers kept running, postgres/redis/lb were not touched
restored: docker start 171a473b0d28 -> healthy and back in HAProxy
=== run 2: api containers before
SERVICE CONTAINER ID STATUS
api 171a473b0d28 Up 2 seconds (healthy)
api 1db2fedff78f Up About a minute (healthy)
Executing explicit failover hook; hook output suppressed to avoid leaking secrets.␍
{"observed_instances_before": 2, "successful_writes": 126, "failed_attempts": 0, "first_recovery_seconds": 4.578}␍
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
api containers after
SERVICE CONTAINER ID STATUS
api 171a473b0d28 Up 19 seconds (healthy)
api 1db2fedff78f Exited (0) 11 seconds ago
the hook stopped 1db2fedff78f (X-Instance-Id of that replica = container ID); other api containers kept running, postgres/redis/lb were not touched
restored: docker start 1db2fedff78f -> healthy and back in HAProxy
PASS: public failover test passed 2 times; every api replica was stopped once and restored
+29
View File
@@ -0,0 +1,29 @@
# failures: Redis and PostgreSQL outages via the balancer
# date: 2026-11-01 20:45:06, commit: 470d9d6 + uncommitted changes
# command: python.exe student-tests/test_failures.py
# exit code: 0, 55.6 s
stopping redis
/health/live -> 200, /health/ready -> 503 (8016 ms)
valid token: GET /users/me -> 503 unavailable (8000 ms), session cannot be checked
unknown token -> 503, not 200: nobody is trusted without a check
no token -> 401
login -> 503: there is nowhere to store the session
registration -> 201: it needs only PostgreSQL
starting redis
after start: the old token works, confirmed messages are in place
PASS: Redis outage gives 503 and does not let anyone in without a session check
killing redis with SIGKILL (docker compose kill redis): no graceful shutdown
right after the crash: GET /users/me -> 503
starting redis
after start: the session issued before the crash still works (AOF, appendfsync always)
PASS: sessions survive a Redis crash, not only a clean restart
stopping postgres
/health/live -> 200, /health/ready -> 503 (1016 ms)
valid token: users/me, chats, history, new message -> 503 unavailable, no details
no token -> 401, unknown token -> 401: anonymous users are not let in
login -> 503, registration -> 503
starting postgres
after start: the old token works, confirmed messages are in place
PASS: PostgreSQL outage gives limited 503 errors and keeps anonymous users out
3 passed, 0 failed
+22
View File
@@ -0,0 +1,22 @@
# idempotency: Idempotency-Key, parallel same key via replicas
# date: 2026-11-01 20:42:37, commit: 470d9d6 + uncommitted changes
# command: python.exe student-tests/test_idempotency.py
# exit code: 0, 2.2 s
first -> 201; same JSON written differently -> 201; plain retry -> 201
PASS: a retry with the same key returns the original 201 and message, no duplicate
20 parallel POSTs with one key: statuses {201: 20}, replicas {'171a473b0d28': 10, '1db2fedff78f': 10}, different bodies in answers: 1, messages in history: 1
PASS: parallel requests with one key through different replicas create exactly one message
20 parallel POSTs, one key, two different bodies: {('body A', 409): 10, ('body B', 201): 10}; saved: ['body B']
PASS: the first body wins, the same body gets 201, the other body gets 409
one key: alice in chat 1, bob in chat 1, alice in chat 2 -> 3 messages
PASS: the key is scoped to the current user and chat; another body with a used key -> 409
missing, empty, 129 chars, space, '/', non-ASCII, '"', '+' -> 400; 128 chars of A-Z a-z 0-9 . _ : - -> 201
PASS: Idempotency-Key is required and checked: [A-Za-z0-9._:-]{1,128}
key used by a 400 and by a 404 first, then valid request -> 201
PASS: rejected requests (400, 404) do not store a result for the key
same key and body by an outsider -> 404; by alice after logout -> 401
PASS: a retry checks the session and chat access again, the saved answer is not leaked
POST sent, connection closed without reading the answer; retry -> 201; messages: 1
PASS: an unconfirmed POST can be safely retried with the same key
8 passed, 0 failed
+39
View File
@@ -0,0 +1,39 @@
{
"scenario": "collector-down",
"date": "2026-11-01 20:25:18",
"outage_s": 90,
"baseline": {
"requests": 870,
"codes": {
"201": 870
},
"success_ratio": 1.0,
"success_rps": 58.0,
"p95_ms_successful": 32.0
},
"during": {
"requests": 5852,
"codes": {
"201": 5852
},
"success_ratio": 1.0,
"success_rps": 57.9,
"p95_ms_successful": 31.0
},
"api_mib_before": 295.2,
"api_mib_max": 313.5,
"sdk_lost_spans_api": {
"processor_queue_full": 8252,
"exporter_failed": 10752
},
"sdk_exported_ok_after_restart": 10287,
"after": {
"requests": 1403,
"codes": {
"201": 1403
},
"success_ratio": 1.0,
"success_rps": 56.1,
"p95_ms_successful": 32.0
}
}
+20
View File
@@ -0,0 +1,20 @@
# incident-collector: lab6: Collector down -> API unaffected, SDK queue bounded, drops counted
# date: 2026-11-01 20:27:53, commit: 470d9d6 + uncommitted changes
# command: python.exe student-tests/incidents.py collector-down
# exit code: 0, 155.8 s
=== collector-down
[ 24.6s] baseline: {'requests': 870, 'codes': {'201': 870}, 'success_ratio': 1.0, 'success_rps': 58.0, 'p95_ms_successful': 32.0}, api containers 295.2 MiB
[ 25.3s] docker compose stop otel-collector
[ 29.3s] {'t': 0.7, 'api_mib': 292.8}
[ 43.6s] {'t': 14.7, 'api_mib': 298.9}
[ 58.0s] {'t': 29.0, 'api_mib': 306.5}
[ 72.6s] {'t': 43.4, 'api_mib': 307.8}
[ 87.0s] {'t': 58.0, 'api_mib': 308.2}
[ 101.0s] {'t': 72.4, 'api_mib': 313.5}
[ 115.0s] {'t': 86.4, 'api_mib': 313.3}
[ 125.6s] docker compose start otel-collector
[ 155.6s] API during collector outage: {'requests': 5852, 'codes': {'201': 5852}, 'success_ratio': 1.0, 'success_rps': 57.9, 'p95_ms_successful': 31.0}; api memory 295.2 -> max 313.5 MiB; SDK lost spans (api): {'processor_queue_full': 8252, 'exporter_failed': 10752}; exported OK in the last minute after restart: 10287
[ 155.6s] saved C:\Users\Gigabyte\Desktop\lab6\mtusi2026lab6\evidence\incident-collector-down.json
PASS: Collector down -> API unaffected, SDK memory bounded, lost spans counted, export resumes after start
1 passed, 0 failed
+82
View File
@@ -0,0 +1,82 @@
{
"scenario": "db-slow",
"date": "2026-11-01 20:13:54",
"lock_seconds": 210,
"baseline": {
"requests": 2310,
"codes": {
"201": 2310
},
"success_ratio": 1.0,
"success_rps": 115.5,
"p95_ms_successful": 32.0,
"server_p95_s": 0.019
},
"firing_after_lock_s": 140.8,
"diagnosis": {
"http_5xx_ratio_1m": 1.0,
"http_p95_messages_s": 7.375,
"pool_used": 8.0,
"pool_wait_p95_s": 0.001,
"status_codes_1m": {
"201": 0.0,
"200": 0.0,
"404": 0.0,
"400": 0.0,
"409": 0.0,
"503": 1.6
},
"reads_during_lock_ms": {
"GET /users/me + GET /chats, avg per request": 17.2,
"max": 23.5
},
"api_log_db_unavailable_by_error_type": {
"QueryCanceled": 216
},
"error_trace": {
"trace_id": "237e2d6b1c7db22adbb7d4752fa47f2",
"server_ms": 5013.3,
"slowest_db_span": "INSERT",
"slowest_db_ms": 5001.3,
"db_span_status": "ERROR",
"db_share": 0.998,
"tree": [
"- [api] POST /api/v1/chats/{chat_id}/messages (SERVER, 5013.3 ms) ERROR http.response.status_code=503 error.type=503",
" - [api] redis GET (CLIENT, 1.1 ms)",
" - [api] SELECT (CLIENT, 1.6 ms)",
" - [api] INSERT (CLIENT, 5001.3 ms) ERROR"
]
},
"handler_cpu_contrast": {
"trace_id": "4a222e478c2d51006538a7bfeb485eb1",
"server_ms": 21.2,
"argon2id_ms": 16.4,
"db_ms_total": 0.7,
"tree": [
"- [api] POST /api/v1/users (SERVER, 21.2 ms) http.response.status_code=201",
" - [api] argon2id hash (INTERNAL, 16.4 ms)",
" - [api] INSERT (CLIENT, 0.7 ms)"
]
}
},
"during_lock": {
"requests": 328,
"codes": {
"503": 320,
"201": 8
},
"success_ratio": 0.0244,
"success_rps": 0.0,
"p95_ms_successful": 2156.0
},
"resolved_after_unlock_s": 50.1,
"after": {
"requests": 5269,
"codes": {
"201": 5269
},
"success_ratio": 1.0,
"success_rps": 116.8,
"p95_ms_successful": 31.0
}
}
+64
View File
@@ -0,0 +1,64 @@
# incident-db: lab6 incident 2: slow PostgreSQL (table lock) -> high error rate firing, cause from traces -> resolved
# date: 2026-11-01 20:18:39, commit: 470d9d6 + uncommitted changes
# command: python.exe student-tests/incidents.py db-slow
# exit code: 0, 285.7 s
=== db-slow
[ 0.0s] load: 8 threads POST /messages
[ 25.0s] baseline: {'requests': 2310, 'codes': {'201': 2310}, 'success_ratio': 1.0, 'success_rps': 115.5, 'p95_ms_successful': 32.0, 'server_p95_s': 0.019}
[ 25.0s] LOCK TABLE messages IN ACCESS EXCLUSIVE MODE for 210 s (PostgreSQL alive, writes wait)
[ 25.1s] 5xx ratio=None p95=0.019 s pool used=0.0 waiting=0.0
[ 30.1s] 5xx ratio=0.0 p95=0.02 s pool used=1.0 waiting=0.0
[ 35.1s] 5xx ratio=0.0 p95=0.02 s pool used=1.0 waiting=0.0
[ 40.1s] 5xx ratio=0.0 p95=0.02 s pool used=8.0 waiting=0.0
[ 45.2s] 5xx ratio=0.0 p95=0.02 s pool used=8.0 waiting=0.0
[ 50.2s] 5xx ratio=0.0 p95=0.021 s pool used=8.0 waiting=0.0
[ 55.3s] 5xx ratio=0.0 p95=0.021 s pool used=8.0 waiting=0.0
[ 60.3s] 5xx ratio=0.0 p95=0.022 s pool used=8.0 waiting=0.0
[ 65.3s] 5xx ratio=0.0 p95=0.024 s pool used=8.0 waiting=0.0
[ 70.4s] 5xx ratio=0.0 p95=0.045 s pool used=8.0 waiting=0.0
[ 75.4s] 5xx ratio=0.015 p95=7.18 s pool used=8.0 waiting=0.0
[ 80.4s] 5xx ratio=0.015 p95=7.234 s pool used=8.0 waiting=0.0
[ 85.4s] 5xx ratio=0.015 p95=7.375 s pool used=8.0 waiting=0.0
[ 90.4s] 5xx ratio=0.044 p95=7.375 s pool used=8.0 waiting=0.0
[ 95.5s] 5xx ratio=0.044 p95=7.375 s pool used=8.0 waiting=0.0
[ 100.5s] 5xx ratio=0.044 p95=7.375 s pool used=8.0 waiting=0.0
[ 105.5s] 5xx ratio=1.0 p95=7.375 s pool used=8.0 waiting=0.0
[ 110.6s] 5xx ratio=1.0 p95=7.375 s pool used=8.0 waiting=0.0
[ 115.6s] 5xx ratio=1.0 p95=7.375 s pool used=8.0 waiting=0.0
[ 120.7s] 5xx ratio=1.0 p95=7.375 s pool used=8.0 waiting=0.0
[ 125.7s] 5xx ratio=1.0 p95=7.375 s pool used=8.0 waiting=0.0
[ 130.7s] 5xx ratio=1.0 p95=7.375 s pool used=8.0 waiting=0.0
[ 135.7s] 5xx ratio=1.0 p95=7.375 s pool used=8.0 waiting=0.0
[ 140.8s] 5xx ratio=1.0 p95=7.375 s pool used=8.0 waiting=0.0
[ 145.8s] 5xx ratio=1.0 p95=7.375 s pool used=8.0 waiting=0.0
[ 150.8s] 5xx ratio=1.0 p95=7.375 s pool used=8.0 waiting=0.0
[ 155.8s] 5xx ratio=1.0 p95=7.375 s pool used=8.0 waiting=0.0
[ 160.8s] 5xx ratio=1.0 p95=7.375 s pool used=8.0 waiting=0.0
[ 165.8s] ALERT MessengerHighErrorRate firing (140.8 s after lock)
[ 172.2s] diagnosis: {"http_5xx_ratio_1m": 1.0, "http_p95_messages_s": 7.375, "pool_used": 8.0, "pool_wait_p95_s": 0.001, "status_codes_1m": {"201": 0.0, "200": 0.0, "404": 0.0, "400": 0.0, "409": 0.0, "503": 1.6}, "reads_during_lock_ms": {"GET /users/me + GET /chats, avg per request": 17.2, "max": 23.5}, "api_log_db_unavailable_by_error_type": {"QueryCanceled": 216}}
[ 172.2s] error trace (DB): {"trace_id": "237e2d6b1c7db22adbb7d4752fa47f2", "server_ms": 5013.3, "slowest_db_span": "INSERT", "slowest_db_ms": 5001.3, "db_span_status": "ERROR", "db_share": 0.998}
- [api] POST /api/v1/chats/{chat_id}/messages (SERVER, 5013.3 ms) ERROR http.response.status_code=503 error.type=503
- [api] redis GET (CLIENT, 1.1 ms)
- [api] SELECT (CLIENT, 1.6 ms)
- [api] INSERT (CLIENT, 5001.3 ms) ERROR
[ 172.2s] contrast, slow handler (CPU): {"trace_id": "4a222e478c2d51006538a7bfeb485eb1", "server_ms": 21.2, "argon2id_ms": 16.4, "db_ms_total": 0.7}
- [api] POST /api/v1/users (SERVER, 21.2 ms) http.response.status_code=201
- [api] argon2id hash (INTERNAL, 16.4 ms)
- [api] INSERT (CLIENT, 0.7 ms)
[ 235.5s] lock released (psql exit 0), 210.5 s after LOCK
[ 235.5s] ... MessengerHighErrorRate: firing (0 s)
[ 240.5s] ... MessengerHighErrorRate: firing (5 s)
[ 245.5s] ... MessengerHighErrorRate: firing (10 s)
[ 250.5s] ... MessengerHighErrorRate: firing (15 s)
[ 255.5s] ... MessengerHighErrorRate: firing (20 s)
[ 260.6s] ... MessengerHighErrorRate: firing (25 s)
[ 265.6s] ... MessengerHighErrorRate: firing (30 s)
[ 270.6s] ... MessengerHighErrorRate: firing (35 s)
[ 275.6s] ... MessengerHighErrorRate: firing (40 s)
[ 280.6s] ... MessengerHighErrorRate: firing (45 s)
[ 285.6s] ALERT MessengerHighErrorRate resolved 50.1 s after unlock
[ 285.6s] load: during lock {'requests': 328, 'codes': {'503': 320, '201': 8}, 'success_ratio': 0.0244, 'success_rps': 0.0, 'p95_ms_successful': 2156.0}; after {'requests': 5269, 'codes': {'201': 5269}, 'success_ratio': 1.0, 'success_rps': 116.8, 'p95_ms_successful': 31.0}
[ 285.6s] saved C:\Users\Gigabyte\Desktop\lab6\mtusi2026lab6\evidence\incident-db-slow.json
PASS: slow DB -> 503 -> MessengerHighErrorRate firing; traces show the time in the INSERT span (not the handler); unlock -> resolved
1 passed, 0 failed
+273
View File
@@ -0,0 +1,273 @@
{
"scenario": "telemetry-down",
"date": "2026-11-01 20:18:47",
"stopped": [
"tempo",
"loki"
],
"outage_s": 150,
"baseline": {
"requests": 899,
"codes": {
"201": 899
},
"success_ratio": 1.0,
"success_rps": 59.9,
"p95_ms_successful": 31.0
},
"collector_heap_before_mib": 35.5,
"collector_container_before_mib": 75.9,
"during": {
"requests": 9555,
"codes": {
"201": 9555
},
"success_ratio": 1.0,
"success_rps": 59.6,
"p95_ms_successful": 31.0
},
"samples": [
{
"t": 0.0,
"collector_heap_mib": 56.4,
"collector_rss_mib": 237.6,
"collector_container_mib": 76.0,
"queue": {
"otlp_http/loki": 12.0,
"otlp_http/prometheus": 0.0,
"otlp_grpc/tempo": 5.0
},
"alert": "inactive"
},
{
"t": 12.1,
"collector_heap_mib": 45.4,
"collector_rss_mib": 237.8,
"collector_container_mib": 76.0,
"queue": {
"otlp_http/loki": 20.0,
"otlp_http/prometheus": 0.0,
"otlp_grpc/tempo": 9.0
},
"alert": "pending"
},
{
"t": 24.2,
"collector_heap_mib": 54.2,
"collector_rss_mib": 237.8,
"collector_container_mib": 76.0,
"queue": {
"otlp_http/loki": 27.0,
"otlp_http/prometheus": 0.0,
"otlp_grpc/tempo": 12.0
},
"alert": "pending"
},
{
"t": 36.2,
"collector_heap_mib": 54.2,
"collector_rss_mib": 237.8,
"collector_container_mib": 78.1,
"queue": {
"otlp_http/loki": 35.0,
"otlp_http/prometheus": 0.0,
"otlp_grpc/tempo": 15.0
},
"alert": "pending"
},
{
"t": 48.7,
"collector_heap_mib": 62.9,
"collector_rss_mib": 240.4,
"collector_container_mib": 82.2,
"queue": {
"otlp_http/loki": 35.0,
"otlp_http/prometheus": 0.0,
"otlp_grpc/tempo": 15.0
},
"alert": "pending"
},
{
"t": 60.8,
"collector_heap_mib": 51.2,
"collector_rss_mib": 244.4,
"collector_container_mib": 82.2,
"queue": {
"otlp_http/loki": 42.0,
"otlp_http/prometheus": 0.0,
"otlp_grpc/tempo": 19.0
},
"alert": "pending"
},
{
"t": 73.1,
"collector_heap_mib": 59.9,
"collector_rss_mib": 244.4,
"collector_container_mib": 82.3,
"queue": {
"otlp_http/loki": 50.0,
"otlp_http/prometheus": 0.0,
"otlp_grpc/tempo": 22.0
},
"alert": "firing"
},
{
"t": 85.2,
"collector_heap_mib": 70.5,
"collector_rss_mib": 248.4,
"collector_container_mib": 88.7,
"queue": {
"otlp_http/loki": 57.0,
"otlp_http/prometheus": 0.0,
"otlp_grpc/tempo": 26.0
},
"alert": "firing"
},
{
"t": 97.7,
"collector_heap_mib": 70.5,
"collector_rss_mib": 248.4,
"collector_container_mib": 94.5,
"queue": {
"otlp_http/loki": 63.0,
"otlp_http/prometheus": 0.0,
"otlp_grpc/tempo": 27.0
},
"alert": "firing"
},
{
"t": 109.8,
"collector_heap_mib": 56.3,
"collector_rss_mib": 256.7,
"collector_container_mib": 94.5,
"queue": {
"otlp_http/loki": 63.0,
"otlp_http/prometheus": 0.0,
"otlp_grpc/tempo": 27.0
},
"alert": "firing"
},
{
"t": 122.1,
"collector_heap_mib": 67.5,
"collector_rss_mib": 256.7,
"collector_container_mib": 94.5,
"queue": {
"otlp_http/loki": 70.0,
"otlp_http/prometheus": 0.0,
"otlp_grpc/tempo": 31.0
},
"alert": "firing"
},
{
"t": 134.2,
"collector_heap_mib": 76.1,
"collector_rss_mib": 256.9,
"collector_container_mib": 98.8,
"queue": {
"otlp_http/loki": 78.0,
"otlp_http/prometheus": 0.0,
"otlp_grpc/tempo": 34.0
},
"alert": "firing"
},
{
"t": 146.2,
"collector_heap_mib": 86.9,
"collector_rss_mib": 267.1,
"collector_container_mib": 107.0,
"queue": {
"otlp_http/loki": 85.0,
"otlp_http/prometheus": 0.0,
"otlp_grpc/tempo": 38.0
},
"alert": "firing"
}
],
"collector_heap_max_mib": 86.9,
"collector_rss_max_mib": 267.1,
"collector_container_max_mib": 107.0,
"TelemetryExportFailing_firing_at_s": 73.1,
"queue_drained_after_start_s": 60.1,
"probe_traces": [
{
"sent_at_s": 0.0,
"http": 201,
"trace_in_tempo": true
},
{
"sent_at_s": 12.1,
"http": 201,
"trace_in_tempo": true
},
{
"sent_at_s": 24.2,
"http": 201,
"trace_in_tempo": true
},
{
"sent_at_s": 36.2,
"http": 201,
"trace_in_tempo": true
},
{
"sent_at_s": 48.7,
"http": 201,
"trace_in_tempo": true
},
{
"sent_at_s": 60.8,
"http": 201,
"trace_in_tempo": true
},
{
"sent_at_s": 73.1,
"http": 201,
"trace_in_tempo": true
},
{
"sent_at_s": 85.1,
"http": 201,
"trace_in_tempo": true
},
{
"sent_at_s": 97.7,
"http": 201,
"trace_in_tempo": true
},
{
"sent_at_s": 109.8,
"http": 201,
"trace_in_tempo": true
},
{
"sent_at_s": 122.1,
"http": 201,
"trace_in_tempo": true
},
{
"sent_at_s": 134.2,
"http": 201,
"trace_in_tempo": true
},
{
"sent_at_s": 146.2,
"http": 201,
"trace_in_tempo": true
}
],
"lost_in_collector": {
"spans": 4096,
"log_records": 235
},
"resolved_after_start_s": 165.6,
"after": {
"requests": 9370,
"codes": {
"201": 9370
},
"success_ratio": 1.0,
"success_rps": 58.3,
"p95_ms_successful": 31.0
}
}
+47
View File
@@ -0,0 +1,47 @@
# incident-telemetry: lab6: Tempo+Loki down -> API unaffected, collector memory bounded, losses counted
# date: 2026-11-01 20:25:06, commit: 470d9d6 + uncommitted changes
# command: python.exe student-tests/incidents.py telemetry-down
# exit code: 0, 379.8 s
=== telemetry-down
[ 22.5s] baseline: {'requests': 899, 'codes': {'201': 899}, 'success_ratio': 1.0, 'success_rps': 59.9, 'p95_ms_successful': 31.0}, collector heap 35.5 MiB, container 75.9 MiB
[ 53.8s] docker compose stop tempo loki: stopped
[ 55.9s] {'t': 0.0, 'collector_heap_mib': 56.4, 'collector_rss_mib': 237.6, 'collector_container_mib': 76.0, 'queue': {'otlp_http/loki': 12.0, 'otlp_http/prometheus': 0.0, 'otlp_grpc/tempo': 5.0}, 'alert': 'inactive'}
[ 68.0s] {'t': 12.1, 'collector_heap_mib': 45.4, 'collector_rss_mib': 237.8, 'collector_container_mib': 76.0, 'queue': {'otlp_http/loki': 20.0, 'otlp_http/prometheus': 0.0, 'otlp_grpc/tempo': 9.0}, 'alert': 'pending'}
[ 80.0s] {'t': 24.2, 'collector_heap_mib': 54.2, 'collector_rss_mib': 237.8, 'collector_container_mib': 76.0, 'queue': {'otlp_http/loki': 27.0, 'otlp_http/prometheus': 0.0, 'otlp_grpc/tempo': 12.0}, 'alert': 'pending'}
[ 92.5s] {'t': 36.2, 'collector_heap_mib': 54.2, 'collector_rss_mib': 237.8, 'collector_container_mib': 78.1, 'queue': {'otlp_http/loki': 35.0, 'otlp_http/prometheus': 0.0, 'otlp_grpc/tempo': 15.0}, 'alert': 'pending'}
[ 104.5s] {'t': 48.7, 'collector_heap_mib': 62.9, 'collector_rss_mib': 240.4, 'collector_container_mib': 82.2, 'queue': {'otlp_http/loki': 35.0, 'otlp_http/prometheus': 0.0, 'otlp_grpc/tempo': 15.0}, 'alert': 'pending'}
[ 116.9s] {'t': 60.8, 'collector_heap_mib': 51.2, 'collector_rss_mib': 244.4, 'collector_container_mib': 82.2, 'queue': {'otlp_http/loki': 42.0, 'otlp_http/prometheus': 0.0, 'otlp_grpc/tempo': 19.0}, 'alert': 'pending'}
[ 128.9s] {'t': 73.1, 'collector_heap_mib': 59.9, 'collector_rss_mib': 244.4, 'collector_container_mib': 82.3, 'queue': {'otlp_http/loki': 50.0, 'otlp_http/prometheus': 0.0, 'otlp_grpc/tempo': 22.0}, 'alert': 'firing'}
[ 141.5s] {'t': 85.2, 'collector_heap_mib': 70.5, 'collector_rss_mib': 248.4, 'collector_container_mib': 88.7, 'queue': {'otlp_http/loki': 57.0, 'otlp_http/prometheus': 0.0, 'otlp_grpc/tempo': 26.0}, 'alert': 'firing'}
[ 153.5s] {'t': 97.7, 'collector_heap_mib': 70.5, 'collector_rss_mib': 248.4, 'collector_container_mib': 94.5, 'queue': {'otlp_http/loki': 63.0, 'otlp_http/prometheus': 0.0, 'otlp_grpc/tempo': 27.0}, 'alert': 'firing'}
[ 165.9s] {'t': 109.8, 'collector_heap_mib': 56.3, 'collector_rss_mib': 256.7, 'collector_container_mib': 94.5, 'queue': {'otlp_http/loki': 63.0, 'otlp_http/prometheus': 0.0, 'otlp_grpc/tempo': 27.0}, 'alert': 'firing'}
[ 178.0s] {'t': 122.1, 'collector_heap_mib': 67.5, 'collector_rss_mib': 256.7, 'collector_container_mib': 94.5, 'queue': {'otlp_http/loki': 70.0, 'otlp_http/prometheus': 0.0, 'otlp_grpc/tempo': 31.0}, 'alert': 'firing'}
[ 190.0s] {'t': 134.2, 'collector_heap_mib': 76.1, 'collector_rss_mib': 256.9, 'collector_container_mib': 98.8, 'queue': {'otlp_http/loki': 78.0, 'otlp_http/prometheus': 0.0, 'otlp_grpc/tempo': 34.0}, 'alert': 'firing'}
[ 202.6s] {'t': 146.2, 'collector_heap_mib': 86.9, 'collector_rss_mib': 267.1, 'collector_container_mib': 107.0, 'queue': {'otlp_http/loki': 85.0, 'otlp_http/prometheus': 0.0, 'otlp_grpc/tempo': 38.0}, 'alert': 'firing'}
[ 214.0s] docker compose start tempo loki
[ 274.1s] exporter queues drained 60.1 s after start
[ 289.4s] ... TelemetryExportFailing: firing (0 s)
[ 294.4s] ... TelemetryExportFailing: firing (5 s)
[ 299.5s] ... TelemetryExportFailing: firing (10 s)
[ 304.5s] ... TelemetryExportFailing: firing (15 s)
[ 309.5s] ... TelemetryExportFailing: firing (20 s)
[ 314.5s] ... TelemetryExportFailing: firing (25 s)
[ 319.5s] ... TelemetryExportFailing: firing (30 s)
[ 324.5s] ... TelemetryExportFailing: firing (35 s)
[ 329.5s] ... TelemetryExportFailing: firing (40 s)
[ 334.5s] ... TelemetryExportFailing: firing (45 s)
[ 339.6s] ... TelemetryExportFailing: firing (50 s)
[ 344.6s] ... TelemetryExportFailing: firing (55 s)
[ 349.6s] ... TelemetryExportFailing: firing (60 s)
[ 354.6s] ... TelemetryExportFailing: firing (65 s)
[ 359.6s] ... TelemetryExportFailing: firing (70 s)
[ 364.6s] ... TelemetryExportFailing: firing (75 s)
[ 369.6s] ... TelemetryExportFailing: firing (80 s)
[ 374.7s] ... TelemetryExportFailing: firing (85 s)
[ 379.7s] API during outage: {'requests': 9555, 'codes': {'201': 9555}, 'success_ratio': 1.0, 'success_rps': 59.6, 'p95_ms_successful': 31.0}
[ 379.7s] probe traces: 13/13 reached Tempo (lost: sent at [] s)
[ 379.7s] lost in Collector (send_failed+enqueue_failed): {'spans': 4096, 'log_records': 235}; collector heap 35.5 -> max 86.9 MiB (memory_limiter 200 MiB), container max 107.0 MiB
[ 379.7s] saved C:\Users\Gigabyte\Desktop\lab6\mtusi2026lab6\evidence\incident-telemetry-down.json
PASS: Tempo+Loki down -> API unaffected, collector memory bounded, losses counted; recovery -> resolved
1 passed, 0 failed
+50
View File
@@ -0,0 +1,50 @@
{
"scenario": "worker-stop",
"date": "2026-11-01 20:09:59",
"firing_after_stop_s": {
"MessengerWorkerNoConsumers": 101.7,
"MessengerQueueLagGrowing": 131.8
},
"diagnosis": {
"queue_consumers": 0.0,
"broker_queue_depth": 6.0,
"jobs_backlog_queued": 3.0,
"oldest_job_age_s": 127.3,
"outbox_oldest_age_s": 0.0,
"published_ok_last_5m": 16.41239671427261,
"worker_metrics_last_seen_s": 131.0,
"last_worker_log": {
"event": "service.stopped",
"message": "stopped"
},
"upload_trace_span_names": [
"INSERT",
"NOTIFY",
"POST /api/v1/chats/{chat_id}/attachments",
"S3 PutObject",
"SELECT",
"UPDATE",
"create attachments",
"inspect image",
"publish attachments",
"redis GET",
"republish lost message"
],
"upload_trace_has_consumer_span": false
},
"ready_after_start_s": [
4.2,
4.2,
4.7
],
"resolved_after_start_s": {
"MessengerWorkerNoConsumers": 29.7,
"MessengerQueueLagGrowing": 29.7
},
"after_recovery": {
"jobs_backlog_queued": 0.0,
"oldest_job_age_s": 0.0,
"queue_consumers": 2.0
},
"time_to_ready_p95_5m_s": 282.0
}
+49
View File
@@ -0,0 +1,49 @@
# incident-worker: lab6 incident 1: worker stopped -> queue lag + no consumers firing -> resolved
# date: 2026-11-01 20:12:40, commit: 470d9d6 + uncommitted changes
# command: python.exe student-tests/incidents.py worker-stop
# exit code: 0, 161.8 s
=== worker-stop
[ 0.1s] baseline: consumers=2.0, oldest job age=0.0 s
[ 1.2s] docker compose stop worker
[ 1.3s] uploaded 3 attachments: 202 queued (API accepts without worker)
[ 1.4s] consumers=2.0 backlog queued=0.0 oldest age=0.0 s, alerts: {}
[ 6.4s] consumers=2.0 backlog queued=0.0 oldest age=0.0 s, alerts: {}
[ 11.4s] consumers=0.0 backlog queued=3.0 oldest age=7.1 s, alerts: {}
[ 16.5s] consumers=0.0 backlog queued=3.0 oldest age=7.1 s, alerts: {}
[ 21.5s] consumers=0.0 backlog queued=3.0 oldest age=17.1 s, alerts: {}
[ 26.5s] consumers=0.0 backlog queued=3.0 oldest age=17.1 s, alerts: {}
[ 31.5s] consumers=0.0 backlog queued=3.0 oldest age=27.1 s, alerts: {}
[ 36.5s] consumers=0.0 backlog queued=3.0 oldest age=27.1 s, alerts: {}
[ 41.6s] consumers=0.0 backlog queued=3.0 oldest age=37.1 s, alerts: {'MessengerWorkerNoConsumers': 'pending'}
[ 46.6s] consumers=0.0 backlog queued=3.0 oldest age=37.1 s, alerts: {'MessengerWorkerNoConsumers': 'pending'}
[ 51.6s] consumers=0.0 backlog queued=3.0 oldest age=47.1 s, alerts: {'MessengerWorkerNoConsumers': 'pending'}
[ 56.6s] consumers=0.0 backlog queued=3.0 oldest age=47.1 s, alerts: {'MessengerWorkerNoConsumers': 'pending'}
[ 61.6s] consumers=0.0 backlog queued=3.0 oldest age=57.1 s, alerts: {'MessengerWorkerNoConsumers': 'pending'}
[ 66.6s] consumers=0.0 backlog queued=3.0 oldest age=57.1 s, alerts: {'MessengerWorkerNoConsumers': 'pending'}
[ 71.7s] consumers=0.0 backlog queued=3.0 oldest age=67.2 s, alerts: {'MessengerQueueLagGrowing': 'pending', 'MessengerWorkerNoConsumers': 'pending'}
[ 76.7s] consumers=0.0 backlog queued=3.0 oldest age=67.2 s, alerts: {'MessengerQueueLagGrowing': 'pending', 'MessengerWorkerNoConsumers': 'pending'}
[ 81.7s] consumers=0.0 backlog queued=3.0 oldest age=77.2 s, alerts: {'MessengerQueueLagGrowing': 'pending', 'MessengerWorkerNoConsumers': 'pending'}
[ 86.7s] consumers=0.0 backlog queued=3.0 oldest age=77.2 s, alerts: {'MessengerQueueLagGrowing': 'pending', 'MessengerWorkerNoConsumers': 'pending'}
[ 91.8s] consumers=0.0 backlog queued=3.0 oldest age=87.2 s, alerts: {'MessengerQueueLagGrowing': 'pending', 'MessengerWorkerNoConsumers': 'pending'}
[ 96.8s] consumers=0.0 backlog queued=3.0 oldest age=87.2 s, alerts: {'MessengerQueueLagGrowing': 'pending', 'MessengerWorkerNoConsumers': 'pending'}
[ 101.8s] ALERT MessengerWorkerNoConsumers firing (101.7 s after stop)
[ 101.8s] consumers=0.0 backlog queued=3.0 oldest age=97.2 s, alerts: {'MessengerQueueLagGrowing': 'pending', 'MessengerWorkerNoConsumers': 'firing'}
[ 106.8s] consumers=0.0 backlog queued=3.0 oldest age=97.2 s, alerts: {'MessengerQueueLagGrowing': 'pending', 'MessengerWorkerNoConsumers': 'firing'}
[ 111.8s] consumers=0.0 backlog queued=3.0 oldest age=107.2 s, alerts: {'MessengerQueueLagGrowing': 'pending', 'MessengerWorkerNoConsumers': 'firing'}
[ 116.8s] consumers=0.0 backlog queued=3.0 oldest age=107.2 s, alerts: {'MessengerQueueLagGrowing': 'pending', 'MessengerWorkerNoConsumers': 'firing'}
[ 121.8s] consumers=0.0 backlog queued=3.0 oldest age=117.3 s, alerts: {'MessengerQueueLagGrowing': 'pending', 'MessengerWorkerNoConsumers': 'firing'}
[ 126.9s] consumers=0.0 backlog queued=3.0 oldest age=117.3 s, alerts: {'MessengerQueueLagGrowing': 'pending', 'MessengerWorkerNoConsumers': 'firing'}
[ 131.9s] ALERT MessengerQueueLagGrowing firing (131.8 s after stop)
[ 132.0s] diagnosis: {"queue_consumers": 0.0, "broker_queue_depth": 6.0, "jobs_backlog_queued": 3.0, "oldest_job_age_s": 127.3, "outbox_oldest_age_s": 0.0, "published_ok_last_5m": 16.41239671427261, "worker_metrics_last_seen_s": 131.0, "last_worker_log": {"event": "service.stopped", "message": "stopped"}, "upload_trace_span_names": ["INSERT", "NOTIFY", "POST /api/v1/chats/{chat_id}/attachments", "S3 PutObject", "SELECT", "UPDATE", "create attachments", "inspect image", "publish attachments", "redis GET", "republish lost message"], "upload_trace_has_consumer_span": false}
[ 135.3s] docker compose start worker
[ 136.6s] all attachments ready 4.7 s after worker start; backlog now 3.0
[ 136.6s] ... MessengerWorkerNoConsumers: firing (0 s)
[ 141.6s] ... MessengerWorkerNoConsumers: firing (5 s)
[ 146.6s] ... MessengerWorkerNoConsumers: firing (10 s)
[ 151.7s] ... MessengerWorkerNoConsumers: firing (15 s)
[ 156.7s] ... MessengerWorkerNoConsumers: firing (20 s)
[ 161.7s] alerts resolved: {'MessengerWorkerNoConsumers': 29.7, 'MessengerQueueLagGrowing': 29.7}; now {'jobs_backlog_queued': 0.0, 'oldest_job_age_s': 0.0, 'queue_consumers': 2.0}
[ 161.7s] saved C:\Users\Gigabyte\Desktop\lab6\mtusi2026lab6\evidence\incident-worker-stop.json
PASS: worker stop -> no consumers + growing queue lag -> firing; cause from metrics/logs/trace; start -> backlog drained -> resolved
1 passed, 0 failed
+8
View File
@@ -0,0 +1,8 @@
# jobs-concurrency: lab5: WORKER_CONCURRENCY consumers, prefetch 1, bounded processing
# date: 2026-11-01 20:38:38, commit: 470d9d6 + uncommitted changes
# command: python.exe student-tests/test_jobs.py concurrency
# exit code: 0, 15.8 s
--- concurrency: Ограниченная конкуренция: WORKER_CONCURRENCY потребителей с prefetch=1; одновременно processing <= 2.
2 consumers, prefetch_count 1, manual ack; 8 queued 3000x2000 JPEG drained in 2.4 s after worker start, peak processing 2 of 8 (6 samples)
1 passed, 0 failed
+15
View File
@@ -0,0 +1,15 @@
# jobs-crash: lab5: worker crash after S3 PUT / after COMMIT before ack, staging cleanup, frozen worker lease
# date: 2026-11-01 20:33:58, commit: 470d9d6 + uncommitted changes
# command: python.exe student-tests/test_jobs.py crash-after-put crash-after-commit staging lease
# exit code: 0, 157.0 s
--- crash-after-put: Worker падает после записи объектов в S3, до COMMIT/ack: повтор завершает тот же результат.
worker killed after S3 PUT (before COMMIT and ack): redelivery saw a live lease (no-op), lease expired after 15 s, attempt 2 rewrote the same keys -> one set; events ['created', 'claimed', 'duplicate_ignored', 'lease_expired', 'claimed', 'ready']
--- crash-after-commit: Worker падает после COMMIT результата, до ack: повторная доставка ready-задачи — no-op с ack.
worker killed after COMMIT, before ack: broker redelivered, worker acked as no-op (1:duplicate_ignored:status=ready); queue empty (0 ready, 0 unacked)
--- staging: Janitor доделывает очистку staging, если worker упал до неё (после crash-after-commit).
staging source still present after the crash (worker died before cleanup); waiting 60 s window
janitor removed the staging source of the ready attachment (this pass); source_key NULL, object gone
--- lease: Зависший worker: аренда не продлевается -> dispatcher возвращает job -> другой поток завершает;
frozen attempt 1 stopped renewing; lease expired, recovered by dispatcher, attempt 2 ready after 17 s; frozen attempt woke up -> stale_result_rejected; events ['created', 'claimed', 'lease_expired', 'claimed', 'ready', 'stale_result_rejected']
4 passed, 0 failed
+13
View File
@@ -0,0 +1,13 @@
# jobs-janitor-replay: lab5: janitor does not delete objects re-written by replay (review fix)
# date: 2026-11-01 20:38:23, commit: 470d9d6 + uncommitted changes
# command: python.exe student-tests/test_janitor_replay.py
# exit code: 0, 187.0 s
race-replayable: failed/retry_exhausted after a crash post-PUT; leftover objects ['v1/crop.jpg', 'v1/optimized.webp', 'v1/original', 'v1/thumbnail.jpg']
race-terminal: failed/retry_exhausted after a crash post-PUT; leftover objects ['v1/crop.jpg', 'v1/optimized.webp', 'v1/original', 'v1/thumbnail.jpg']
waiting 86 s until the leftovers are older than grace (120 s)
janitor pass over the bucket: did not try to delete any object of the replayable failed attachment
ops replay -> job 09f5cf6c-bca3-4759-9930-8d18968ed1be ready
after the janitor pass: original/thumbnail/crop/optimized -> 200, 4 objects in S3; janitor report: orphans 0, deleted 0
retention expired (STAGING_RETENTION_SECONDS=1 for this pass): staging source removed, leftovers of the failed attachment swept; replay refused: "source file is no longer in staging (retention expired)"
1 passed, 0 failed
+11
View File
@@ -0,0 +1,11 @@
# jobs-limits: lab5: worker limits - bytes, pixels, memory (RLIMIT_AS), time (JOB_TIMEOUT_SECONDS)
# date: 2026-11-01 20:30:08, commit: 470d9d6 + uncommitted changes
# command: python.exe student-tests/test_jobs.py limits
# exit code: 0, 72.7 s
--- limits: Лимиты: bytes и пиксели на API; память/пиксели/время процесса обработки на worker.
10 MiB + 8 bytes -> 413 before any job is created
imaging.py on 8000x5000 PNG: exit 0, peak RSS 226.9 MiB (RLIMIT_AS 512 MiB); same file with MAX_IMAGE_PIXELS=10M -> exit 4 (image_too_large)
memory bomb in the imaging process -> failed/resource_limit after attempt 1; worker itself survived
imaging hang -> killed after 60 s (processing_timeout, temporary), lease renewed meanwhile (no lease_expired), attempt 2 ready after 62 s
1 passed, 0 failed
+9
View File
@@ -0,0 +1,9 @@
# jobs-outbox: lab5: dispatcher crash between COMMIT and publish / after confirm
# date: 2026-11-01 20:31:21, commit: 470d9d6 + uncommitted changes
# command: python.exe student-tests/test_jobs.py outbox-crash
# exit code: 0, 17.2 s
--- outbox-crash: Разрыв COMMIT/publish: dispatcher падает после COMMIT задания до publish и после confirm до отметки.
dispatcher killed between COMMIT and publish; restarted by policy, outbox re-published -> job d1eb476a-fbe1-4271-861f-74f3e943b8cc ready, attempt 1, no manual action
dispatcher killed after publisher confirm, before marking outbox -> message published twice; worker: ['created', 'claimed', 'ready', 'duplicate_ignored'] -> one result set
1 passed, 0 failed
+16
View File
@@ -0,0 +1,16 @@
# jobs-recovery: lab5: worker down -> 202 -> restart api+broker -> ready; broker down -> outbox waits
# date: 2026-11-01 20:31:04, commit: 470d9d6 + uncommitted changes
# command: python.exe student-tests/test_jobs.py worker-down broker-down
# exit code: 0, 55.2 s
--- worker-down: Защита п.2-3: worker остановлен -> 202 -> сообщение с вложением -> рестарт API+broker -> worker -> ready.
worker stopped
upload while worker is down -> 202 queued, attachment 0d7622f1-7c85-4c52-9dc0-2dad8f729c8d
message with attachment 201, content 409, other messages 201; job 6a45774d-0d88-46ec-87b9-70fb4c122bbd published, queue messages/unacked = (1, 0)
rabbitmq and api restarted with volumes; queue still holds 1 message(s); status queued
worker started -> same job 6a45774d-0d88-46ec-87b9-70fb4c122bbd ready, thumbnail downloadable; staging object deleted
--- broker-down: Брокер недоступен: API принимает (outbox), dispatcher копит и публикует после восстановления.
rabbitmq stopped
upload -> 202 and /health/ready 200 without broker; outbox row pending for job 34eb3c30-1942-4777-bce2-1ea2a4eca4c9
rabbitmq started -> dispatcher published the pending row -> ready
2 passed, 0 failed
+15
View File
@@ -0,0 +1,15 @@
# jobs-retry: lab5: backoff+jitter, retry_exhausted, replay, permanent errors, DLQ
# date: 2026-11-01 20:35:16, commit: 470d9d6 + uncommitted changes
# command: python.exe student-tests/test_jobs.py retry exhausted-replay permanent dlq
# exit code: 0, 77.6 s
--- retry: Временные ошибки S3: backoff с jitter, затем ready; задержки видны в журнале.
2 x storage_unavailable -> retries after 1.90 s and 3.20 s (equal jitter: 1..2 s, 2..4 s), attempt 3 ready
--- exhausted-replay: Исчерпание попыток -> failed/retry_exhausted, реестр failed, явный replay; replay ready — отказ.
5 temporary errors -> failed/retry_exhausted (public error_code), content 409, attach 409, listed by ops.py failed (replayable)
ops replay -> same job_id d8ab860c-eb40-4df2-8d98-67aade24f2f2 attempt 6 ready; second replay refused: "job is ready, replay is only for failed jobs"
--- permanent: Постоянная ошибка (битое изображение в worker) -> failed сразу, без повторов.
invalid image in the worker -> failed/invalid_image at attempt 1, no retry (permanent error)
--- dlq: Невалидные сообщения и сообщения о неизвестной job -> DLQ; dlq-replay их не исполняет.
schema-invalid message and unknown job_id -> reject -> DLQ (2 message(s)); dlq-replay kept them: ['invalid message is kept for analysis', 'unknown job']
4 passed, 0 failed
+14
View File
@@ -0,0 +1,14 @@
# jobs-variants: lab5: thumbnail/crop/optimized, EXIF orientation, alpha, no upscale, metadata stripped
# date: 2026-11-01 20:28:56, commit: 470d9d6 + uncommitted changes
# command: python.exe student-tests/test_jobs.py variants
# exit code: 0, 20.1 s
--- variants: thumbnail/crop/optimized по контракту, EXIF orientation, alpha -> белый, без увеличения, без метаданных.
thumb320: thumbnail 256x160, crop 128x128, optimized 320x200; original byte-identical; EXIF/XMP in variants: 0; S3 keys ['v1/crop.jpg', 'v1/optimized.webp', 'v1/original', 'v1/thumbnail.jpg']
exif6: thumbnail 192x256, crop 128x128, optimized 300x400; original byte-identical; EXIF/XMP in variants: 0; S3 keys ['v1/crop.jpg', 'v1/optimized.webp', 'v1/original', 'v1/thumbnail.jpg']
alpha: thumbnail 256x170, crop 128x128, optimized 300x200; original byte-identical; EXIF/XMP in variants: 0; S3 keys ['v1/crop.jpg', 'v1/optimized.webp', 'v1/original', 'v1/thumbnail.jpg']
tiny: thumbnail 40x30, crop 128x128, optimized 40x30; original byte-identical; EXIF/XMP in variants: 0; S3 keys ['v1/crop.jpg', 'v1/optimized.webp', 'v1/original', 'v1/thumbnail.jpg']
large: thumbnail 256x170, crop 128x128, optimized 1280x853; original byte-identical; EXIF/XMP in variants: 0; S3 keys ['v1/crop.jpg', 'v1/optimized.webp', 'v1/original', 'v1/thumbnail.jpg']
strip: thumbnail 256x1, crop 128x128, optimized 1280x1; original byte-identical; EXIF/XMP in variants: 0; S3 keys ['v1/crop.jpg', 'v1/optimized.webp', 'v1/original', 'v1/thumbnail.jpg']
unknown variant name -> 400; variants carry their own size/sha256, original fields describe the upload
1 passed, 0 failed
+17
View File
@@ -0,0 +1,17 @@
{
"lab": 6,
"workload": "closed-loop POST messages; no automatic retries",
"requested_duration_seconds": 30.0,
"elapsed_seconds": 30.031,
"concurrency": 4,
"successful_requests": 7178,
"failed_requests": 0,
"error_ratio": 0.0,
"successful_rps": 239.02,
"successful_latency_ms": {
"p50": 16.0,
"p95": 32.0,
"p99": 47.0
},
"note": "Latency percentiles cover successes only. Timeouts/errors are counted separately; closed-loop has coordinated omission and client overhead."
}
+22
View File
@@ -0,0 +1,22 @@
# load: public load generator, 30 s, concurrency 4
# date: 2026-11-01 20:44:10, commit: 470d9d6 + uncommitted changes
# command: python.exe tests/load.py --base-url http://127.0.0.1:8080 --duration 30 --concurrency 4 --output evidence/load.json
# exit code: 0, 30.3 s
{
"lab": 6,
"workload": "closed-loop POST messages; no automatic retries",
"requested_duration_seconds": 30.0,
"elapsed_seconds": 30.031,
"concurrency": 4,
"successful_requests": 7178,
"failed_requests": 0,
"error_ratio": 0.0,
"successful_rps": 239.02,
"successful_latency_ms": {
"p50": 16.0,
"p95": 32.0,
"p99": 47.0
},
"note": "Latency percentiles cover successes only. Timeouts/errors are counted separately; closed-loop has coordinated omission and client overhead."
}
+96
View File
@@ -0,0 +1,96 @@
# attachments: lab4: files, limits, damaged images, MIME, filenames, access, attachment_ids
# date: 2026-11-01 00:52:47, commit: unknown
# command: python student-tests/test_attachments.py
# exit code: 0, 13.5 s
sample.png: 111817 bytes, sha256 99ea7533c441..., downloaded by the other member, same bytes
sample.jpg: 1492 bytes, sha256 c310b9a1c208..., downloaded by the other member, same bytes
progressive.jpg: 1081 bytes, sha256 913df01aec84..., downloaded by the other member, same bytes
interlaced.png: 79 bytes, sha256 38149222f78f..., downloaded by the other member, same bytes
1x1.png: 67 bytes, sha256 eaa4a94ea300..., downloaded by the other member, same bytes
PASS: PNG, JPEG, progressive JPEG, interlaced PNG and 1x1 PNG are stored and returned byte for byte
exactly 10485760 bytes (10 MiB) -> 202, then ready
10485761 bytes (10 MiB + 1) with Content-Length -> 413 before reading the body
PASS: the 10 MiB limit is exact
12 MiB without Content-Length (chunked) -> 413 as soon as the 10 MiB limit is passed
PASS: oversized streamed body is cut off, the API keeps working
8000x5000 = 40 000 000 pixels (38957 bytes compressed) -> 202, ready f30c028f
8001x5000 = 40 005 000 pixels (38962 bytes) -> 413
header claims 100000x100000 in 65 bytes -> 413 from the header, nothing is decoded
PASS: pixel limit is checked before decompression
PNG cut in half (55908 bytes, image/png) -> 415
PNG without IEND (111805 bytes, image/png) -> 415
PNG with a flipped byte in IDAT (CRC mismatch) (111817 bytes, image/png) -> 415
PNG with garbage after IEND (111824 bytes, image/png) -> 415
PNG signature only (8 bytes, image/png) -> 415
PNG with less pixel data than the header says (70 bytes, image/png) -> 415
JPEG cut in half (746 bytes, image/jpeg) -> 415
JPEG header only (20 bytes, image/jpeg) -> 415
random bytes (1600 bytes, image/png) -> 415
plain text (28 bytes, image/jpeg) -> 415
empty body -> 400
PASS: damaged and foreign files are rejected with 415, never 500
PLTE 771 bytes = 257 entries (review case) (850 bytes, valid CRCs) -> 415
PLTE length not a multiple of 3 (83 bytes, valid CRCs) -> 415
empty PLTE (79 bytes, valid CRCs) -> 415
palette larger than bit depth allows (depth 1, 3 entries) (88 bytes, valid CRCs) -> 415
palette image without PLTE (67 bytes, valid CRCs) -> 415
PLTE in a grayscale image (85 bytes, valid CRCs) -> 415
PLTE after IDAT (85 bytes, valid CRCs) -> 415
two PLTE chunks (103 bytes, valid CRCs) -> 415
tRNS longer than the palette (100 bytes, valid CRCs) -> 415
tRNS before PLTE (98 bytes, valid CRCs) -> 415
tRNS of wrong size for RGB (4 bytes instead of 6) (85 bytes, valid CRCs) -> 415
tRNS in an image with alpha channel (84 bytes, valid CRCs) -> 415
IEND with data (70 bytes, valid CRCs) -> 415
unknown critical chunk (81 bytes, valid CRCs) -> 415
IDAT chunks not consecutive (95 bytes, valid CRCs) -> 415
gAMA after IDAT (85 bytes, valid CRCs) -> 415
gAMA of 2 bytes instead of 4 (83 bytes, valid CRCs) -> 415
3 MiB metadata chunk before IDAT (3145809 bytes, valid CRCs) -> 415
private chunk after IDAT (181 bytes, valid CRCs) -> 415
animated PNG frame (fdAT) (91 bytes, valid CRCs) -> 415
tIME of 2 bytes instead of 7 (83 bytes, valid CRCs) -> 415
tEXt without keyword separator (86 bytes, valid CRCs) -> 415
zTXt with broken zlib after IDAT (91 bytes, valid CRCs) -> 415
zTXt text bomb: 50 MB of text in ~50 KB after IDAT (48694 bytes, valid CRCs) -> 415
palette 256 entries + tRNS + tEXt and tIME after IDAT -> 201, downloaded byte for byte
palette depth 2 with 4 entries -> 201, downloaded byte for byte
RGB with 6-byte tRNS and gAMA -> 201, downloaded byte for byte
compressed zTXt (100 KB of text) and iTXt after IDAT -> 201, downloaded byte for byte
PASS: chunk contents are checked, not only CRCs; valid PNGs with metadata are still accepted
PNG bytes sent as image/jpeg -> 415
JPEG bytes sent as image/png -> 415
GIF bytes sent as image/png -> 415
PNG sent as image/gif -> 415
PNG sent as text/html -> 415
PNG sent as application/octet-stream -> 415
PNG sent as multipart/form-data -> 415
PNG sent as 'IMAGE/PNG; charset=binary' -> 201, stored as image/png
PASS: the type is taken from the content; a declared type that does not match is refused
13 dangerous or invalid names (path, slashes, NUL, control characters, empty, 256 chars) -> 400
no filename -> 400
Unicode, 255 chars, leading dots, %20 and ? are kept as display names only
PASS: filename never becomes a path; dangerous names are refused
outsider -> 404 for metadata and bytes (same as a non-existent id); no token -> 401; bad UUID -> 400
upload into someone else's / unknown chat -> 404, without token -> 401
variant=preview -> 400 (not in the contract); original/thumbnail/crop/optimized -> 200 (lab5)
PASS: only chat members can see an attachment
text='' with 2 attachments -> 201, order kept; any member may attach a file uploaded by another member
history returns attachment_ids for every message, [] for a message without files; reuse is allowed
attachment of another chat (author is a member of both) -> 404
own + foreign attachment -> 404
unknown attachment_id -> 404
outsider referencing an attachment of the chat -> 404
duplicate ids -> 400
11 ids -> 400
bad UUID -> 400
empty text without attachments -> 400
whitespace text without attachments -> 400
PASS: only attachments of the same chat can be linked; rejected requests change nothing
same key + same attachments -> same 201; other attachments -> 409; missing field == []
PASS: Idempotency-Key covers attachment_ids
sent 1.1 MB of a declared 5 MB body and closed the connection
the API keeps serving uploads; nothing of the aborted request is visible (DB/S3 side is checked by test_consistency.py)
PASS: an interrupted upload is dropped
12 passed, 0 failed
+6
View File
@@ -0,0 +1,6 @@
# check: offline contract check (make check)
# date: 2026-11-01 00:22:29, commit: unknown
# command: python scripts/check_contract.py
# exit code: 0, 0.1 s
PASS: offline skeleton structure, local refs and Python syntax; application NOT tested.
+28
View File
@@ -0,0 +1,28 @@
# configs: lab6: collector/prometheus/loki/tempo configs by their own tools, alert unit tests, Grafana provisioning
# date: 2026-11-01 00:22:31, commit: unknown
# command: python student-tests/check_configs.py
# exit code: 0, 0.7 s
--- otelcol-contrib validate (infra/otel/collector.yaml): exit 0
--- promtool check config (infra/prometheus/prometheus.yml): exit 0
Checking /home/claude/work/mtusi2026lab6/infra/prometheus/rules/alerts.yml
SUCCESS: 6 rules found
Checking /home/claude/work/mtusi2026lab6/infra/prometheus/rules/recording.yml
SUCCESS: 10 rules found
--- promtool check rules (recording + alerts): exit 0
Checking /home/claude/work/mtusi2026lab6/infra/prometheus/rules/alerts.yml
SUCCESS: 6 rules found
Checking /home/claude/work/mtusi2026lab6/infra/prometheus/rules/recording.yml
SUCCESS: 10 rules found
--- promtool test rules (unit tests of alert thresholds/windows/for): exit 0
SUCCESS
--- loki -verify-config (infra/loki/loki.yaml): exit 0
--- tempo -config.verify (infra/tempo/tempo.yaml): exit 0
--- Grafana: not reachable at http://127.0.0.1:3000, skipped (local binaries mode)
PASS: collector, prometheus (config, rules, unit tests), loki and tempo configs are valid
+36
View File
@@ -0,0 +1,36 @@
# dashboard: lab6: every dashboard/rule query runs on live data, key signals present, no forbidden labels
# date: 2026-11-01 00:23:49, commit: unknown
# command: python student-tests/check_dashboard.py
# exit code: 0, 0.5 s
PromQL: 54 dashboard expressions + 16 rule expressions executed, 0 errors, 15 empty now (no traffic of that kind / Docker-only / no incident)
empty now: CPU контейнеров / лимит
empty now: Collector: потери и отказы
empty now: SDK приложений: экспорт и потери
empty now: alerts.yml: MessengerDbPoolSaturated
empty now: alerts.yml: MessengerHighErrorRate
empty now: alerts.yml: MessengerQueueLagGrowing
empty now: alerts.yml: MessengerWorkerNoConsumers
empty now: alerts.yml: TelemetryCollectorDown
empty now: alerts.yml: TelemetryExportFailing
empty now: Алерты Prometheus (pending/firing)
empty now: Память: RSS процесса и контейнер
LogQL ok: Предупреждения и ошибки (Loki): {service_name=~"messenger-.*"} | detected_level=~"warn|error"
TraceQL ok: Трассы с ошибками (Tempo, TraceQL): { status = error } -> 5 trace(s)
data: http_server_request_duration_seconds_count{job="messenger-api"} 39 series <- HTTP requests/duration (3)
data: messenger_job_duration_seconds_count 3 series <- jobs processed/failed + duration (3)
data: messenger_attachment_time_to_ready_seconds_count 1 series <- end-to-end time to ready (4)
data: messenger_queue_depth 2 series <- queue depth (4)
data: messenger_queue_oldest_age_seconds 1 series <- oldest job age (4)
data: db_client_connection_count 4 series <- DB pool used/idle (4)
data: db_client_connection_pending_requests 2 series <- DB pool waiting (4)
data: messenger_worker_busy 1 series <- worker busy (4)
data: messenger_worker_capacity 1 series <- worker capacity (4)
data: process_cpu_time_seconds_total 12 series <- process CPU (4)
data: process_memory_usage_bytes 6 series <- process RAM (4)
data: otelcol_exporter_queue_size 3 series <- collector queue (4)
labels used by application metrics: __name__, cpu_mode, db_client_connection_pool_name, db_client_connection_state, deployment_environment_name, error_type, http_request_method, http_response_status_class, http_response_status_code, http_route, instance, job, job_type, le, messaging_destination_name, otel_component_name, otel_component_type, otel_span_parent_origin, otel_span_sampling_result, outcome, server_address, server_port, service_version, status, telemetry_sdk_language, telemetry_sdk_name, telemetry_sdk_version
http_route values (templates, not URLs): ['/api/v1/attachments/{attachment_id}', '/api/v1/attachments/{attachment_id}/content', '/api/v1/auth/sessions', '/api/v1/auth/sessions/current', '/api/v1/chats', '/api/v1/chats/{chat_id}', '/api/v1/chats/{chat_id}/attachments', '/api/v1/chats/{chat_id}/messages', '/api/v1/users', '/api/v1/users/me', '/health/live', '/health/ready']
PASS: every dashboard/rule query runs, key signals have data, no forbidden labels
+22
View File
@@ -0,0 +1,22 @@
# idempotency: Idempotency-Key, parallel same key via replicas
# date: 2026-11-01 00:52:50, commit: unknown
# command: python student-tests/test_idempotency.py
# exit code: 0, 2.2 s
first -> 201; same JSON written differently -> 201; plain retry -> 201
PASS: a retry with the same key returns the original 201 and message, no duplicate
20 parallel POSTs with one key: statuses {201: 20}, replicas {'a1a1a1a1a1a1': 10, 'a2a2a2a2a2a2': 10}, different bodies in answers: 1, messages in history: 1
PASS: parallel requests with one key through different replicas create exactly one message
20 parallel POSTs, one key, two different bodies: {('body A', 409): 10, ('body B', 201): 10}; saved: ['body B']
PASS: the first body wins, the same body gets 201, the other body gets 409
one key: alice in chat 1, bob in chat 1, alice in chat 2 -> 3 messages
PASS: the key is scoped to the current user and chat; another body with a used key -> 409
missing, empty, 129 chars, space, '/', non-ASCII, '"', '+' -> 400; 128 chars of A-Z a-z 0-9 . _ : - -> 201
PASS: Idempotency-Key is required and checked: [A-Za-z0-9._:-]{1,128}
key used by a 400 and by a 404 first, then valid request -> 201
PASS: rejected requests (400, 404) do not store a result for the key
same key and body by an outsider -> 404; by alice after logout -> 401
PASS: a retry checks the session and chat access again, the saved answer is not leaked
POST sent, connection closed without reading the answer; retry -> 201; messages: 1
PASS: an unconfirmed POST can be safely retried with the same key
8 passed, 0 failed
@@ -0,0 +1,39 @@
{
"scenario": "collector-down",
"date": "2026-11-01 00:39:14",
"outage_s": 90,
"baseline": {
"requests": 1002,
"codes": {
"201": 1002
},
"success_ratio": 1.0,
"success_rps": 66.8,
"p95_ms_successful": 15.2
},
"during": {
"requests": 6263,
"codes": {
"201": 6263
},
"success_ratio": 1.0,
"success_rps": 67.4,
"p95_ms_successful": 14.3
},
"api_mib_before": 280.5,
"api_mib_max": 292.5,
"sdk_lost_spans_api": {
"processor_queue_full": 0,
"exporter_failed": 24576
},
"sdk_exported_ok_after_restart": 10524,
"after": {
"requests": 1703,
"codes": {
"201": 1703
},
"success_ratio": 1.0,
"success_rps": 68.1,
"p95_ms_successful": 13.8
}
}
@@ -0,0 +1,22 @@
# incident-collector: lab6: Collector down -> API unaffected, SDK queue bounded, drops counted
# date: 2026-11-01 00:41:37, commit: unknown
# command: python student-tests/incidents.py collector-down
# exit code: 0, 143.3 s
=== collector-down
[ 20.3s] baseline: {'requests': 1002, 'codes': {'201': 1002}, 'success_ratio': 1.0, 'success_rps': 66.8, 'p95_ms_successful': 15.2}, api containers 280.5 MiB
[ 20.6s] docker compose stop otel-collector
[ 20.8s] {'t': 0.3, 'api_mib': 283.0}
[ 31.0s] {'t': 10.5, 'api_mib': 283.2}
[ 41.3s] {'t': 20.8, 'api_mib': 288.6}
[ 51.5s] {'t': 31.0, 'api_mib': 289.0}
[ 61.7s] {'t': 41.2, 'api_mib': 289.7}
[ 71.9s] {'t': 51.4, 'api_mib': 292.5}
[ 82.1s] {'t': 61.6, 'api_mib': 292.4}
[ 92.4s] {'t': 71.9, 'api_mib': 292.3}
[ 102.6s] {'t': 82.1, 'api_mib': 291.2}
[ 113.2s] docker compose start otel-collector
[ 143.2s] API during collector outage: {'requests': 6263, 'codes': {'201': 6263}, 'success_ratio': 1.0, 'success_rps': 67.4, 'p95_ms_successful': 14.3}; api memory 280.5 -> max 292.5 MiB; SDK lost spans (api): {'processor_queue_full': 0, 'exporter_failed': 24576}; exported OK in the last minute after restart: 10524
[ 143.2s] saved /home/claude/work/mtusi2026lab6/evidence/native-sandbox/incident-collector-down.json
PASS: Collector down -> API unaffected, SDK memory bounded, lost spans counted, export resumes after start
1 passed, 0 failed
@@ -0,0 +1,82 @@
{
"scenario": "db-slow",
"date": "2026-11-01 00:42:49",
"lock_seconds": 210,
"baseline": {
"requests": 2648,
"codes": {
"201": 2648
},
"success_ratio": 1.0,
"success_rps": 132.4,
"p95_ms_successful": 18.5,
"server_p95_s": 0.0214
},
"firing_after_lock_s": 120.1,
"diagnosis": {
"http_5xx_ratio_1m": 1.0,
"http_p95_messages_s": 7.375,
"pool_used": 8.0,
"pool_wait_p95_s": 0.001,
"status_codes_1m": {
"201": 0.0,
"200": 0.0,
"404": 0.0,
"400": 0.0,
"409": 0.0,
"503": 1.6
},
"reads_during_lock_ms": {
"GET /users/me + GET /chats, avg per request": 4.7,
"max": 5.4
},
"api_log_db_unavailable_by_error_type": {
"QueryCanceled": 184
},
"error_trace": {
"trace_id": "1c7f8dd06427574a5f155558aa4cd975",
"server_ms": 5006.7,
"slowest_db_span": "INSERT",
"slowest_db_ms": 5000.6,
"db_span_status": "ERROR",
"db_share": 0.999,
"tree": [
"- [api] POST /api/v1/chats/{chat_id}/messages (SERVER, 5006.7 ms) ERROR http.response.status_code=503 error.type=503",
" - [api] redis GET (CLIENT, 0.2 ms)",
" - [api] SELECT (CLIENT, 0.4 ms)",
" - [api] INSERT (CLIENT, 5000.6 ms) ERROR"
]
},
"handler_cpu_contrast": {
"trace_id": "a6da2e3fe7b0c229773f36fa507293ca",
"server_ms": 34.0,
"argon2id_ms": 29.0,
"db_ms_total": 0.6,
"tree": [
"- [api] POST /api/v1/users (SERVER, 34.0 ms) http.response.status_code=201",
" - [api] argon2id hash (INTERNAL, 29.0 ms)",
" - [api] INSERT (CLIENT, 0.6 ms)"
]
}
},
"during_lock": {
"requests": 326,
"codes": {
"503": 320,
"201": 6
},
"success_ratio": 0.0184,
"success_rps": 0.0,
"p95_ms_successful": 2718.4
},
"resolved_after_unlock_s": 30.0,
"after": {
"requests": 3298,
"codes": {
"201": 3298
},
"success_ratio": 1.0,
"success_rps": 131.9,
"p95_ms_successful": 21.0
}
}
+56
View File
@@ -0,0 +1,56 @@
# incident-db: lab6 incident 2: slow PostgreSQL (table lock) -> high error rate firing, cause from traces -> resolved
# date: 2026-11-01 00:47:15, commit: unknown
# command: python student-tests/incidents.py db-slow
# exit code: 0, 265.4 s
=== db-slow
[ 0.1s] load: 8 threads POST /messages
[ 25.1s] baseline: {'requests': 2648, 'codes': {'201': 2648}, 'success_ratio': 1.0, 'success_rps': 132.4, 'p95_ms_successful': 18.5, 'server_p95_s': 0.0214}
[ 25.1s] LOCK TABLE messages IN ACCESS EXCLUSIVE MODE for 210 s (PostgreSQL alive, writes wait)
[ 25.1s] 5xx ratio=0.0 p95=0.021 s pool used=0.0 waiting=0.0
[ 30.1s] 5xx ratio=0.0 p95=0.022 s pool used=8.0 waiting=0.0
[ 35.1s] 5xx ratio=0.0 p95=0.022 s pool used=8.0 waiting=0.0
[ 40.1s] 5xx ratio=0.0 p95=0.022 s pool used=8.0 waiting=0.0
[ 45.1s] 5xx ratio=0.005 p95=0.022 s pool used=8.0 waiting=0.0
[ 50.1s] 5xx ratio=0.005 p95=0.023 s pool used=8.0 waiting=0.0
[ 55.1s] 5xx ratio=0.005 p95=0.023 s pool used=8.0 waiting=0.0
[ 60.1s] 5xx ratio=0.01 p95=0.024 s pool used=8.0 waiting=0.0
[ 65.1s] 5xx ratio=0.01 p95=0.024 s pool used=8.0 waiting=0.0
[ 70.1s] 5xx ratio=0.01 p95=5.688 s pool used=8.0 waiting=0.0
[ 75.2s] 5xx ratio=0.069 p95=5.688 s pool used=8.0 waiting=0.0
[ 80.2s] 5xx ratio=0.069 p95=7.375 s pool used=8.0 waiting=0.0
[ 85.2s] 5xx ratio=0.069 p95=7.375 s pool used=8.0 waiting=0.0
[ 90.2s] 5xx ratio=1.0 p95=7.375 s pool used=8.0 waiting=0.0
[ 95.2s] 5xx ratio=1.0 p95=7.375 s pool used=8.0 waiting=0.0
[ 100.2s] 5xx ratio=1.0 p95=7.375 s pool used=8.0 waiting=0.0
[ 105.2s] 5xx ratio=1.0 p95=7.375 s pool used=8.0 waiting=0.0
[ 110.2s] 5xx ratio=1.0 p95=7.375 s pool used=8.0 waiting=0.0
[ 115.2s] 5xx ratio=1.0 p95=7.375 s pool used=8.0 waiting=0.0
[ 120.2s] 5xx ratio=1.0 p95=7.375 s pool used=8.0 waiting=0.0
[ 125.2s] 5xx ratio=1.0 p95=7.375 s pool used=8.0 waiting=0.0
[ 130.2s] 5xx ratio=1.0 p95=7.375 s pool used=8.0 waiting=0.0
[ 135.2s] 5xx ratio=1.0 p95=7.375 s pool used=8.0 waiting=0.0
[ 140.2s] 5xx ratio=1.0 p95=7.375 s pool used=8.0 waiting=0.0
[ 145.2s] ALERT MessengerHighErrorRate firing (120.1 s after lock)
[ 151.5s] diagnosis: {"http_5xx_ratio_1m": 1.0, "http_p95_messages_s": 7.375, "pool_used": 8.0, "pool_wait_p95_s": 0.001, "status_codes_1m": {"201": 0.0, "200": 0.0, "404": 0.0, "400": 0.0, "409": 0.0, "503": 1.6}, "reads_during_lock_ms": {"GET /users/me + GET /chats, avg per request": 4.7, "max": 5.4}, "api_log_db_unavailable_by_error_type": {"QueryCanceled": 184}}
[ 151.5s] error trace (DB): {"trace_id": "1c7f8dd06427574a5f155558aa4cd975", "server_ms": 5006.7, "slowest_db_span": "INSERT", "slowest_db_ms": 5000.6, "db_span_status": "ERROR", "db_share": 0.999}
- [api] POST /api/v1/chats/{chat_id}/messages (SERVER, 5006.7 ms) ERROR http.response.status_code=503 error.type=503
- [api] redis GET (CLIENT, 0.2 ms)
- [api] SELECT (CLIENT, 0.4 ms)
- [api] INSERT (CLIENT, 5000.6 ms) ERROR
[ 151.5s] contrast, slow handler (CPU): {"trace_id": "a6da2e3fe7b0c229773f36fa507293ca", "server_ms": 34.0, "argon2id_ms": 29.0, "db_ms_total": 0.6}
- [api] POST /api/v1/users (SERVER, 34.0 ms) http.response.status_code=201
- [api] argon2id hash (INTERNAL, 29.0 ms)
- [api] INSERT (CLIENT, 0.6 ms)
[ 235.4s] lock released (psql exit 0), 210.3 s after LOCK
[ 235.4s] ... MessengerHighErrorRate: firing (0 s)
[ 240.4s] ... MessengerHighErrorRate: firing (5 s)
[ 245.4s] ... MessengerHighErrorRate: firing (10 s)
[ 250.4s] ... MessengerHighErrorRate: firing (15 s)
[ 255.4s] ... MessengerHighErrorRate: firing (20 s)
[ 260.4s] ... MessengerHighErrorRate: firing (25 s)
[ 265.4s] ALERT MessengerHighErrorRate resolved 30.0 s after unlock
[ 265.4s] load: during lock {'requests': 326, 'codes': {'503': 320, '201': 6}, 'success_ratio': 0.0184, 'success_rps': 0.0, 'p95_ms_successful': 2718.4}; after {'requests': 3298, 'codes': {'201': 3298}, 'success_ratio': 1.0, 'success_rps': 131.9, 'p95_ms_successful': 21.0}
[ 265.4s] saved /home/claude/work/mtusi2026lab6/evidence/native-sandbox/incident-db-slow.json
PASS: slow DB -> 503 -> MessengerHighErrorRate firing; traces show the time in the INSERT span (not the handler); unlock -> resolved
1 passed, 0 failed
@@ -0,0 +1,307 @@
{
"scenario": "telemetry-down",
"date": "2026-11-01 00:32:59",
"stopped": [
"tempo",
"loki"
],
"outage_s": 150,
"baseline": {
"requests": 955,
"codes": {
"201": 955
},
"success_ratio": 1.0,
"success_rps": 63.7,
"p95_ms_successful": 17.9
},
"collector_heap_before_mib": 44.1,
"collector_container_before_mib": 224.4,
"during": {
"requests": 11500,
"codes": {
"201": 11500
},
"success_ratio": 1.0,
"success_rps": 68.3,
"p95_ms_successful": 13.2
},
"samples": [
{
"t": 0.0,
"collector_heap_mib": 39.8,
"collector_rss_mib": 228.5,
"collector_container_mib": 228.6,
"queue": {
"otlp_http/loki": 0.0,
"otlp_http/prometheus": 0.0,
"otlp_grpc/tempo": 6.0
},
"alert": "inactive"
},
{
"t": 10.1,
"collector_heap_mib": 52.2,
"collector_rss_mib": 228.6,
"collector_container_mib": 228.6,
"queue": {
"otlp_http/loki": 5.0,
"otlp_http/prometheus": 0.0,
"otlp_grpc/tempo": 10.0
},
"alert": "inactive"
},
{
"t": 20.3,
"collector_heap_mib": 52.2,
"collector_rss_mib": 228.6,
"collector_container_mib": 228.7,
"queue": {
"otlp_http/loki": 5.0,
"otlp_http/prometheus": 0.0,
"otlp_grpc/tempo": 10.0
},
"alert": "inactive"
},
{
"t": 30.4,
"collector_heap_mib": 63.3,
"collector_rss_mib": 230.2,
"collector_container_mib": 233.6,
"queue": {
"otlp_http/loki": 12.0,
"otlp_http/prometheus": 0.0,
"otlp_grpc/tempo": 14.0
},
"alert": "inactive"
},
{
"t": 40.6,
"collector_heap_mib": 48.5,
"collector_rss_mib": 234.5,
"collector_container_mib": 234.5,
"queue": {
"otlp_http/loki": 20.0,
"otlp_http/prometheus": 0.0,
"otlp_grpc/tempo": 18.0
},
"alert": "pending"
},
{
"t": 50.7,
"collector_heap_mib": 48.5,
"collector_rss_mib": 234.5,
"collector_container_mib": 234.6,
"queue": {
"otlp_http/loki": 20.0,
"otlp_http/prometheus": 0.0,
"otlp_grpc/tempo": 18.0
},
"alert": "pending"
},
{
"t": 60.8,
"collector_heap_mib": 59.5,
"collector_rss_mib": 234.6,
"collector_container_mib": 234.9,
"queue": {
"otlp_http/loki": 27.0,
"otlp_http/prometheus": 0.0,
"otlp_grpc/tempo": 22.0
},
"alert": "pending"
},
{
"t": 71.0,
"collector_heap_mib": 70.7,
"collector_rss_mib": 239.4,
"collector_container_mib": 242.2,
"queue": {
"otlp_http/loki": 35.0,
"otlp_http/prometheus": 0.0,
"otlp_grpc/tempo": 26.0
},
"alert": "pending"
},
{
"t": 81.2,
"collector_heap_mib": 70.7,
"collector_rss_mib": 239.4,
"collector_container_mib": 247.4,
"queue": {
"otlp_http/loki": 35.0,
"otlp_http/prometheus": 0.0,
"otlp_grpc/tempo": 26.0
},
"alert": "pending"
},
{
"t": 91.3,
"collector_heap_mib": 58.1,
"collector_rss_mib": 247.4,
"collector_container_mib": 247.4,
"queue": {
"otlp_http/loki": 42.0,
"otlp_http/prometheus": 0.0,
"otlp_grpc/tempo": 30.0
},
"alert": "pending"
},
{
"t": 101.4,
"collector_heap_mib": 69.3,
"collector_rss_mib": 247.5,
"collector_container_mib": 247.5,
"queue": {
"otlp_http/loki": 50.0,
"otlp_http/prometheus": 0.0,
"otlp_grpc/tempo": 32.0
},
"alert": "firing"
},
{
"t": 111.6,
"collector_heap_mib": 69.3,
"collector_rss_mib": 247.5,
"collector_container_mib": 249.7,
"queue": {
"otlp_http/loki": 50.0,
"otlp_http/prometheus": 0.0,
"otlp_grpc/tempo": 32.0
},
"alert": "firing"
},
{
"t": 121.8,
"collector_heap_mib": 80.2,
"collector_rss_mib": 249.9,
"collector_container_mib": 258.8,
"queue": {
"otlp_http/loki": 57.0,
"otlp_http/prometheus": 0.0,
"otlp_grpc/tempo": 36.0
},
"alert": "firing"
},
{
"t": 131.9,
"collector_heap_mib": 92.7,
"collector_rss_mib": 262.3,
"collector_container_mib": 265.4,
"queue": {
"otlp_http/loki": 63.0,
"otlp_http/prometheus": 0.0,
"otlp_grpc/tempo": 40.0
},
"alert": "firing"
},
{
"t": 142.1,
"collector_heap_mib": 92.7,
"collector_rss_mib": 262.3,
"collector_container_mib": 273.3,
"queue": {
"otlp_http/loki": 63.0,
"otlp_http/prometheus": 0.0,
"otlp_grpc/tempo": 40.0
},
"alert": "firing"
}
],
"collector_heap_max_mib": 92.7,
"collector_rss_max_mib": 262.3,
"collector_container_max_mib": 273.3,
"TelemetryExportFailing_firing_at_s": 101.4,
"queue_drained_after_start_s": 80.0,
"probe_traces": [
{
"sent_at_s": 0.0,
"http": 201,
"trace_in_tempo": true
},
{
"sent_at_s": 10.1,
"http": 201,
"trace_in_tempo": true
},
{
"sent_at_s": 20.3,
"http": 201,
"trace_in_tempo": true
},
{
"sent_at_s": 30.4,
"http": 201,
"trace_in_tempo": true
},
{
"sent_at_s": 40.6,
"http": 201,
"trace_in_tempo": true
},
{
"sent_at_s": 50.7,
"http": 201,
"trace_in_tempo": true
},
{
"sent_at_s": 60.8,
"http": 201,
"trace_in_tempo": true
},
{
"sent_at_s": 71.0,
"http": 201,
"trace_in_tempo": true
},
{
"sent_at_s": 81.2,
"http": 201,
"trace_in_tempo": true
},
{
"sent_at_s": 91.3,
"http": 201,
"trace_in_tempo": true
},
{
"sent_at_s": 101.4,
"http": 201,
"trace_in_tempo": true
},
{
"sent_at_s": 111.6,
"http": 201,
"trace_in_tempo": true
},
{
"sent_at_s": 121.7,
"http": 201,
"trace_in_tempo": true
},
{
"sent_at_s": 131.9,
"http": 201,
"trace_in_tempo": true
},
{
"sent_at_s": 142.1,
"http": 201,
"trace_in_tempo": false
}
],
"lost_in_collector": {
"spans": 4096,
"log_records": 269
},
"resolved_after_start_s": 155.4,
"after": {
"requests": 10186,
"codes": {
"201": 10186
},
"success_ratio": 1.0,
"success_rps": 67.7,
"p95_ms_successful": 14.2
}
}
@@ -0,0 +1,41 @@
# incident-telemetry: lab6: Tempo+Loki down -> API unaffected, collector memory bounded, losses counted
# date: 2026-11-01 00:39:14, commit: unknown
# command: python student-tests/incidents.py telemetry-down
# exit code: 0, 374.8 s
=== telemetry-down
[ 20.2s] baseline: {'requests': 955, 'codes': {'201': 955}, 'success_ratio': 1.0, 'success_rps': 63.7, 'p95_ms_successful': 17.9}, collector heap 44.1 MiB, container 224.4 MiB
[ 50.9s] docker compose stop tempo loki: stopped
[ 51.1s] {'t': 0.0, 'collector_heap_mib': 39.8, 'collector_rss_mib': 228.5, 'collector_container_mib': 228.6, 'queue': {'otlp_http/loki': 0.0, 'otlp_http/prometheus': 0.0, 'otlp_grpc/tempo': 6.0}, 'alert': 'inactive'}
[ 61.2s] {'t': 10.1, 'collector_heap_mib': 52.2, 'collector_rss_mib': 228.6, 'collector_container_mib': 228.6, 'queue': {'otlp_http/loki': 5.0, 'otlp_http/prometheus': 0.0, 'otlp_grpc/tempo': 10.0}, 'alert': 'inactive'}
[ 71.3s] {'t': 20.3, 'collector_heap_mib': 52.2, 'collector_rss_mib': 228.6, 'collector_container_mib': 228.7, 'queue': {'otlp_http/loki': 5.0, 'otlp_http/prometheus': 0.0, 'otlp_grpc/tempo': 10.0}, 'alert': 'inactive'}
[ 81.5s] {'t': 30.4, 'collector_heap_mib': 63.3, 'collector_rss_mib': 230.2, 'collector_container_mib': 233.6, 'queue': {'otlp_http/loki': 12.0, 'otlp_http/prometheus': 0.0, 'otlp_grpc/tempo': 14.0}, 'alert': 'inactive'}
[ 91.6s] {'t': 40.6, 'collector_heap_mib': 48.5, 'collector_rss_mib': 234.5, 'collector_container_mib': 234.5, 'queue': {'otlp_http/loki': 20.0, 'otlp_http/prometheus': 0.0, 'otlp_grpc/tempo': 18.0}, 'alert': 'pending'}
[ 101.8s] {'t': 50.7, 'collector_heap_mib': 48.5, 'collector_rss_mib': 234.5, 'collector_container_mib': 234.6, 'queue': {'otlp_http/loki': 20.0, 'otlp_http/prometheus': 0.0, 'otlp_grpc/tempo': 18.0}, 'alert': 'pending'}
[ 112.0s] {'t': 60.8, 'collector_heap_mib': 59.5, 'collector_rss_mib': 234.6, 'collector_container_mib': 234.9, 'queue': {'otlp_http/loki': 27.0, 'otlp_http/prometheus': 0.0, 'otlp_grpc/tempo': 22.0}, 'alert': 'pending'}
[ 122.1s] {'t': 71.0, 'collector_heap_mib': 70.7, 'collector_rss_mib': 239.4, 'collector_container_mib': 242.2, 'queue': {'otlp_http/loki': 35.0, 'otlp_http/prometheus': 0.0, 'otlp_grpc/tempo': 26.0}, 'alert': 'pending'}
[ 132.2s] {'t': 81.2, 'collector_heap_mib': 70.7, 'collector_rss_mib': 239.4, 'collector_container_mib': 247.4, 'queue': {'otlp_http/loki': 35.0, 'otlp_http/prometheus': 0.0, 'otlp_grpc/tempo': 26.0}, 'alert': 'pending'}
[ 142.4s] {'t': 91.3, 'collector_heap_mib': 58.1, 'collector_rss_mib': 247.4, 'collector_container_mib': 247.4, 'queue': {'otlp_http/loki': 42.0, 'otlp_http/prometheus': 0.0, 'otlp_grpc/tempo': 30.0}, 'alert': 'pending'}
[ 152.5s] {'t': 101.4, 'collector_heap_mib': 69.3, 'collector_rss_mib': 247.5, 'collector_container_mib': 247.5, 'queue': {'otlp_http/loki': 50.0, 'otlp_http/prometheus': 0.0, 'otlp_grpc/tempo': 32.0}, 'alert': 'firing'}
[ 162.7s] {'t': 111.6, 'collector_heap_mib': 69.3, 'collector_rss_mib': 247.5, 'collector_container_mib': 249.7, 'queue': {'otlp_http/loki': 50.0, 'otlp_http/prometheus': 0.0, 'otlp_grpc/tempo': 32.0}, 'alert': 'firing'}
[ 172.9s] {'t': 121.8, 'collector_heap_mib': 80.2, 'collector_rss_mib': 249.9, 'collector_container_mib': 258.8, 'queue': {'otlp_http/loki': 57.0, 'otlp_http/prometheus': 0.0, 'otlp_grpc/tempo': 36.0}, 'alert': 'firing'}
[ 183.0s] {'t': 131.9, 'collector_heap_mib': 92.7, 'collector_rss_mib': 262.3, 'collector_container_mib': 265.4, 'queue': {'otlp_http/loki': 63.0, 'otlp_http/prometheus': 0.0, 'otlp_grpc/tempo': 40.0}, 'alert': 'firing'}
[ 193.2s] {'t': 142.1, 'collector_heap_mib': 92.7, 'collector_rss_mib': 262.3, 'collector_container_mib': 273.3, 'queue': {'otlp_http/loki': 63.0, 'otlp_http/prometheus': 0.0, 'otlp_grpc/tempo': 40.0}, 'alert': 'firing'}
[ 219.3s] docker compose start tempo loki
[ 299.3s] exporter queues drained 80.0 s after start
[ 324.7s] ... TelemetryExportFailing: firing (0 s)
[ 329.7s] ... TelemetryExportFailing: firing (5 s)
[ 334.7s] ... TelemetryExportFailing: firing (10 s)
[ 339.7s] ... TelemetryExportFailing: firing (15 s)
[ 344.7s] ... TelemetryExportFailing: firing (20 s)
[ 349.7s] ... TelemetryExportFailing: firing (25 s)
[ 354.7s] ... TelemetryExportFailing: firing (30 s)
[ 359.7s] ... TelemetryExportFailing: firing (35 s)
[ 364.7s] ... TelemetryExportFailing: firing (40 s)
[ 369.7s] ... TelemetryExportFailing: firing (45 s)
[ 374.7s] API during outage: {'requests': 11500, 'codes': {'201': 11500}, 'success_ratio': 1.0, 'success_rps': 68.3, 'p95_ms_successful': 13.2}
[ 374.7s] probe traces: 14/15 reached Tempo (lost: sent at [142.1] s)
[ 374.7s] lost in Collector (send_failed+enqueue_failed): {'spans': 4096, 'log_records': 269}; collector heap 44.1 -> max 92.7 MiB (memory_limiter 200 MiB), container max 273.3 MiB
[ 374.7s] saved /home/claude/work/mtusi2026lab6/evidence/native-sandbox/incident-telemetry-down.json
PASS: Tempo+Loki down -> API unaffected, collector memory bounded, losses counted; recovery -> resolved
1 passed, 0 failed
@@ -0,0 +1,49 @@
{
"scenario": "worker-stop",
"date": "2026-11-01 00:26:35",
"firing_after_stop_s": {
"MessengerWorkerNoConsumers": 66.4,
"MessengerQueueLagGrowing": 111.4
},
"diagnosis": {
"queue_consumers": 0.0,
"broker_queue_depth": 3.0,
"jobs_backlog_queued": 3.0,
"oldest_job_age_s": 97.3,
"outbox_oldest_age_s": 0.0,
"published_ok_last_5m": 3.102218085931441,
"worker_metrics_last_seen_s": 110.0,
"last_worker_log": {
"event": "service.stopped",
"message": "stopped"
},
"upload_trace_span_names": [
"INSERT",
"NOTIFY",
"POST /api/v1/chats/{chat_id}/attachments",
"S3 PutObject",
"SELECT",
"UPDATE",
"create attachments",
"inspect image",
"publish attachments",
"redis GET"
],
"upload_trace_has_consumer_span": false
},
"ready_after_start_s": [
1.5,
1.6,
2.0
],
"resolved_after_start_s": {
"MessengerWorkerNoConsumers": 17.0,
"MessengerQueueLagGrowing": 17.0
},
"after_recovery": {
"jobs_backlog_queued": 0.0,
"oldest_job_age_s": 0.0,
"queue_consumers": 2.0
},
"time_to_ready_p95_5m_s": 117.0
}
@@ -0,0 +1,43 @@
# incident-worker: lab6 incident 1: worker stopped -> queue lag + no consumers firing -> resolved
# date: 2026-11-01 00:28:44, commit: unknown
# command: python student-tests/incidents.py worker-stop
# exit code: 0, 128.6 s
=== worker-stop
[ 0.1s] baseline: consumers=2.0, oldest job age=0.0 s
[ 1.3s] docker compose stop worker
[ 1.4s] uploaded 3 attachments: 202 queued (API accepts without worker)
[ 1.4s] consumers=2.0 backlog queued=0.0 oldest age=0.0 s, alerts: {}
[ 6.4s] consumers=0.0 backlog queued=3.0 oldest age=2.1 s, alerts: {'MessengerWorkerNoConsumers': 'pending'}
[ 11.4s] consumers=0.0 backlog queued=3.0 oldest age=2.1 s, alerts: {'MessengerWorkerNoConsumers': 'pending'}
[ 16.4s] consumers=0.0 backlog queued=3.0 oldest age=12.1 s, alerts: {'MessengerWorkerNoConsumers': 'pending'}
[ 21.4s] consumers=0.0 backlog queued=3.0 oldest age=12.1 s, alerts: {'MessengerWorkerNoConsumers': 'pending'}
[ 26.4s] consumers=0.0 backlog queued=3.0 oldest age=22.1 s, alerts: {'MessengerWorkerNoConsumers': 'pending'}
[ 31.4s] consumers=0.0 backlog queued=3.0 oldest age=22.1 s, alerts: {'MessengerWorkerNoConsumers': 'pending'}
[ 36.4s] consumers=0.0 backlog queued=3.0 oldest age=27.1 s, alerts: {'MessengerWorkerNoConsumers': 'pending'}
[ 41.4s] consumers=0.0 backlog queued=3.0 oldest age=27.1 s, alerts: {'MessengerWorkerNoConsumers': 'pending'}
[ 46.4s] consumers=0.0 backlog queued=3.0 oldest age=37.1 s, alerts: {'MessengerWorkerNoConsumers': 'pending'}
[ 51.4s] consumers=0.0 backlog queued=3.0 oldest age=37.1 s, alerts: {'MessengerQueueLagGrowing': 'pending', 'MessengerWorkerNoConsumers': 'pending'}
[ 56.4s] consumers=0.0 backlog queued=3.0 oldest age=47.2 s, alerts: {'MessengerQueueLagGrowing': 'pending', 'MessengerWorkerNoConsumers': 'pending'}
[ 61.5s] consumers=0.0 backlog queued=3.0 oldest age=47.2 s, alerts: {'MessengerQueueLagGrowing': 'pending', 'MessengerWorkerNoConsumers': 'pending'}
[ 66.5s] ALERT MessengerWorkerNoConsumers firing (66.4 s after stop)
[ 66.5s] consumers=0.0 backlog queued=3.0 oldest age=57.2 s, alerts: {'MessengerQueueLagGrowing': 'pending', 'MessengerWorkerNoConsumers': 'firing'}
[ 71.5s] consumers=0.0 backlog queued=3.0 oldest age=57.2 s, alerts: {'MessengerQueueLagGrowing': 'pending', 'MessengerWorkerNoConsumers': 'firing'}
[ 76.5s] consumers=0.0 backlog queued=3.0 oldest age=67.2 s, alerts: {'MessengerQueueLagGrowing': 'pending', 'MessengerWorkerNoConsumers': 'firing'}
[ 81.5s] consumers=0.0 backlog queued=3.0 oldest age=67.2 s, alerts: {'MessengerQueueLagGrowing': 'pending', 'MessengerWorkerNoConsumers': 'firing'}
[ 86.5s] consumers=0.0 backlog queued=3.0 oldest age=77.2 s, alerts: {'MessengerQueueLagGrowing': 'pending', 'MessengerWorkerNoConsumers': 'firing'}
[ 91.5s] consumers=0.0 backlog queued=3.0 oldest age=77.2 s, alerts: {'MessengerQueueLagGrowing': 'pending', 'MessengerWorkerNoConsumers': 'firing'}
[ 96.5s] consumers=0.0 backlog queued=3.0 oldest age=87.2 s, alerts: {'MessengerQueueLagGrowing': 'pending', 'MessengerWorkerNoConsumers': 'firing'}
[ 101.5s] consumers=0.0 backlog queued=3.0 oldest age=87.2 s, alerts: {'MessengerQueueLagGrowing': 'pending', 'MessengerWorkerNoConsumers': 'firing'}
[ 106.5s] consumers=0.0 backlog queued=3.0 oldest age=97.3 s, alerts: {'MessengerQueueLagGrowing': 'pending', 'MessengerWorkerNoConsumers': 'firing'}
[ 111.5s] ALERT MessengerQueueLagGrowing firing (111.4 s after stop)
[ 111.5s] diagnosis: {"queue_consumers": 0.0, "broker_queue_depth": 3.0, "jobs_backlog_queued": 3.0, "oldest_job_age_s": 97.3, "outbox_oldest_age_s": 0.0, "published_ok_last_5m": 3.102218085931441, "worker_metrics_last_seen_s": 110.0, "last_worker_log": {"event": "service.stopped", "message": "stopped"}, "upload_trace_span_names": ["INSERT", "NOTIFY", "POST /api/v1/chats/{chat_id}/attachments", "S3 PutObject", "SELECT", "UPDATE", "create attachments", "inspect image", "publish attachments", "redis GET"], "upload_trace_has_consumer_span": false}
[ 111.6s] docker compose start worker
[ 113.5s] all attachments ready 2.0 s after worker start; backlog now 3.0
[ 113.5s] ... MessengerWorkerNoConsumers: firing (0 s)
[ 118.5s] ... MessengerWorkerNoConsumers: firing (5 s)
[ 123.5s] ... MessengerWorkerNoConsumers: firing (10 s)
[ 128.5s] alerts resolved: {'MessengerWorkerNoConsumers': 17.0, 'MessengerQueueLagGrowing': 17.0}; now {'jobs_backlog_queued': 0.0, 'oldest_job_age_s': 0.0, 'queue_consumers': 2.0}
[ 128.5s] saved /home/claude/work/mtusi2026lab6/evidence/native-sandbox/incident-worker-stop.json
PASS: worker stop -> no consumers + growing queue lag -> firing; cause from metrics/logs/trace; start -> backlog drained -> resolved
1 passed, 0 failed
@@ -0,0 +1,8 @@
# jobs-concurrency: lab5: WORKER_CONCURRENCY consumers, prefetch 1, bounded processing
# date: 2026-11-01 00:52:34, commit: unknown
# command: python student-tests/test_jobs.py concurrency
# exit code: 0, 7.1 s
--- concurrency: Ограниченная конкуренция: WORKER_CONCURRENCY потребителей с prefetch=1; одновременно processing <= 2.
2 consumers, prefetch_count 1, manual ack; 8 queued 3000x2000 JPEG drained in 4.1 s after worker start, peak processing 2 of 8 (22 samples)
1 passed, 0 failed
+9
View File
@@ -0,0 +1,9 @@
# jobs-outbox: lab5: dispatcher crash between COMMIT and publish / after confirm
# date: 2026-11-01 00:51:38, commit: unknown
# command: python student-tests/test_jobs.py outbox-crash
# exit code: 0, 7.4 s
--- outbox-crash: Разрыв COMMIT/publish: dispatcher падает после COMMIT задания до publish и после confirm до отметки.
dispatcher killed between COMMIT and publish; restarted by policy, outbox re-published -> job 18ab06f7-657b-4508-9ba5-844bd2c7ba2e ready, attempt 1, no manual action
dispatcher killed after publisher confirm, before marking outbox -> message published twice; worker: ['created', 'claimed', 'ready', 'duplicate_ignored'] -> one result set
1 passed, 0 failed
+16
View File
@@ -0,0 +1,16 @@
# jobs-recovery: lab5: worker down -> 202 -> restart api+broker -> ready; broker down -> outbox waits
# date: 2026-11-01 00:48:13, commit: unknown
# command: python student-tests/test_jobs.py worker-down broker-down
# exit code: 0, 44.2 s
--- worker-down: Защита п.2-3: worker остановлен -> 202 -> сообщение с вложением -> рестарт API+broker -> worker -> ready.
worker stopped
upload while worker is down -> 202 queued, attachment 748b0b56-e355-48a0-9ac6-4b731a3432a9
message with attachment 201, content 409, other messages 201; job 87ddc8fa-f8fe-4241-bf18-95fd2d4a2762 published, queue messages/unacked = (1, 0)
rabbitmq and api restarted with volumes; queue still holds 1 message(s); status queued
worker started -> same job 87ddc8fa-f8fe-4241-bf18-95fd2d4a2762 ready, thumbnail downloadable; staging object deleted
--- broker-down: Брокер недоступен: API принимает (outbox), dispatcher копит и публикует после восстановления.
rabbitmq stopped
upload -> 202 and /health/ready 200 without broker; outbox row pending for job 5784e1e7-7173-4a27-a3ad-72216f4a43a9
rabbitmq started -> dispatcher published the pending row -> ready
2 passed, 0 failed
+15
View File
@@ -0,0 +1,15 @@
# jobs-retry: lab5: backoff+jitter, retry_exhausted, replay, permanent errors, DLQ
# date: 2026-11-01 00:52:27, commit: unknown
# command: python student-tests/test_jobs.py retry exhausted-replay permanent dlq
# exit code: 0, 49.1 s
--- retry: Временные ошибки S3: backoff с jitter, затем ready; задержки видны в журнале.
2 x storage_unavailable -> retries after 1.40 s and 3.50 s (equal jitter: 1..2 s, 2..4 s), attempt 3 ready
--- exhausted-replay: Исчерпание попыток -> failed/retry_exhausted, реестр failed, явный replay; replay ready — отказ.
5 temporary errors -> failed/retry_exhausted (public error_code), content 409, attach 409, listed by ops.py failed (replayable)
ops replay -> same job_id fce6904a-fe4b-429c-821a-e3b55a43b0ef attempt 6 ready; second replay refused: "job is ready, replay is only for failed jobs"
--- permanent: Постоянная ошибка (битое изображение в worker) -> failed сразу, без повторов.
invalid image in the worker -> failed/invalid_image at attempt 1, no retry (permanent error)
--- dlq: Невалидные сообщения и сообщения о неизвестной job -> DLQ; dlq-replay их не исполняет.
schema-invalid message and unknown job_id -> reject -> DLQ (2 message(s)); dlq-replay kept them: ['invalid message is kept for analysis', 'unknown job']
4 passed, 0 failed
+14
View File
@@ -0,0 +1,14 @@
# jobs-variants: lab5: thumbnail/crop/optimized, EXIF orientation, alpha, no upscale, metadata stripped
# date: 2026-11-01 00:47:29, commit: unknown
# command: python student-tests/test_jobs.py variants
# exit code: 0, 14.3 s
--- variants: thumbnail/crop/optimized по контракту, EXIF orientation, alpha -> белый, без увеличения, без метаданных.
thumb320: thumbnail 256x160, crop 128x128, optimized 320x200; original byte-identical; EXIF/XMP in variants: 0; S3 keys ['v1/crop.jpg', 'v1/optimized.webp', 'v1/original', 'v1/thumbnail.jpg']
exif6: thumbnail 192x256, crop 128x128, optimized 300x400; original byte-identical; EXIF/XMP in variants: 0; S3 keys ['v1/crop.jpg', 'v1/optimized.webp', 'v1/original', 'v1/thumbnail.jpg']
alpha: thumbnail 256x170, crop 128x128, optimized 300x200; original byte-identical; EXIF/XMP in variants: 0; S3 keys ['v1/crop.jpg', 'v1/optimized.webp', 'v1/original', 'v1/thumbnail.jpg']
tiny: thumbnail 40x30, crop 128x128, optimized 40x30; original byte-identical; EXIF/XMP in variants: 0; S3 keys ['v1/crop.jpg', 'v1/optimized.webp', 'v1/original', 'v1/thumbnail.jpg']
large: thumbnail 256x170, crop 128x128, optimized 1280x853; original byte-identical; EXIF/XMP in variants: 0; S3 keys ['v1/crop.jpg', 'v1/optimized.webp', 'v1/original', 'v1/thumbnail.jpg']
strip: thumbnail 256x1, crop 128x128, optimized 1280x1; original byte-identical; EXIF/XMP in variants: 0; S3 keys ['v1/crop.jpg', 'v1/optimized.webp', 'v1/original', 'v1/thumbnail.jpg']
unknown variant name -> 400; variants carry their own size/sha256, original fields describe the upload
1 passed, 0 failed
+17
View File
@@ -0,0 +1,17 @@
{
"lab": 6,
"workload": "closed-loop POST messages; no automatic retries",
"requested_duration_seconds": 30.0,
"elapsed_seconds": 30.083,
"concurrency": 4,
"successful_requests": 8762,
"failed_requests": 0,
"error_ratio": 0.0,
"successful_rps": 291.265,
"successful_latency_ms": {
"p50": 11.557,
"p95": 26.659,
"p99": 56.425
},
"note": "Latency percentiles cover successes only. Timeouts/errors are counted separately; closed-loop has coordinated omission and client overhead."
}
+22
View File
@@ -0,0 +1,22 @@
# load: public load generator, 30 s, concurrency 4
# date: 2026-11-01 00:42:08, commit: unknown
# command: python tests/load.py --base-url http://127.0.0.1:8080 --duration 30 --concurrency 4 --output evidence/load.json
# exit code: 0, 30.4 s
{
"lab": 6,
"workload": "closed-loop POST messages; no automatic retries",
"requested_duration_seconds": 30.0,
"elapsed_seconds": 30.083,
"concurrency": 4,
"successful_requests": 8762,
"failed_requests": 0,
"error_ratio": 0.0,
"successful_rps": 291.265,
"successful_latency_ms": {
"p50": 11.557,
"p95": 26.659,
"p99": 56.425
},
"note": "Latency percentiles cover successes only. Timeouts/errors are counted separately; closed-loop has coordinated omission and client overhead."
}
+10
View File
@@ -0,0 +1,10 @@
# race: lab2 races via the balancer
# date: 2026-11-01 00:52:53, commit: unknown
# command: python student-tests/test_race.py
# exit code: 0, 1.5 s
sent 100 messages from 10 clients in 0.34 s; read 100 in 4 pages, unique ids: 100
PASS: 100 concurrent messages from 10 clients, no losses and no duplicates
20 parallel registrations of one username: 201 x1, 409 x19
PASS: concurrent registration created exactly one user
2 passed, 0 failed
+6
View File
@@ -0,0 +1,6 @@
# smoke: public smoke via the balancer (make test) with telemetry ON, with attachment
# date: 2026-11-01 00:22:30, commit: unknown
# command: python tests/smoke.py --base-url http://127.0.0.1:8080
# exit code: 0, 1.7 s
PASS: lab6 public API scenario; infrastructure and grading evidence remain separate.
+26
View File
@@ -0,0 +1,26 @@
# student-tests: lab1/lab2 API tests via the balancer
# date: 2026-11-01 00:52:52, commit: unknown
# command: python student-tests/test_api.py
# exit code: 0, 2.0 s
PASS: duplicate username returns 409
PASS: invalid JSON returns 400
PASS: wrong and extra fields return 400
PASS: foreign chat returns 404
PASS: empty and too long messages return 400, 4000 chars is ok
PASS: pagination works across multiple pages, foreign cursor returns 400
PASS: empty cursor (?cursor= and ?cursor) returns 400, no cursor returns the first page
PASS: chat list pagination
PASS: unicode text is stored as is
PASS: strings with U+0000 are stored and returned as is
PASS: user response has no password or hash
PASS: password length 12..128, blank password is rejected
PASS: Basic login returns opaque Bearer token with expiry
PASS: wrong password and unknown user both return the same 401
PASS: malformed Basic header returns 401
PASS: password with colon and unicode works
PASS: business endpoints need Bearer; Basic and X-User-Id give 401
PASS: X-User-Id does not change the current user
PASS: 401 comes before 400 and 404
PASS: logout revokes only the current session
20 passed, 0 failed
+48
View File
@@ -0,0 +1,48 @@
# Сводка проверок (нативная песочница, без Docker)
Стенд теми же процессами без контейнеров: PostgreSQL 16, Redis 7, RabbitMQ 3.12, SeaweedFS 3.80, HAProxy 2.8, 2 реплики API, dispatcher, worker, janitor (Python 3.11, requirements.txt), otelcol-contrib 0.164.0, Prometheus 3.15.1, Loki 3.7.9, Tempo 3.1.1 с конфигами из infra/ (адреса -> 127.0.0.1). Команды `docker compose` тестов выполнялись через подмену на управление процессами. Машина: Linux x86_64, 2 vCPU, 8 GiB RAM.
| Шаг | Что проверяет | Результат | Время, с | Файл |
| --- | --- | --- | --- | --- |
| check | offline contract check (make check) | PASS | 0 | evidence/native-sandbox/check.txt |
| smoke | public smoke via the balancer (make test) with telemetry ON, with attachment | PASS | 2 | evidence/native-sandbox/smoke.txt |
| configs | lab6: collector/prometheus/loki/tempo configs by their own tools, alert unit tests, Grafana provisioning | PASS | 1 | evidence/native-sandbox/configs.txt |
| telemetry | lab6: request<->log<->trace, upload->publish->consume->S3/DB chain, retry, replay link, no secrets | PASS | 77 | evidence/native-sandbox/telemetry.txt |
| dashboard | lab6: every dashboard/rule query runs on live data, key signals present, no forbidden labels | PASS | 0 | evidence/native-sandbox/dashboard.txt |
| telemetry-history | lab6: traces/logs/metrics survive restart of prometheus/loki/tempo (volumes) | PASS | 52 | evidence/native-sandbox/telemetry-history.txt |
| incident-worker | lab6 incident 1: worker stopped -> queue lag + no consumers firing -> resolved | PASS | 129 | evidence/native-sandbox/incident-worker.txt |
| incident-db | lab6 incident 2: slow PostgreSQL (table lock) -> high error rate firing, cause from traces -> resolved | PASS | 265 | evidence/native-sandbox/incident-db.txt |
| incident-telemetry | lab6: Tempo+Loki down -> API unaffected, collector memory bounded, losses counted | PASS | 375 | evidence/native-sandbox/incident-telemetry.txt |
| incident-collector | lab6: Collector down -> API unaffected, SDK queue bounded, drops counted | PASS | 143 | evidence/native-sandbox/incident-collector.txt |
| jobs-variants | lab5: thumbnail/crop/optimized, EXIF orientation, alpha, no upscale, metadata stripped | PASS | 14 | evidence/native-sandbox/jobs-variants.txt |
| jobs-recovery | lab5: worker down -> 202 -> restart api+broker -> ready; broker down -> outbox waits | PASS | 44 | evidence/native-sandbox/jobs-recovery.txt |
| jobs-outbox | lab5: dispatcher crash between COMMIT and publish / after confirm | PASS | 7 | evidence/native-sandbox/jobs-outbox.txt |
| jobs-retry | lab5: backoff+jitter, retry_exhausted, replay, permanent errors, DLQ | PASS | 49 | evidence/native-sandbox/jobs-retry.txt |
| jobs-concurrency | lab5: WORKER_CONCURRENCY consumers, prefetch 1, bounded processing | PASS | 7 | evidence/native-sandbox/jobs-concurrency.txt |
| attachments | lab4: files, limits, damaged images, MIME, filenames, access, attachment_ids | PASS | 14 | evidence/native-sandbox/attachments.txt |
| idempotency | Idempotency-Key, parallel same key via replicas | PASS | 2 | evidence/native-sandbox/idempotency.txt |
| student-tests | lab1/lab2 API tests via the balancer | PASS | 2 | evidence/native-sandbox/student-tests.txt |
| race | lab2 races via the balancer | PASS | 2 | evidence/native-sandbox/race.txt |
| load | public load generator, 30 s, concurrency 4 | PASS | 30 | evidence/native-sandbox/load.txt |
# Замеры
Алерты на контролируемых инцидентах (`student-tests/incidents.py`, состояние из Prometheus /api/v1/alerts):
| Инцидент | Воздействие | Алерт | firing через, с | resolved через, с после устранения |
| --- | --- | --- | --- | --- |
| 1. worker | `docker compose stop worker` + 3 загрузки | MessengerWorkerNoConsumers | 66.4 (от stop) | 17.0 (от start) |
| 1. worker | `docker compose stop worker` + 3 загрузки | MessengerQueueLagGrowing | 111.4 (от stop) | 17.0 (от start) |
| 2. PostgreSQL | `LOCK TABLE messages IN ACCESS EXCLUSIVE MODE` на 210 с под нагрузкой 8 потоков | MessengerHighErrorRate | 120.1 (от LOCK) | 30.0 (от COMMIT блокировки) |
| 3. телеметрия | `docker compose stop tempo loki` на 150 с | TelemetryExportFailing | 101.4 (от stop) | 155.4 (от start) |
Инцидент 1, наблюдения в момент firing: consumers очереди = 0.0, сообщений в RabbitMQ = 3.0, queued заданий = 3.0, возраст старейшего = 97.3 с, возраст outbox = 0.0 с (публикация работает), метрики worker не обновлялись 110.0 с, последний лог worker: event=`service.stopped`; трасса загрузки содержит `publish attachments`, но не содержит `process attachments.process.v1`. После start: вложения ready через 2.0 с, backlog 0.0.
Инцидент 2, наблюдения: доля 5xx (1m) = 1.0, коды POST /messages за 1m = {'201': 0.0, '200': 0.0, '404': 0.0, '400': 0.0, '409': 0.0, '503': 1.6}, p95 POST /messages = 7.375 с, чтения других таблиц (GET /users/me, /chats) во время блокировки {'GET /users/me + GET /chats, avg per request': 4.7, 'max': 5.4} мс, занято соединений пула = 8.0, p95 ожидания пула = 0.001 с, логи API event=db.unavailable по error_type: {'QueryCanceled': 184}. Error-трасса 1c7f8dd06427574a5f155558aa4cd975: server-спан 5006.7 мс, из них `INSERT` 5000.6 мс (доля 0.999, статус ERROR). Контраст «медленный обработчик» (трасса a6da2e3fe7b0c229773f36fa507293ca, POST /users): server 34.0 мс, `argon2id hash` 29.0 мс, все спаны БД 0.6 мс. Нагрузка: до 132.4 успешных записей/с, во время блокировки {'503': 320, '201': 6}, после 131.9/с без ошибок.
| Отказ телеметрии | API во время отказа | Память | Потери телеметрии |
| --- | --- | --- | --- |
| `stop tempo loki` на 150 с (окно повторов Collector 120 с) | 11500 запросов, коды {'201': 11500}, доля успеха 1.0 | heap Collector 44.1 -> max 92.7 MiB (limit 200), контейнер max 273.3 MiB | send/enqueue failed в Collector: {'spans': 4096, 'log_records': 269}; пробные трассы дошли 14/15, потеряны отправленные на [142.1] с |
| `stop otel-collector` на 90 с | 6263 запросов, коды {'201': 6263}, доля успеха 1.0 | api 280.5 -> max 292.5 MiB (2 реплики) | SDK api потерял спанов: {'processor_queue_full': 0, 'exporter_failed': 24576} (queue_full — очередь 2048 полна, exporter_failed — Collector не принял пакет); после start экспорт возобновился (10524 спанов за минуту) |
Публичный генератор нагрузки при включённой телеметрии (`tests/load.py`, closed loop, concurrency 4, 30 с, 2 реплики): 291.265 успешных POST/с, ошибок 0, p50 11.557 мс, p95 26.659 мс, p99 56.425 мс (песочница 2 vCPU на всё: стенд + хранилища + клиент; не сравнивать с Docker-машиной).
@@ -0,0 +1,9 @@
# telemetry-history: lab6: traces/logs/metrics survive restart of prometheus/loki/tempo (volumes)
# date: 2026-11-01 00:26:35, commit: unknown
# command: python student-tests/test_telemetry.py history
# exit code: 0, 52.2 s
before restart: trace 52668075eebc7fd4938de9690ba2aad1 found, its log found, sum(http_server_request_duration_seconds_count{job="messenger-api"}) at t-30s = 719
after restart of prometheus, loki, tempo: trace 52668075eebc7fd4938de9690ba2aad1 (4 spans), 1 log record(s), metric at t-30s = 719 (same value)
PASS: persistent volumes keep traces, logs and metrics across restarts of the stores
1 passed, 0 failed
+145
View File
@@ -0,0 +1,145 @@
# telemetry: lab6: request<->log<->trace, upload->publish->consume->S3/DB chain, retry, replay link, no secrets
# date: 2026-11-01 00:23:48, commit: unknown
# command: python student-tests/test_telemetry.py request upload-chain retry-chain replay-link
# exit code: 0, 77.1 s
POST message: 201, X-Request-Id=4d281ed1-39de-484a-add2-8480ef33ab9c, trace_id=97ebaba763fec926fa1e1ed3fc0fae7a (client traceparent)
- [api] POST /api/v1/chats/{chat_id}/messages (SERVER, 5.8 ms) http.response.status_code=201
- [api] redis GET (CLIENT, 0.3 ms)
- [api] SELECT (CLIENT, 0.5 ms)
- [api] INSERT (CLIENT, 0.8 ms)
Loki: 'POST /api/v1/chats/{chat_id}/messages -> 201 (5.9 ms)' event=http.request severity=INFO service=messenger-api trace_id=97ebaba763fec926fa1e1ed3fc0fae7a span_id=82ab66080cb50d2a request_id=4d281ed1-39de-484a-add2-8480ef33ab9c
PASS: request -> server span with DB/Redis children -> structured log with the same trace_id/span_id and request_id; no message text, password or token in logs/span attributes
- [api] POST /api/v1/chats/{chat_id}/attachments (SERVER, 64.6 ms) http.response.status_code=202
- [api] redis GET (CLIENT, 0.4 ms)
- [api] SELECT (CLIENT, 0.5 ms)
- [api] inspect image (INTERNAL, 45.7 ms)
- [api] INSERT (CLIENT, 1.1 ms)
- [api] S3 PutObject (CLIENT, 5.1 ms) aws.s3.key=staging/f5bdb54e2b234121b7e13ef3007a03b1
- [api] UPDATE (CLIENT, 0.9 ms)
- [api] create attachments (PRODUCER, 3.5 ms) messenger.job.attempt=1
- [api] INSERT (CLIENT, 0.9 ms)
- [api] INSERT (CLIENT, 0.9 ms)
- [api] INSERT (CLIENT, 0.8 ms)
- [api] NOTIFY (CLIENT, 0.3 ms)
- [dispatcher] publish attachments (PRODUCER, 4.4 ms) messenger.job.attempt=1
- [dispatcher] UPDATE (CLIENT, 0.9 ms)
- [worker] process attachments.process.v1 (CONSUMER, 280.0 ms) messenger.job.attempt=1 messenger.job.outcome=ready
- [worker] SELECT (CLIENT, 1.4 ms)
- [worker] UPDATE (CLIENT, 0.8 ms)
- [worker] UPDATE (CLIENT, 1.4 ms)
- [worker] INSERT (CLIENT, 0.7 ms)
- [worker] S3 GetObject (CLIENT, 2.9 ms) aws.s3.key=staging/f5bdb54e2b234121b7e13ef3007a03b1
- [worker] verify source sha256 (INTERNAL, 0.1 ms)
- [worker] imaging (INTERNAL, 238.2 ms)
- [worker] S3 PutObject (CLIENT, 4.2 ms) aws.s3.key=attachments/016e0413-eeaa-481a-bef5-27270d212a71/v1/original
- [worker] S3 PutObject (CLIENT, 3.4 ms) aws.s3.key=attachments/016e0413-eeaa-481a-bef5-27270d212a71/v1/optimized.webp
- [worker] S3 PutObject (CLIENT, 3.2 ms) aws.s3.key=attachments/016e0413-eeaa-481a-bef5-27270d212a71/v1/thumbnail.jpg
- [worker] S3 PutObject (CLIENT, 2.9 ms) aws.s3.key=attachments/016e0413-eeaa-481a-bef5-27270d212a71/v1/crop.jpg
- [worker] commit result (INTERNAL, 7.5 ms)
- [worker] SELECT (CLIENT, 0.7 ms)
- [worker] INSERT (CLIENT, 1.0 ms)
- [worker] INSERT (CLIENT, 0.6 ms)
- [worker] INSERT (CLIENT, 0.7 ms)
- [worker] UPDATE (CLIENT, 1.0 ms)
- [worker] UPDATE (CLIENT, 0.7 ms)
- [worker] INSERT (CLIENT, 0.4 ms)
- [worker] cleanup staging (INTERNAL, 4.1 ms)
- [worker] S3 DeleteObject (CLIENT, 2.4 ms) aws.s3.key=staging/f5bdb54e2b234121b7e13ef3007a03b1
- [worker] UPDATE (CLIENT, 1.4 ms)
worker logs with trace_id 0eecc096d0191a19e41ad1547110183c: ['job.claimed', 'job.ready']
PASS: one trace 0eecc096d0191a19e41ad1547110183c: API 202 -> outbox create -> dispatcher publish -> worker consume -> 4 S3 objects + COMMIT ready (37 spans, services: messenger-api, messenger-dispatcher, messenger-worker)
- [api] POST /api/v1/chats/{chat_id}/attachments (SERVER, 17.4 ms) http.response.status_code=202
- [api] redis GET (CLIENT, 0.3 ms)
- [api] SELECT (CLIENT, 0.5 ms)
- [api] inspect image (INTERNAL, 0.3 ms)
- [api] INSERT (CLIENT, 0.7 ms)
- [api] S3 PutObject (CLIENT, 5.0 ms) aws.s3.key=staging/e638ce1aa4c645a6bbc8e93427d644df
- [api] UPDATE (CLIENT, 0.6 ms)
- [api] create attachments (PRODUCER, 2.9 ms) messenger.job.attempt=1
- [api] INSERT (CLIENT, 0.6 ms)
- [api] INSERT (CLIENT, 0.5 ms)
- [api] INSERT (CLIENT, 0.5 ms)
- [api] NOTIFY (CLIENT, 0.2 ms)
- [dispatcher] publish attachments (PRODUCER, 3.2 ms) messenger.job.attempt=1
- [dispatcher] UPDATE (CLIENT, 0.5 ms)
- [worker] process attachments.process.v1 (CONSUMER, 255.7 ms) ERROR messenger.job.attempt=1 messenger.job.outcome=retry error.type=storage_unavailable
- [worker] SELECT (CLIENT, 0.8 ms)
- [worker] UPDATE (CLIENT, 0.5 ms)
- [worker] UPDATE (CLIENT, 0.5 ms)
- [worker] INSERT (CLIENT, 0.4 ms)
- [worker] S3 GetObject (CLIENT, 3.4 ms) aws.s3.key=staging/e638ce1aa4c645a6bbc8e93427d644df
- [worker] verify source sha256 (INTERNAL, 0.0 ms)
- [worker] imaging (INTERNAL, 238.9 ms)
- [worker] SELECT (CLIENT, 0.6 ms)
- [worker] UPDATE (CLIENT, 0.8 ms)
- [worker] UPDATE (CLIENT, 0.5 ms)
- [worker] create attachments (PRODUCER, 1.5 ms) messenger.job.attempt=2
- [worker] INSERT (CLIENT, 0.8 ms)
- [worker] NOTIFY (CLIENT, 0.2 ms)
- [dispatcher] publish attachments (PRODUCER, 3.3 ms) messenger.job.attempt=2
- [dispatcher] UPDATE (CLIENT, 0.6 ms)
- [worker] process attachments.process.v1 (CONSUMER, 284.4 ms) messenger.job.attempt=2 messenger.job.outcome=ready
- [worker] SELECT (CLIENT, 0.7 ms)
- [worker] UPDATE (CLIENT, 0.8 ms)
- [worker] UPDATE (CLIENT, 0.7 ms)
- [worker] INSERT (CLIENT, 0.6 ms)
- [worker] S3 GetObject (CLIENT, 3.5 ms) aws.s3.key=staging/e638ce1aa4c645a6bbc8e93427d644df
- [worker] verify source sha256 (INTERNAL, 0.1 ms)
- [worker] imaging (INTERNAL, 250.7 ms)
- [worker] S3 PutObject (CLIENT, 4.7 ms) aws.s3.key=attachments/9e5dd23f-0ecc-4bdf-b8de-87d529fd54b0/v1/original
- [worker] S3 PutObject (CLIENT, 3.2 ms) aws.s3.key=attachments/9e5dd23f-0ecc-4bdf-b8de-87d529fd54b0/v1/optimized.webp
- [worker] S3 PutObject (CLIENT, 3.0 ms) aws.s3.key=attachments/9e5dd23f-0ecc-4bdf-b8de-87d529fd54b0/v1/thumbnail.jpg
- [worker] S3 PutObject (CLIENT, 2.9 ms) aws.s3.key=attachments/9e5dd23f-0ecc-4bdf-b8de-87d529fd54b0/v1/crop.jpg
- [worker] commit result (INTERNAL, 6.6 ms)
- [worker] SELECT (CLIENT, 0.6 ms)
- [worker] INSERT (CLIENT, 0.7 ms)
- [worker] INSERT (CLIENT, 0.6 ms)
- [worker] INSERT (CLIENT, 0.8 ms)
- [worker] UPDATE (CLIENT, 0.8 ms)
- [worker] UPDATE (CLIENT, 0.5 ms)
- [worker] INSERT (CLIENT, 0.5 ms)
- [worker] cleanup staging (INTERNAL, 4.6 ms)
- [worker] S3 DeleteObject (CLIENT, 2.7 ms) aws.s3.key=staging/e638ce1aa4c645a6bbc8e93427d644df
- [worker] UPDATE (CLIENT, 1.3 ms)
- [worker] INSERT (CLIENT, 0.5 ms)
worker log: 'job 9a82f341-ec57-49e5-aa86-6263681529c1 attempt 1: storage_unavailable (temporary) -> retry' error_type=storage_unavailable
messenger_job_duration_seconds_count{outcome="retry"}: 0 -> 1
PASS: retry in one trace 1abe27ebd519ac0854a844d18d679bf6: attempt 1 ERROR storage_unavailable -> create -> publish -> attempt 2 ready; retry counted in metrics and logged
original trace 5b3ea90278cb5e18b6ad08cd32349c0e: 5 attempts, last outcome failed
- [ops] ops replay (INTERNAL, 16.5 ms)
- [ops] SELECT (CLIENT, 2.3 ms)
- [ops] UPDATE (CLIENT, 0.9 ms)
- [ops] UPDATE (CLIENT, 0.8 ms)
- [ops] INSERT (CLIENT, 0.7 ms)
- [ops] create attachments (PRODUCER, 1.1 ms) links=1 messenger.job.attempt=6
- [ops] INSERT (CLIENT, 0.7 ms)
- [ops] NOTIFY (CLIENT, 0.2 ms)
- [dispatcher] publish attachments (PRODUCER, 5.3 ms) messenger.job.attempt=6
- [worker] process attachments.process.v1 (CONSUMER, 281.7 ms) messenger.job.attempt=6 messenger.job.outcome=ready
- [worker] SELECT (CLIENT, 0.4 ms)
- [worker] UPDATE (CLIENT, 0.4 ms)
- [worker] UPDATE (CLIENT, 0.6 ms)
- [worker] INSERT (CLIENT, 0.2 ms)
- [worker] S3 GetObject (CLIENT, 2.7 ms) aws.s3.key=staging/4a1c95c1e3ea46c1b51982aa45344f00
- [worker] verify source sha256 (INTERNAL, 0.0 ms)
- [worker] imaging (INTERNAL, 251.3 ms)
- [worker] S3 PutObject (CLIENT, 3.9 ms) aws.s3.key=attachments/5f4e2b56-4497-4ff8-9c9f-df41939a2520/v1/original
- [worker] S3 PutObject (CLIENT, 2.9 ms) aws.s3.key=attachments/5f4e2b56-4497-4ff8-9c9f-df41939a2520/v1/optimized.webp
- [worker] S3 PutObject (CLIENT, 2.8 ms) aws.s3.key=attachments/5f4e2b56-4497-4ff8-9c9f-df41939a2520/v1/thumbnail.jpg
- [worker] S3 PutObject (CLIENT, 2.5 ms) aws.s3.key=attachments/5f4e2b56-4497-4ff8-9c9f-df41939a2520/v1/crop.jpg
- [worker] commit result (INTERNAL, 6.0 ms)
- [worker] SELECT (CLIENT, 0.6 ms)
- [worker] INSERT (CLIENT, 0.7 ms)
- [worker] INSERT (CLIENT, 0.6 ms)
- [worker] INSERT (CLIENT, 0.3 ms)
- [worker] UPDATE (CLIENT, 0.7 ms)
- [worker] UPDATE (CLIENT, 0.5 ms)
- [worker] INSERT (CLIENT, 0.4 ms)
- [worker] cleanup staging (INTERNAL, 5.9 ms)
- [worker] S3 DeleteObject (CLIENT, 3.3 ms) aws.s3.key=staging/4a1c95c1e3ea46c1b51982aa45344f00
- [worker] UPDATE (CLIENT, 2.1 ms)
- [dispatcher] UPDATE (CLIENT, 1.3 ms)
replay trace 6d0327f64ceb5758c4a19b30aceed617: create span links -> ['5b3ea90278cb5e18b6ad08cd32349c0e'] (original upload trace 5b3ea90278cb5e18b6ad08cd32349c0e)
PASS: replay = new trace (root 'ops replay') with a link to the original upload; worker finished it
4 passed, 0 failed
+40
View File
@@ -0,0 +1,40 @@
# persistence: public persistence test incl. S3 + proof of real restarts (make test-persistence)
# date: 2026-11-01 20:46:08, commit: 470d9d6 + uncommitted changes
# command: python.exe student-tests/run_persistence.py
# exit code: 0, 62.0 s
before: container, ID, started at
messenger-lab6-api-1 171a473b0d28 2026-11-01T17:43:16.63584434Z
messenger-lab6-api-2 1db2fedff78f 2026-11-01T17:43:36.466962173Z
messenger-lab6-dispatcher-1 2f899202c4d1 2026-11-01T17:31:14.251298706Z
messenger-lab6-grafana-1 23e7b8bb1b3a 2026-11-01T17:06:55.450862118Z
messenger-lab6-janitor-1 6dad6b402ed9 2026-11-01T17:07:17.636225869Z
messenger-lab6-lb-1 0bffe8d8d7d2 2026-11-01T17:07:20.27137747Z
messenger-lab6-loki-1 c62735c8baca 2026-11-01T17:22:20.690589644Z
messenger-lab6-otel-collector-1 8c416bdc0221 2026-11-01T17:27:23.730596273Z
messenger-lab6-postgres-1 ced386ea9bbd 2026-11-01T17:45:04.263026279Z
messenger-lab6-prometheus-1 451bf5466e96 2026-11-01T17:09:18.447414724Z
messenger-lab6-rabbitmq-1 ec502659b532 2026-11-01T17:30:47.892983401Z
messenger-lab6-redis-1 3c003ba9b32a 2026-11-01T17:44:43.823155102Z
messenger-lab6-s3-1 1e70a509e403 2026-11-01T17:40:41.919464505Z
messenger-lab6-tempo-1 3daf3848457f 2026-11-01T17:22:20.681510324Z
messenger-lab6-worker-1 cbd8138493bf 2026-11-01T17:38:33.102546081Z
Executing explicit persistence hook; hook output suppressed to avoid leaking secrets.␍
PASS: persistence preserved confirmed data and existing session. Hook scope needs operator evidence.
after (hook + waiting for readiness took 60.9 s): container, ID, started at, restarted?
messenger-lab6-api-1 171a473b0d28 2026-11-01T17:46:02.488153329Z same container: True, restarted: True
messenger-lab6-api-2 1db2fedff78f 2026-11-01T17:46:02.317979748Z same container: True, restarted: True
messenger-lab6-dispatcher-1 2f899202c4d1 2026-11-01T17:46:00.495060123Z same container: True, restarted: True
messenger-lab6-grafana-1 23e7b8bb1b3a 2026-11-01T17:45:57.449417453Z same container: True, restarted: True
messenger-lab6-janitor-1 6dad6b402ed9 2026-11-01T17:45:57.621731679Z same container: True, restarted: True
messenger-lab6-lb-1 0bffe8d8d7d2 2026-11-01T17:46:05.984667885Z same container: True, restarted: True
messenger-lab6-loki-1 c62735c8baca 2026-11-01T17:45:21.206788727Z same container: True, restarted: True
messenger-lab6-otel-collector-1 8c416bdc0221 2026-11-01T17:45:56.829306342Z same container: True, restarted: True
messenger-lab6-postgres-1 ced386ea9bbd 2026-11-01T17:45:19.869545292Z same container: True, restarted: True
messenger-lab6-prometheus-1 451bf5466e96 2026-11-01T17:45:20.880337926Z same container: True, restarted: True
messenger-lab6-rabbitmq-1 ec502659b532 2026-11-01T17:45:21.007029551Z same container: True, restarted: True
messenger-lab6-redis-1 3c003ba9b32a 2026-11-01T17:45:19.748047785Z same container: True, restarted: True
messenger-lab6-s3-1 1e70a509e403 2026-11-01T17:45:29.752000764Z same container: True, restarted: True
messenger-lab6-tempo-1 3daf3848457f 2026-11-01T17:45:50.068926735Z same container: True, restarted: True
messenger-lab6-worker-1 cbd8138493bf 2026-11-01T17:46:00.664535867Z same container: True, restarted: True
PASS: the hook restarted postgres, redis, s3, rabbitmq, api, janitor, dispatcher, worker, lb, otel-collector, prometheus, loki, tempo, grafana (all api replicas; same containers, new start time); data, the attachment bytes and the old token survived
+10
View File
@@ -0,0 +1,10 @@
# race: lab2 races via the balancer
# date: 2026-11-01 20:42:41, commit: 470d9d6 + uncommitted changes
# command: python.exe student-tests/test_race.py
# exit code: 0, 1.2 s
sent 100 messages from 10 clients in 0.30 s; read 100 in 4 pages, unique ids: 100
PASS: 100 concurrent messages from 10 clients, no losses and no duplicates
20 parallel registrations of one username: 201 x1, 409 x19
PASS: concurrent registration created exactly one user
2 passed, 0 failed
+14
View File
@@ -0,0 +1,14 @@
# redis: Redis as the session store
# date: 2026-11-01 20:42:56, commit: 470d9d6 + uncommitted changes
# command: python.exe student-tests/redis_info.py
# exit code: 0, 3.2 s
session key: session:0fe0e5550e07d95d...; value is the user id: True
TTL of the key, seconds: 3599
sessions in Redis: 147
config appendonly = yes
config appendfsync = always
config maxmemory-policy = noeviction
aof_enabled:1
aof_last_write_status:ok
without password: NOAUTH Authentication required.
+53
View File
@@ -0,0 +1,53 @@
# s3-security: lab4: private bucket outside API, limited API key, no console/ports, idempotent bootstrap
# date: 2026-11-01 20:38:59, commit: 470d9d6 + uncommitted changes
# command: python.exe student-tests/test_s3_security.py
# exit code: 0, 10.5 s
anonymous get_object directly to S3 (from the data network) -> 403 AccessDenied
anonymous head_object directly to S3 (from the data network) -> 403
anonymous list_bucket directly to S3 (from the data network) -> 403 AccessDenied
anonymous put_object directly to S3 (from the data network) -> 403 AccessDenied
anonymous get_bucket_policy directly to S3 (from the data network) -> 403 AccessDenied
the same file through the API for a chat member -> 200
PASS: the bucket is private: no anonymous read, list, write or policy read
API key: list buckets -> ['messenger-attachments']
API key: get own object -> allowed
API key: put object -> allowed
API key: delete object -> allowed
API key: list bucket -> allowed
API key: create another bucket -> denied: AccessDenied
API key: make bucket public (put policy) -> denied: NotImplemented
API key: read bucket policy -> denied: NoSuchBucketPolicy
API key: delete bucket -> denied: AccessDenied
API key: change versioning -> denied: NotImplemented
PASS: the API key can only get/put/delete/list objects of its own bucket; bucket admin, policy and other buckets are denied
compose: s3 has no published ports, only the internal network 'data' (S3 8333, master UI 9333, filer UI 8888 are reachable only inside the stand)
127.0.0.1:8333 from the host -> connection refused
127.0.0.1:9333 from the host -> connection refused
127.0.0.1:8888 from the host -> connection refused
127.0.0.1:19333 from the host -> connection refused
secrets of api: ['cache_url', 'database_url', 's3_access_key_id', 's3_secret_access_key']
secrets of dispatcher: ['broker_url_dispatcher', 'database_url']
secrets of grafana: ['grafana_admin_password']
secrets of janitor: ['database_url', 's3_access_key_id', 's3_secret_access_key']
secrets of lb: -
secrets of loki: -
secrets of migrate: ['database_url']
secrets of otel-collector: -
secrets of postgres: ['postgres_password']
secrets of prometheus: -
secrets of rabbitmq: ['rabbitmq_definitions']
secrets of redis: ['redis_auth']
secrets of s3: ['s3_config']
secrets of s3-init: ['s3_access_key_id', 's3_root_password', 's3_root_user', 's3_secret_access_key']
secrets of telemetry-init: -
secrets of tempo: -
secrets of worker: ['broker_url_worker', 'database_url', 's3_access_key_id', 's3_secret_access_key']
PASS: S3 is reachable only inside the stand; admin keys are only in s3 and s3-init
s3-init: s3-init: bucket messenger-attachments exists
s3-init: s3-init: api key can put/get/list/delete objects of its bucket
s3-init: s3-init: api key cannot create buckets (AccessDenied)
s3-init: s3-init: bucket is private (anonymous list/get/put -> [403])
after the repeated bootstrap: old file downloads, new upload works
PASS: bucket/user/policy bootstrap can be repeated safely
4 passed, 0 failed
+6
View File
@@ -0,0 +1,6 @@
# smoke: public smoke via the balancer (make test) with telemetry ON, with attachment
# date: 2026-11-01 20:07:47, commit: 470d9d6 + uncommitted changes
# command: python.exe tests/smoke.py --base-url http://127.0.0.1:8080
# exit code: 0, 1.0 s
PASS: lab6 public API scenario; infrastructure and grading evidence remain separate.
+66
View File
@@ -0,0 +1,66 @@
# stack: stand layout: replicas, ports, limits, networks, secrets, S3, telemetry services
# date: 2026-11-01 20:07:46, commit: 470d9d6 + uncommitted changes
# command: python.exe student-tests/check_stack.py
# exit code: 0, 3.1 s
host: Windows 10, AMD64 Family 26 Model 68 Stepping 0, AuthenticAMD; client Python 3.11.1
Docker 28.1.1, Docker Compose version v2.35.1-desktop.1; Docker VM: 16 CPU, 15.2 GiB RAM, Docker Desktop
SERVICE CONTAINER ID STATUS PORTS
api 171a473b0d28 Up 26 seconds (healthy) 8080/tcp
api 1db2fedff78f Up 26 seconds (healthy) 8080/tcp
dispatcher 2f899202c4d1 Up 47 seconds (healthy)
grafana 23e7b8bb1b3a Up 49 seconds (healthy) 127.0.0.1:3000->3000/tcp
janitor 6dad6b402ed9 Up 26 seconds (healthy)
lb 0bffe8d8d7d2 Up 24 seconds (healthy) 127.0.0.1:8080->8080/tcp, 127.0.0.1:8404->8404/tcp
loki c62735c8baca Up 54 seconds 127.0.0.1:3100->3100/tcp
migrate dd9753ec4186 Exited (0) 48 seconds ago
otel-collector 8c416bdc0221 Up 55 seconds
postgres ced386ea9bbd Up 55 seconds (healthy)
prometheus 451bf5466e96 Up 55 seconds (healthy) 127.0.0.1:9090->9090/tcp
rabbitmq ec502659b532 Up 55 seconds (healthy)
redis 3c003ba9b32a Up 55 seconds (healthy)
s3 1e70a509e403 Up 55 seconds (healthy)
s3-init 64471229b155 Exited (0) 27 seconds ago
telemetry-init 809e227f3528 Exited (0) 55 seconds ago
tempo 3daf3848457f Up 54 seconds 127.0.0.1:3200->3200/tcp
worker cbd8138493bf Up 26 seconds (healthy)
container image cpus memory host ports networks
messenger-lab6-api-1 messenger-lab6-api 1.00 512 MiB - data,edge,telemetry
messenger-lab6-api-2 messenger-lab6-api 1.00 512 MiB - data,edge,telemetry
messenger-lab6-dispatcher-1 messenger-lab6-dispatcher 0.25 128 MiB - data,telemetry
messenger-lab6-grafana-1 grafana/grafana:12.4.14 0.50 384 MiB 127.0.0.1:3000 ops,telemetry
messenger-lab6-janitor-1 messenger-lab6-janitor 0.25 192 MiB - data,telemetry
messenger-lab6-lb-1 haproxy:3.2.25-alpine 0.50 128 MiB 127.0.0.1:8080,127.0.0.1:8404 edge
messenger-lab6-loki-1 grafana/loki:3.7.9 1.00 512 MiB 127.0.0.1:3100 ops,telemetry
messenger-lab6-otel-collector-1 otel/opentelemetry-collector-contrib:0.164.0 0.50 384 MiB - telemetry
messenger-lab6-postgres-1 postgres:17.11-alpine 1.00 512 MiB - data
messenger-lab6-prometheus-1 prom/prometheus:v3.15.1 1.00 512 MiB 127.0.0.1:9090 ops,telemetry
messenger-lab6-rabbitmq-1 rabbitmq:4.1.4-alpine 1.00 512 MiB - data
messenger-lab6-redis-1 redis:7.4.11-alpine 0.50 128 MiB - data
messenger-lab6-s3-1 chrislusf/seaweedfs:3.80 1.00 512 MiB - data
messenger-lab6-tempo-1 grafana/tempo:3.1.1 1.00 512 MiB 127.0.0.1:3200 ops,telemetry
messenger-lab6-worker-1 messenger-lab6-worker 2.00 1536 MiB - data,telemetry
secrets of api: ['cache_url', 'database_url', 's3_access_key_id', 's3_secret_access_key']
secrets of dispatcher: ['broker_url_dispatcher', 'database_url']
secrets of grafana: ['grafana_admin_password']
secrets of janitor: ['database_url', 's3_access_key_id', 's3_secret_access_key']
secrets of lb: -
secrets of loki: -
secrets of migrate: ['database_url']
secrets of otel-collector: -
secrets of postgres: ['postgres_password']
secrets of prometheus: -
secrets of rabbitmq: ['rabbitmq_definitions']
secrets of redis: ['redis_auth']
secrets of s3: ['s3_config']
secrets of s3-init: ['s3_access_key_id', 's3_root_password', 's3_root_user', 's3_secret_access_key']
secrets of telemetry-init: -
secrets of tempo: -
secrets of worker: ['broker_url_worker', 'database_url', 's3_access_key_id', 's3_secret_access_key']
through http://127.0.0.1:8080 one session is served by 2 replicas: ['171a473b0d28', '1db2fedff78f']
/health/ready -> 200 from 1db2fedff78f
PASS: 2 api replicas behind one entry point, no direct API ports, limits on every container, postgres/redis/s3/rabbitmq only in the internal data network, worker/dispatcher/janitor in data+telemetry, collector only in the internal telemetry network, prometheus/loki/tempo/grafana on 127.0.0.1 with persistent volumes, pinned images, S3 admin keys only in s3 and s3-init, broker credentials only in dispatcher/worker
+26
View File
@@ -0,0 +1,26 @@
# student-tests: lab1/lab2 API tests via the balancer
# date: 2026-11-01 20:42:40, commit: 470d9d6 + uncommitted changes
# command: python.exe student-tests/test_api.py
# exit code: 0, 2.8 s
PASS: duplicate username returns 409
PASS: invalid JSON returns 400
PASS: wrong and extra fields return 400
PASS: foreign chat returns 404
PASS: empty and too long messages return 400, 4000 chars is ok
PASS: pagination works across multiple pages, foreign cursor returns 400
PASS: empty cursor (?cursor= and ?cursor) returns 400, no cursor returns the first page
PASS: chat list pagination
PASS: unicode text is stored as is
PASS: strings with U+0000 are stored and returned as is
PASS: user response has no password or hash
PASS: password length 12..128, blank password is rejected
PASS: Basic login returns opaque Bearer token with expiry
PASS: wrong password and unknown user both return the same 401
PASS: malformed Basic header returns 401
PASS: password with colon and unicode works
PASS: business endpoints need Bearer; Basic and X-User-Id give 401
PASS: X-User-Id does not change the current user
PASS: 401 comes before 400 and 404
PASS: logout revokes only the current session
20 passed, 0 failed
+108
View File
@@ -0,0 +1,108 @@
# Сводка проверок (Docker-стенд, 2026-11-01)
Шаги запускались группами (`collect_evidence.py check stack smoke configs telemetry dashboard telemetry-history`, затем каждый инцидент и `load` отдельно, затем `--from jobs-variants`); `load` выполнен дважды — в группе lab6 и в регрессии, evidence/load.txt и load.json — от второго прогона.
| Шаг | Что проверяет | Результат | Время, с | Файл |
| --- | --- | --- | --- | --- |
| check | offline contract check (make check) | PASS | 0 | evidence/check.txt |
| stack | stand layout: replicas, ports, limits, networks, secrets, S3, telemetry services | PASS | 3 | evidence/stack.txt |
| smoke | public smoke via the balancer (make test) with telemetry ON, with attachment | PASS | 1 | evidence/smoke.txt |
| configs | lab6: collector/prometheus/loki/tempo configs by their own tools, alert unit tests, Grafana provisioning | PASS | 6 | evidence/configs.txt |
| telemetry | lab6: request<->log<->trace, upload->publish->consume->S3/DB chain, retry, replay link, no secrets | PASS | 79 | evidence/telemetry.txt |
| dashboard | lab6: every dashboard/rule query runs on live data, key signals present, no forbidden labels | PASS | 1 | evidence/dashboard.txt |
| telemetry-history | lab6: traces/logs/metrics survive restart of prometheus/loki/tempo (volumes) | PASS | 39 | evidence/telemetry-history.txt |
| incident-worker | lab6 incident 1: worker stopped -> queue lag + no consumers firing -> resolved | PASS | 162 | evidence/incident-worker.txt |
| incident-db | lab6 incident 2: slow PostgreSQL (table lock) -> high error rate firing, cause from traces -> resolved | PASS | 286 | evidence/incident-db.txt |
| incident-telemetry | lab6: Tempo+Loki down -> API unaffected, collector memory bounded, losses counted | PASS | 380 | evidence/incident-telemetry.txt |
| incident-collector | lab6: Collector down -> API unaffected, SDK queue bounded, drops counted | PASS | 156 | evidence/incident-collector.txt |
| load | public load generator, 30 s, concurrency 4 | PASS | 30 | evidence/load.txt |
| jobs-variants | lab5: thumbnail/crop/optimized, EXIF orientation, alpha, no upscale, metadata stripped | PASS | 20 | evidence/jobs-variants.txt |
| jobs-limits | lab5: worker limits - bytes, pixels, memory (RLIMIT_AS), time (JOB_TIMEOUT_SECONDS) | PASS | 73 | evidence/jobs-limits.txt |
| jobs-recovery | lab5: worker down -> 202 -> restart api+broker -> ready; broker down -> outbox waits | PASS | 55 | evidence/jobs-recovery.txt |
| jobs-outbox | lab5: dispatcher crash between COMMIT and publish / after confirm | PASS | 17 | evidence/jobs-outbox.txt |
| jobs-crash | lab5: worker crash after S3 PUT / after COMMIT before ack, staging cleanup, frozen worker lease | PASS | 157 | evidence/jobs-crash.txt |
| jobs-retry | lab5: backoff+jitter, retry_exhausted, replay, permanent errors, DLQ | PASS | 78 | evidence/jobs-retry.txt |
| jobs-janitor-replay | lab5: janitor does not delete objects re-written by replay (review fix) | PASS | 187 | evidence/jobs-janitor-replay.txt |
| jobs-concurrency | lab5: WORKER_CONCURRENCY consumers, prefetch 1, bounded processing | PASS | 16 | evidence/jobs-concurrency.txt |
| attachments | lab4: files, limits, damaged images, MIME, filenames, access, attachment_ids | PASS | 10 | evidence/attachments.txt |
| s3-security | lab4: private bucket outside API, limited API key, no console/ports, idempotent bootstrap | PASS | 10 | evidence/s3-security.txt |
| consistency | lab4: aborted upload, crash between S3 and DB, janitor, orphans, S3 outage | PASS | 160 | evidence/consistency.txt |
| upload-memory | lab4: >=10 concurrent uploads, peak memory of api replicas | PASS | 53 | evidence/upload-memory.txt |
| balancing | balancing, shared sessions/data/files, X-Instance-Id | PASS | 2 | evidence/balancing.txt |
| idempotency | Idempotency-Key, parallel same key via replicas | PASS | 2 | evidence/idempotency.txt |
| student-tests | lab1/lab2 API tests via the balancer | PASS | 3 | evidence/student-tests.txt |
| race | lab2 races via the balancer | PASS | 1 | evidence/race.txt |
| db | PostgreSQL: rollback, FK, Argon2id, unique keys, migrations | PASS | 12 | evidence/db.txt |
| redis | Redis as the session store | PASS | 3 | evidence/redis.txt |
| explain | EXPLAIN of the history page (full plans: explain-history.txt) | PASS | 1 | evidence/explain.txt |
| failover | public failover test for every replica, file downloaded via the other one (make test-failover) | PASS | 42 | evidence/failover.txt |
| load | public load generator, 30 s, concurrency 4 | PASS | 30 | evidence/load.txt |
| failures | Redis and PostgreSQL outages via the balancer | PASS | 56 | evidence/failures.txt |
| persistence | public persistence test incl. S3 + proof of real restarts (make test-persistence) | PASS | 62 | evidence/persistence.txt |
# Замеры
Машина: Windows 10, AMD64 Family 26 Model 68 Stepping 0, AuthenticAMD; Docker VM: 16 CPU, 15.2 GiB RAM; клиент Python 3.11.1; дата прогона 2026-11-01, commit 470d9d6 + uncommitted changes. Лимиты контейнеров: api 1 CPU / 512 MiB каждая, postgres, s3 (SeaweedFS) и rabbitmq по 1 CPU / 512 MiB, redis и lb по 0,5 CPU / 128 MiB, janitor 0,25 CPU / 192 MiB, dispatcher 0,25 CPU / 128 MiB, worker 2 CPU / 1536 MiB; lab6: otel-collector 0,5 CPU / 384 MiB, prometheus, loki, tempo по 1 CPU / 512 MiB, grafana 0,5 CPU / 384 MiB.
Алерты на контролируемых инцидентах (`student-tests/incidents.py`, состояние из Prometheus /api/v1/alerts):
| Инцидент | Воздействие | Алерт | firing через, с | resolved через, с после устранения |
| --- | --- | --- | --- | --- |
| 1. worker | `docker compose stop worker` + 3 загрузки | MessengerWorkerNoConsumers | 101.7 (от stop) | 29.7 (от start) |
| 1. worker | `docker compose stop worker` + 3 загрузки | MessengerQueueLagGrowing | 131.8 (от stop) | 29.7 (от start) |
| 2. PostgreSQL | `LOCK TABLE messages IN ACCESS EXCLUSIVE MODE` на 210 с под нагрузкой 8 потоков | MessengerHighErrorRate | 140.8 (от LOCK) | 50.1 (от COMMIT блокировки) |
| 3. телеметрия | `docker compose stop tempo loki` на 150 с | TelemetryExportFailing | 73.1 (от stop) | 165.6 (от start) |
Инцидент 1, наблюдения в момент firing: consumers очереди = 0.0, сообщений в RabbitMQ = 6.0, queued заданий = 3.0, возраст старейшего = 127.3 с, возраст outbox = 0.0 с (публикация работает), метрики worker не обновлялись 131.0 с, последний лог worker: event=`service.stopped`; трасса загрузки содержит `publish attachments`, но не содержит `process attachments.process.v1`. После start: вложения ready через 4.7 с, backlog 0.0.
Инцидент 2, наблюдения: доля 5xx (1m) = 1.0, коды POST /messages за 1m = {'201': 0.0, '200': 0.0, '404': 0.0, '400': 0.0, '409': 0.0, '503': 1.6}, p95 POST /messages = 7.375 с, чтения других таблиц (GET /users/me, /chats) во время блокировки {'GET /users/me + GET /chats, avg per request': 17.2, 'max': 23.5} мс, занято соединений пула = 8.0, p95 ожидания пула = 0.001 с, логи API event=db.unavailable по error_type: {'QueryCanceled': 216}. Error-трасса 237e2d6b1c7db22adbb7d4752fa47f2: server-спан 5013.3 мс, из них `INSERT` 5001.3 мс (доля 0.998, статус ERROR). Контраст «медленный обработчик» (трасса 4a222e478c2d51006538a7bfeb485eb1, POST /users): server 21.2 мс, `argon2id hash` 16.4 мс, все спаны БД 0.7 мс. Нагрузка: до 115.5 успешных записей/с, во время блокировки {'503': 320, '201': 8}, после 116.8/с без ошибок.
| Отказ телеметрии | API во время отказа | Память | Потери телеметрии |
| --- | --- | --- | --- |
| `stop tempo loki` на 150 с (окно повторов Collector 120 с) | 9555 запросов, коды {'201': 9555}, доля успеха 1.0 | heap Collector 35.5 -> max 86.9 MiB (limit 200), контейнер max 107.0 MiB | send/enqueue failed в Collector: {'spans': 4096, 'log_records': 235}; пробные трассы дошли 13/13, потеряны отправленные на [] с |
| `stop otel-collector` на 90 с | 5852 запросов, коды {'201': 5852}, доля успеха 1.0 | api 295.2 -> max 313.5 MiB (2 реплики) | SDK api потерял спанов: {'processor_queue_full': 8252, 'exporter_failed': 10752} (queue_full — очередь 2048 полна, exporter_failed — Collector не принял пакет); после start экспорт возобновился (10287 спанов за минуту) |
Публичный тест отказа (`make test-failover`, 15 с записи во время остановки реплики):
| Прогон | Остановлена реплика | Реплик до отказа | Успешных записей | Неудачных попыток (повторены с тем же ключом) | Первая запись после hook, с |
| --- | --- | --- | --- | --- | --- |
| 1 | 171a473b0d28 | 2 | 127 | 0 | 4.75 |
| 2 | 1db2fedff78f | 2 | 126 | 0 | 4.578 |
Одновременные загрузки (`student-tests/upload_memory.py`, перед каждым сценарием реплики перезапускаются, лимит api 512 MiB / 1 CPU). Пик RSS — VmHWM процесса API; cgroup — память контейнера, включая page cache временных файлов:
| Сценарий | Одновременно | Объём, MiB | Время, с (p50 / max) | Реплика: загрузок | RSS до, MiB | Пик RSS, MiB | Рост, MiB | Пик cgroup, MiB |
| --- | --- | --- | --- | --- | --- | --- | --- | --- |
| 10 x ~9.5 MiB PNG (noise) | 10 | 94.9 | 1.77 / 1.95 | 171a473b0d28: 5 | 109.6 | 124.5 | 14.9 | 162.8 |
| | | | | 1db2fedff78f: 5 | 110.5 | 125.6 | 15.1 | 163.3 |
| 10 x 40 Mpx PNG (8000x5000 RGB) | 10 | 1.1 | 0.98 / 1.3 | 171a473b0d28: 5 | 107.6 | 112.4 | 4.8 | 101.5 |
| | | | | 1db2fedff78f: 5 | 107.1 | 109.8 | 2.7 | 100.0 |
| 20 mixed: large + 40 Mpx + JPEG | 20 | 133.2 | 1.45 / 1.95 | 171a473b0d28: 10 | 109.0 | 136.3 | 27.3 | 191.4 |
| | | | | 1db2fedff78f: 10 | 110.6 | 135.0 | 24.3 | 172.8 |
Один PNG 8000x5000 RGB внутри контейнера api, дополнительный пик RSS: наивно (тело целиком в памяти + полное декодирование Pillow) 161 MiB, потоковая проверка 0 MiB. 10 таких наивных загрузок одновременно не поместились бы в 512 MiB.
Публичный генератор нагрузки (`tests/load.py`, closed loop, concurrency 4, 30 с, 2 реплики): 239.02 успешных POST/с, ошибок 0 (доля 0.0), задержка успешных p50 16.0 мс, p95 32.0 мс, p99 47.0 мс.
| Воздействие | Что ожидаем | Что наблюдали | Время восстановления / потеря данных |
| --- | --- | --- | --- |
| публичный `make test-failover` для каждой реплики | запись продолжается не позже 10 с, подтверждённые сообщения на месте, дублей нет | PASS 2 раз(а), неудачных попыток: 0, 0 | первая запись после hook через 4.75, 4.578 с (hook ждёт остановки ~4 с); потерь нет |
| перезапуск всего стенда (`restart` hook: postgres, redis, s3, api, janitor, lb) | данные, файл и прежний токен живы | PASS, те же контейнеры с новым временем старта | 60.9 с до готовности; потерь нет |
| `docker compose stop s3` (SeaweedFS остановлен) | загрузка и скачивание -> 503, метаданные, сообщения и /health/ready работают | upload 503 за 20234 мс, download 503, остальное 200/201 | после start файлы на месте; uploading-строку убрал janitor; потерь нет |
| `docker compose pause s3` (SeaweedFS завис) | то же, но через таймауты S3-клиента | upload 503 за 14703 мс (2 попытки x 5 с + откат 2 с) | после unpause файлы на месте; потерь нет |
| падение между PUT в S3 и COMMIT в БД (код API в контейнере, finish_upload падает) | вложение не видно, janitor не трогает его до конца grace period, потом удаляет объект и строку | GET/прикрепление -> 404; janitor: свежая строка сохранена, dry-run только отчёт, затем удалено | мусора не осталось; повторный проход ничего не делает |
| обрыв загрузки клиентом (9 МБ заявлено, отправлено 0,2 и 3 МБ) | ничего не сохраняется | строк и объектов не прибавилось, временных файлов 0 | мгновенно |
| worker остановлен, upload, рестарт rabbitmq и api с volumes, start worker | 202 queued, сообщение с вложением 201, content 409; после рестартов job в очереди; тот же job_id -> ready | worker started -> same job 6a45774d-0d88-46ec-87b9-70fb4c122bbd ready, thumbnail downloadable; staging object deleted | потерь нет; staging удалён после COMMIT |
| rabbitmq остановлен во время upload | 202 и /health/ready 200 без брокера; строка outbox ждёт; после start публикуется | rabbitmq started -> dispatcher published the pending row -> ready | потерь нет |
| crash dispatcher между COMMIT задания и publish | строка outbox не отмечена -> публикуется после рестарта процесса | dispatcher killed between COMMIT and publish; restarted by policy, outbox re-published -> job d1eb476a-fbe1-4271-861f-74f3e943b8cc ready, attempt 1, no manual action | без ручного действия |
| crash dispatcher после confirm, до отметки outbox | дубль сообщения, worker распознаёт по состоянию job | dispatcher killed after publisher confirm, before marking outbox -> message published twice; worker: ['created', 'claimed', 'ready', 'duplicate_ignored'] -> one result set | один набор вариантов |
| crash worker после PUT в S3, до COMMIT и ack | повтор после истечения аренды перезаписывает те же ключи | worker killed after S3 PUT (before COMMIT and ack): redelivery saw a live lease (no-op), lease expired after 15 s, attempt 2 rewrote the same keys -> one set; events ['created', 'claimed', 'duplicate_ignored', 'lease_expired', 'claimed', 'ready'] | один набор, 4 объекта |
| crash worker после COMMIT, до ack | redelivery ready-задачи -> no-op ack | worker killed after COMMIT, before ack: broker redelivered, worker acked as no-op (1:duplicate_ignored:status=ready); queue empty (0 ready, 0 unacked) | очередь пуста, дублей нет |
| worker завис (не продлевает аренду) | dispatcher возвращает job, другой поток завершает; поздний результат отклонён fencing | frozen attempt 1 stopped renewing; lease expired, recovered by dispatcher, attempt 2 ready after 17 s; frozen attempt woke up -> stale_result_rejected; events ['created', 'claimed', 'lease_expired', 'claimed', 'ready', 'stale_result_rejected'] | ready не откатан |
| зависание обработки изображения | процесс убит по JOB_TIMEOUT_SECONDS, временная ошибка, аренда продлевалась | imaging hang -> killed after 60 s (processing_timeout, temporary), lease renewed meanwhile (no lease_expired), attempt 2 ready after 62 s | повтор -> ready |
| нехватка памяти в процессе обработки (RLIMIT_AS) | failed/resource_limit, worker жив | memory bomb in the imaging process -> failed/resource_limit after attempt 1; worker itself survived | постоянная ошибка, без повторов |
| 2 временные ошибки S3 | backoff с jitter, затем ready | 2 x storage_unavailable -> retries after 1.90 s and 3.20 s (equal jitter: 1..2 s, 2..4 s), attempt 3 ready | - |
| 5 временных ошибок подряд | failed/retry_exhausted, реестр failed, content 409 | 5 temporary errors -> failed/retry_exhausted (public error_code), content 409, attach 409, listed by ops.py failed (replayable) | replay оператора |
| replay failed и повторный replay ready | тот же job_id -> ready; повтор отклонён | ops replay -> same job_id d8ab860c-eb40-4df2-8d98-67aade24f2f2 attempt 6 ready; second replay refused: "job is ready, replay is only for failed jobs" | дубля нет |
| невалидное сообщение и неизвестный job_id | reject -> DLQ, dlq-replay не исполняет | schema-invalid message and unknown job_id -> reject -> DLQ (2 message(s)); dlq-replay kept them: ['invalid message is kept for analysis', 'unknown job'] | сообщения сохранены |
| 8 заданий в очереди, старт worker | WORKER_CONCURRENCY=2, prefetch 1 | 2 consumers, prefetch_count 1, manual ack; 8 queued 3000x2000 JPEG drained in 2.4 s after worker start, peak processing 2 of 8 (6 samples) | - |
+9
View File
@@ -0,0 +1,9 @@
# telemetry-history: lab6: traces/logs/metrics survive restart of prometheus/loki/tempo (volumes)
# date: 2026-11-01 20:09:51, commit: 470d9d6 + uncommitted changes
# command: python.exe student-tests/test_telemetry.py history
# exit code: 0, 38.6 s
before restart: trace 0b9106c1057e9753186aec51b529946b found, its log found, sum(http_server_request_duration_seconds_count{job="messenger-api"}) at t-30s = 434
after restart of prometheus, loki, tempo: trace 0b9106c1057e9753186aec51b529946b (4 spans), 1 log record(s), metric at t-30s = 434 (same value)
PASS: persistent volumes keep traces, logs and metrics across restarts of the stores
1 passed, 0 failed
+145
View File
@@ -0,0 +1,145 @@
# telemetry: lab6: request<->log<->trace, upload->publish->consume->S3/DB chain, retry, replay link, no secrets
# date: 2026-11-01 20:09:11, commit: 470d9d6 + uncommitted changes
# command: python.exe student-tests/test_telemetry.py request upload-chain retry-chain replay-link
# exit code: 0, 78.6 s
POST message: 201, X-Request-Id=df174aef-1d0d-4340-b2d7-907241684f5e, trace_id=6be6bfe68dce05dd2bbbf0048a53c7ce (client traceparent)
- [api] POST /api/v1/chats/{chat_id}/messages (SERVER, 4.6 ms) http.response.status_code=201
- [api] redis GET (CLIENT, 0.2 ms)
- [api] SELECT (CLIENT, 0.3 ms)
- [api] INSERT (CLIENT, 0.4 ms)
Loki: 'POST /api/v1/chats/{chat_id}/messages -> 201 (4.6 ms)' event=http.request severity=INFO service=messenger-api trace_id=6be6bfe68dce05dd2bbbf0048a53c7ce span_id=78cd8621fce4f3b8 request_id=df174aef-1d0d-4340-b2d7-907241684f5e
PASS: request -> server span with DB/Redis children -> structured log with the same trace_id/span_id and request_id; no message text, password or token in logs/span attributes
- [api] POST /api/v1/chats/{chat_id}/attachments (SERVER, 13.5 ms) http.response.status_code=202
- [api] redis GET (CLIENT, 0.2 ms)
- [api] SELECT (CLIENT, 0.4 ms)
- [api] inspect image (INTERNAL, 0.5 ms)
- [api] INSERT (CLIENT, 0.6 ms)
- [api] S3 PutObject (CLIENT, 2.9 ms) aws.s3.key=staging/1b42fa0c1dd84589a58369be9f034238
- [api] UPDATE (CLIENT, 0.7 ms)
- [api] create attachments (PRODUCER, 2.4 ms) messenger.job.attempt=1
- [api] INSERT (CLIENT, 0.7 ms)
- [api] INSERT (CLIENT, 0.6 ms)
- [api] INSERT (CLIENT, 0.6 ms)
- [api] NOTIFY (CLIENT, 0.1 ms)
- [dispatcher] publish attachments (PRODUCER, 4.0 ms) messenger.job.attempt=1
- [dispatcher] UPDATE (CLIENT, 0.4 ms)
- [worker] process attachments.process.v1 (CONSUMER, 161.4 ms) messenger.job.attempt=1 messenger.job.outcome=ready
- [worker] SELECT (CLIENT, 0.4 ms)
- [worker] UPDATE (CLIENT, 0.3 ms)
- [worker] UPDATE (CLIENT, 0.4 ms)
- [worker] INSERT (CLIENT, 0.3 ms)
- [worker] S3 GetObject (CLIENT, 2.0 ms) aws.s3.key=staging/1b42fa0c1dd84589a58369be9f034238
- [worker] verify source sha256 (INTERNAL, 0.0 ms)
- [worker] imaging (INTERNAL, 139.8 ms)
- [worker] S3 PutObject (CLIENT, 2.8 ms) aws.s3.key=attachments/98cd3d9b-6ee6-4d65-8c63-9586acb34da1/v1/original
- [worker] S3 PutObject (CLIENT, 1.9 ms) aws.s3.key=attachments/98cd3d9b-6ee6-4d65-8c63-9586acb34da1/v1/optimized.webp
- [worker] S3 PutObject (CLIENT, 2.3 ms) aws.s3.key=attachments/98cd3d9b-6ee6-4d65-8c63-9586acb34da1/v1/thumbnail.jpg
- [worker] S3 PutObject (CLIENT, 1.8 ms) aws.s3.key=attachments/98cd3d9b-6ee6-4d65-8c63-9586acb34da1/v1/crop.jpg
- [worker] commit result (INTERNAL, 4.9 ms)
- [worker] SELECT (CLIENT, 0.5 ms)
- [worker] INSERT (CLIENT, 0.5 ms)
- [worker] INSERT (CLIENT, 0.3 ms)
- [worker] INSERT (CLIENT, 0.4 ms)
- [worker] UPDATE (CLIENT, 0.4 ms)
- [worker] UPDATE (CLIENT, 0.3 ms)
- [worker] INSERT (CLIENT, 0.3 ms)
- [worker] cleanup staging (INTERNAL, 4.7 ms)
- [worker] S3 DeleteObject (CLIENT, 2.2 ms) aws.s3.key=staging/1b42fa0c1dd84589a58369be9f034238
- [worker] UPDATE (CLIENT, 2.2 ms)
worker logs with trace_id f5d1897588244cad5fc6ded83b930725: ['job.claimed', 'job.ready']
PASS: one trace f5d1897588244cad5fc6ded83b930725: API 202 -> outbox create -> dispatcher publish -> worker consume -> 4 S3 objects + COMMIT ready (37 spans, services: messenger-api, messenger-dispatcher, messenger-worker)
- [api] POST /api/v1/chats/{chat_id}/attachments (SERVER, 12.6 ms) http.response.status_code=202
- [api] redis GET (CLIENT, 0.2 ms)
- [api] SELECT (CLIENT, 0.5 ms)
- [api] inspect image (INTERNAL, 0.3 ms)
- [api] INSERT (CLIENT, 0.6 ms)
- [api] S3 PutObject (CLIENT, 2.5 ms) aws.s3.key=staging/d44ab652329d41458bd477c6cf3ba29c
- [api] UPDATE (CLIENT, 0.6 ms)
- [api] create attachments (PRODUCER, 1.4 ms) messenger.job.attempt=1
- [api] INSERT (CLIENT, 0.4 ms)
- [api] INSERT (CLIENT, 0.3 ms)
- [api] INSERT (CLIENT, 0.3 ms)
- [api] NOTIFY (CLIENT, 0.1 ms)
- [dispatcher] publish attachments (PRODUCER, 4.2 ms) messenger.job.attempt=1
- [dispatcher] UPDATE (CLIENT, 0.4 ms)
- [worker] process attachments.process.v1 (CONSUMER, 135.6 ms) ERROR messenger.job.attempt=1 messenger.job.outcome=retry error.type=storage_unavailable
- [worker] SELECT (CLIENT, 0.4 ms)
- [worker] UPDATE (CLIENT, 0.4 ms)
- [worker] UPDATE (CLIENT, 0.4 ms)
- [worker] INSERT (CLIENT, 0.3 ms)
- [worker] S3 GetObject (CLIENT, 2.6 ms) aws.s3.key=staging/d44ab652329d41458bd477c6cf3ba29c
- [worker] verify source sha256 (INTERNAL, 0.0 ms)
- [worker] imaging (INTERNAL, 123.0 ms)
- [worker] SELECT (CLIENT, 0.4 ms)
- [worker] UPDATE (CLIENT, 0.5 ms)
- [worker] UPDATE (CLIENT, 0.3 ms)
- [worker] create attachments (PRODUCER, 1.0 ms) messenger.job.attempt=2
- [worker] INSERT (CLIENT, 0.6 ms)
- [worker] NOTIFY (CLIENT, 0.2 ms)
- [dispatcher] publish attachments (PRODUCER, 5.2 ms) messenger.job.attempt=2
- [dispatcher] UPDATE (CLIENT, 0.5 ms)
- [worker] process attachments.process.v1 (CONSUMER, 144.9 ms) messenger.job.attempt=2 messenger.job.outcome=ready
- [worker] SELECT (CLIENT, 0.4 ms)
- [worker] UPDATE (CLIENT, 0.4 ms)
- [worker] UPDATE (CLIENT, 0.4 ms)
- [worker] INSERT (CLIENT, 0.3 ms)
- [worker] S3 GetObject (CLIENT, 1.7 ms) aws.s3.key=staging/d44ab652329d41458bd477c6cf3ba29c
- [worker] verify source sha256 (INTERNAL, 0.0 ms)
- [worker] imaging (INTERNAL, 125.7 ms)
- [worker] S3 PutObject (CLIENT, 2.5 ms) aws.s3.key=attachments/214e2e86-8b1d-488b-99d8-5c60fd849c0c/v1/original
- [worker] S3 PutObject (CLIENT, 1.8 ms) aws.s3.key=attachments/214e2e86-8b1d-488b-99d8-5c60fd849c0c/v1/optimized.webp
- [worker] S3 PutObject (CLIENT, 1.7 ms) aws.s3.key=attachments/214e2e86-8b1d-488b-99d8-5c60fd849c0c/v1/thumbnail.jpg
- [worker] S3 PutObject (CLIENT, 1.6 ms) aws.s3.key=attachments/214e2e86-8b1d-488b-99d8-5c60fd849c0c/v1/crop.jpg
- [worker] commit result (INTERNAL, 4.4 ms)
- [worker] SELECT (CLIENT, 0.4 ms)
- [worker] INSERT (CLIENT, 0.4 ms)
- [worker] INSERT (CLIENT, 0.3 ms)
- [worker] INSERT (CLIENT, 0.2 ms)
- [worker] UPDATE (CLIENT, 0.4 ms)
- [worker] UPDATE (CLIENT, 0.3 ms)
- [worker] INSERT (CLIENT, 0.4 ms)
- [worker] cleanup staging (INTERNAL, 4.5 ms)
- [worker] S3 DeleteObject (CLIENT, 1.7 ms) aws.s3.key=staging/d44ab652329d41458bd477c6cf3ba29c
- [worker] UPDATE (CLIENT, 2.5 ms)
- [worker] INSERT (CLIENT, 0.4 ms)
worker log: 'job 7bd96513-9f85-471e-b553-ec49f9fe4560 attempt 1: storage_unavailable (temporary) -> retry' error_type=storage_unavailable
messenger_job_duration_seconds_count{outcome="retry"}: 0 -> 1
PASS: retry in one trace 5d34bb1eecbc90702d2f5e7de5b9bca6: attempt 1 ERROR storage_unavailable -> create -> publish -> attempt 2 ready; retry counted in metrics and logged
original trace 38319800cdce5da47cb2b821dc03bf6e: 5 attempts, last outcome failed
- [ops] ops replay (INTERNAL, 12.3 ms)
- [ops] SELECT (CLIENT, 1.9 ms)
- [ops] UPDATE (CLIENT, 0.6 ms)
- [ops] UPDATE (CLIENT, 0.4 ms)
- [ops] INSERT (CLIENT, 0.5 ms)
- [ops] create attachments (PRODUCER, 0.8 ms) links=1 messenger.job.attempt=6
- [ops] INSERT (CLIENT, 0.5 ms)
- [ops] NOTIFY (CLIENT, 0.2 ms)
- [dispatcher] publish attachments (PRODUCER, 70.0 ms) messenger.job.attempt=6
- [dispatcher] UPDATE (CLIENT, 66.1 ms)
- [worker] process attachments.process.v1 (CONSUMER, 145.2 ms) messenger.job.attempt=6 messenger.job.outcome=ready
- [worker] SELECT (CLIENT, 0.5 ms)
- [worker] UPDATE (CLIENT, 0.5 ms)
- [worker] UPDATE (CLIENT, 0.5 ms)
- [worker] INSERT (CLIENT, 0.2 ms)
- [worker] S3 GetObject (CLIENT, 1.7 ms) aws.s3.key=staging/31f520a1f9d2445689ed0344a495998f
- [worker] verify source sha256 (INTERNAL, 0.0 ms)
- [worker] imaging (INTERNAL, 125.7 ms)
- [worker] S3 PutObject (CLIENT, 2.5 ms) aws.s3.key=attachments/ebdeb0f4-a519-42b0-808b-3e6cf118b861/v1/original
- [worker] S3 PutObject (CLIENT, 2.0 ms) aws.s3.key=attachments/ebdeb0f4-a519-42b0-808b-3e6cf118b861/v1/optimized.webp
- [worker] S3 PutObject (CLIENT, 1.6 ms) aws.s3.key=attachments/ebdeb0f4-a519-42b0-808b-3e6cf118b861/v1/thumbnail.jpg
- [worker] S3 PutObject (CLIENT, 1.6 ms) aws.s3.key=attachments/ebdeb0f4-a519-42b0-808b-3e6cf118b861/v1/crop.jpg
- [worker] commit result (INTERNAL, 4.4 ms)
- [worker] SELECT (CLIENT, 0.5 ms)
- [worker] INSERT (CLIENT, 0.3 ms)
- [worker] INSERT (CLIENT, 0.2 ms)
- [worker] INSERT (CLIENT, 0.2 ms)
- [worker] UPDATE (CLIENT, 0.4 ms)
- [worker] UPDATE (CLIENT, 0.3 ms)
- [worker] INSERT (CLIENT, 0.3 ms)
- [worker] cleanup staging (INTERNAL, 4.1 ms)
- [worker] S3 DeleteObject (CLIENT, 2.1 ms) aws.s3.key=staging/31f520a1f9d2445689ed0344a495998f
- [worker] UPDATE (CLIENT, 1.8 ms)
replay trace 9417040b8f913c26894caaaf0996e442: create span links -> ['38319800cdce5da47cb2b821dc03bf6e'] (original upload trace 38319800cdce5da47cb2b821dc03bf6e)
PASS: replay = new trace (root 'ops replay') with a link to the original upload; worker finished it
4 passed, 0 failed
+124
View File
@@ -0,0 +1,124 @@
{
"date": "2026-11-01 20:42",
"api_limit_mib": 512,
"api_limit_cpus": 1.0,
"runs": [
{
"scenario": "10 x ~9.5 MiB PNG (noise)",
"concurrency": 10,
"file_bytes": [
9953047
],
"total_mib": 94.9,
"all_202": true,
"wall_seconds": 1.95,
"latency_s": {
"p50": 1.77,
"max": 1.95
},
"sampler_rounds": 16,
"replicas": [
{
"replica": "171a473b0d28",
"uploads_served": 5,
"rss_before_mib": 109.6,
"rss_peak_mib": 124.5,
"rss_growth_mib": 14.9,
"rss_peak_sampled_mib": 124.5,
"cgroup_peak_mib": 162.8,
"cgroup_peak_sampled_mib": 160.2
},
{
"replica": "1db2fedff78f",
"uploads_served": 5,
"rss_before_mib": 110.5,
"rss_peak_mib": 125.6,
"rss_growth_mib": 15.1,
"rss_peak_sampled_mib": 125.6,
"cgroup_peak_mib": 163.3,
"cgroup_peak_sampled_mib": 160.8
}
]
},
{
"scenario": "10 x 40 Mpx PNG (8000x5000 RGB)",
"concurrency": 10,
"file_bytes": [
116714
],
"total_mib": 1.1,
"all_202": true,
"wall_seconds": 1.3,
"latency_s": {
"p50": 0.98,
"max": 1.3
},
"sampler_rounds": 9,
"replicas": [
{
"replica": "171a473b0d28",
"uploads_served": 5,
"rss_before_mib": 107.6,
"rss_peak_mib": 112.4,
"rss_growth_mib": 4.8,
"rss_peak_sampled_mib": 112.4,
"cgroup_peak_mib": 101.5,
"cgroup_peak_sampled_mib": 101.4
},
{
"replica": "1db2fedff78f",
"uploads_served": 5,
"rss_before_mib": 107.1,
"rss_peak_mib": 109.8,
"rss_growth_mib": 2.7,
"rss_peak_sampled_mib": 109.8,
"cgroup_peak_mib": 100.0,
"cgroup_peak_sampled_mib": 100.0
}
]
},
{
"scenario": "20 mixed: large + 40 Mpx + JPEG",
"concurrency": 20,
"file_bytes": [
1492,
116714,
9953047
],
"total_mib": 133.2,
"all_202": true,
"wall_seconds": 1.95,
"latency_s": {
"p50": 1.45,
"max": 1.95
},
"sampler_rounds": 11,
"replicas": [
{
"replica": "171a473b0d28",
"uploads_served": 10,
"rss_before_mib": 109.0,
"rss_peak_mib": 136.3,
"rss_growth_mib": 27.3,
"rss_peak_sampled_mib": 136.3,
"cgroup_peak_mib": 191.4,
"cgroup_peak_sampled_mib": 191.4
},
{
"replica": "1db2fedff78f",
"uploads_served": 10,
"rss_before_mib": 110.6,
"rss_peak_mib": 135.0,
"rss_growth_mib": 24.3,
"rss_peak_sampled_mib": 135.0,
"cgroup_peak_mib": 172.8,
"cgroup_peak_sampled_mib": 171.4
}
]
}
],
"single_file_extra_rss_mib": {
"naive": 161,
"streaming": 0
}
}
+13
View File
@@ -0,0 +1,13 @@
# upload-memory: lab4: >=10 concurrent uploads, peak memory of api replicas
# date: 2026-11-01 20:42:33, commit: 470d9d6 + uncommitted changes
# command: python.exe student-tests/upload_memory.py --output evidence/upload-memory.json
# exit code: 0, 53.4 s
client: Python 3.11.1 on Windows 10
preparing synthetic images (random-noise PNG ~9.5 MiB each, 40 Mpx PNG)...
large: 9953047 bytes; 40 Mpx: 116714 bytes
{"scenario": "10 x ~9.5 MiB PNG (noise)", "concurrency": 10, "file_bytes": [9953047], "total_mib": 94.9, "all_202": true, "wall_seconds": 1.95, "latency_s": {"p50": 1.77, "max": 1.95}, "sampler_rounds": 16, "replicas": [{"replica": "171a473b0d28", "uploads_served": 5, "rss_before_mib": 109.6, "rss_peak_mib": 124.5, "rss_growth_mib": 14.9, "rss_peak_sampled_mib": 124.5, "cgroup_peak_mib": 162.8, "cgroup_peak_sampled_mib": 160.2}, {"replica": "1db2fedff78f", "uploads_served": 5, "rss_before_mib": 110.5, "rss_peak_mib": 125.6, "rss_growth_mib": 15.1, "rss_peak_sampled_mib": 125.6, "cgroup_peak_mib": 163.3, "cgroup_peak_sampled_mib": 160.8}]}
{"scenario": "10 x 40 Mpx PNG (8000x5000 RGB)", "concurrency": 10, "file_bytes": [116714], "total_mib": 1.1, "all_202": true, "wall_seconds": 1.3, "latency_s": {"p50": 0.98, "max": 1.3}, "sampler_rounds": 9, "replicas": [{"replica": "171a473b0d28", "uploads_served": 5, "rss_before_mib": 107.6, "rss_peak_mib": 112.4, "rss_growth_mib": 4.8, "rss_peak_sampled_mib": 112.4, "cgroup_peak_mib": 101.5, "cgroup_peak_sampled_mib": 101.4}, {"replica": "1db2fedff78f", "uploads_served": 5, "rss_before_mib": 107.1, "rss_peak_mib": 109.8, "rss_growth_mib": 2.7, "rss_peak_sampled_mib": 109.8, "cgroup_peak_mib": 100.0, "cgroup_peak_sampled_mib": 100.0}]}
{"scenario": "20 mixed: large + 40 Mpx + JPEG", "concurrency": 20, "file_bytes": [1492, 116714, 9953047], "total_mib": 133.2, "all_202": true, "wall_seconds": 1.95, "latency_s": {"p50": 1.45, "max": 1.95}, "sampler_rounds": 11, "replicas": [{"replica": "171a473b0d28", "uploads_served": 10, "rss_before_mib": 109.0, "rss_peak_mib": 136.3, "rss_growth_mib": 27.3, "rss_peak_sampled_mib": 136.3, "cgroup_peak_mib": 191.4, "cgroup_peak_sampled_mib": 191.4}, {"replica": "1db2fedff78f", "uploads_served": 10, "rss_before_mib": 110.6, "rss_peak_mib": 135.0, "rss_growth_mib": 24.3, "rss_peak_sampled_mib": 135.0, "cgroup_peak_mib": 172.8, "cgroup_peak_sampled_mib": 171.4}]}
one 8000x5000 RGB PNG inside the api container, extra peak RSS: naive (body in RAM + full decode) 161 MiB, streaming check 0 MiB
PASS: all uploads succeeded; largest RSS growth of one replica: 27.3 MiB (limit 512 MiB); results in evidence/upload-memory.json