выполнение ЛР4 на 4

- S3: SeaweedFS 4.51 (MinIO-образы недоступны), приватный bucket,
  отдельные ограниченные ключи API, служебные порты закрыты;
  идемпотентный s3-init с проверкой приватности и прогревом записи
- вложения: потоковая загрузка PNG/JPEG, лимиты 10 MiB / 40 Мпикс,
  тип по содержимому, проверка filename, скачивание только участникам
- согласованность PG/S3: pending -> PUT -> ready, компенсация, sweeper
  с grace и dry-run; attachment_ids в сообщениях, FK по чату
- back-pressure на S3 PUT после найденного OOM SeaweedFS
- тесты student-tests, evidence, REPORT.md, DEMO.md
This commit is contained in:
Ilya
2026-10-28 18:06:07 +03:00
parent ec540a1a72
commit a97c35fc12
60 changed files with 4369 additions and 17 deletions
+50
View File
@@ -0,0 +1,50 @@
# 2026-10-28T12:44:18Z
$ make test-attachments
PASS png+jpeg upload, member download is byte-identical, metadata stable
PASS message with only attachments, order kept, history shows links, re-use by other member
PASS idempotency: missing attachment_ids == [], other attachments -> 409
PASS exactly 40 000 000 px accepted
PASS 10 MiB + 1 byte with Content-Length -> 413
PASS 10 MiB + 1 byte chunked (no Content-Length) -> 413 while streaming
PASS decompression bomb 8000x5001 px (~1 KB/40 MB raw) -> 413
PASS RGB 20000x20000 header -> 413 before decode
PASS truncated PNG -> 415
PASS PNG with damaged IDAT byte (CRC) -> 415
PASS truncated JPEG -> 415
PASS PNG bytes declared image/jpeg -> 415
PASS JPEG bytes declared image/png -> 415
PASS text declared image/png -> 415
PASS GIF declared image/png -> 415
PASS SVG/HTML declared image/png -> 415
PASS PNG magic + garbage -> 415
PASS empty body -> 415
PASS Content-Type application/octet-stream -> 415
PASS Content-Type multipart/form-data -> 415
PASS filename missing -> 400
PASS filename path ../ -> 400
PASS filename slash -> 400
PASS filename backslash -> 400
PASS filename NUL -> 400
PASS filename newline -> 400
PASS filename bidi RLO -> 400
PASS filename dot-dot -> 400
PASS filename blank -> 400
PASS filename 256 chars -> 400
PASS outsider uploads into chat -> 404
PASS outsider metadata -> 404
PASS outsider content -> 404
PASS unknown attachment -> 404
PASS invalid attachment UUID -> 400
PASS no session -> 401
PASS variant thumbnail not produced in lab4 -> 404
PASS unknown variant -> 400
PASS variant=original explicit -> 200
PASS attachment of another chat (same author) -> 404
PASS outsider links chat attachment into own chat -> 404
PASS unknown attachment id in message -> 404
PASS 11 attachment ids -> 400
PASS duplicate attachment ids -> 400
PASS blank text without attachments -> 400
PASS attachment_ids wrong type -> 400
PASS DB composite FK rejects cross-chat link even bypassing API
PASS: 47 attachment cases
+6
View File
@@ -0,0 +1,6 @@
# 2026-10-28T12:44:12Z repeat bootstrap on existing volumes
$ docker compose run --rm --no-deps s3-init
INFO s3-bootstrap: bucket messenger-attachments already exists
INFO s3-bootstrap: anonymous list/get denied: bucket is private
$ docker compose run --rm --no-deps migrate
INFO migrate: migrations up to date: 0 applied now, 3 before
+10
View File
@@ -0,0 +1,10 @@
# 2026-10-28T12:51:16Z
$ make test-consistency
PASS S3 down: upload 503 in 0.79s, content 503, metadata 200 (ready), messages 201, ready 200, no pending row left
PASS S3 back (healthy per compose): first download byte-identical after 0.0s
PASS aborted upload (1.1 of 5 MiB sent): no S3 object, no metadata row
injected: orphan object, stale pending row + object, stale pending row without object; waiting 63s
dry-run: {"pending_found": 2, "orphans_found": 1, "objects_scanned": 28, "duration_ms": 186.1}
real: {"pending_deleted": 2, "orphans_deleted": 1, "objects_scanned": 27, "duration_ms": 203.2}
repeat: {"pending_found": 0, "orphans_found": 0}
PASS sweeper: dry-run reports only; real pass removes stale pending rows/objects and orphans; fresh and ready kept; repeat is a no-op
+153
View File
@@ -0,0 +1,153 @@
{
"profile": "closed loop, 8 workers, each: POST message (retry same key) + GET history; client timeout 2 s",
"action": "scripts/stop-container.sh messenger-lab4-api-1",
"action_started_s": 5.03,
"action_finished_s": 7.7,
"action_returncode": 0,
"action_output": [
"2026-10-28T12:54:50Z stopped messenger-lab4-api-1 instance=api-a442bb8f state=exited"
],
"elapsed_s": 25.2,
"requests": 8858,
"successful": 8858,
"errors": 0,
"error_ratio": 0.0,
"successful_rps": 351.5,
"latency_ms_success": {
"p50": 14.3,
"p95": 60.7,
"p99": 96.4,
"max": 306.4
},
"slow_over_500ms_after_action": 0,
"error_window_s": null,
"recovery_s_after_action": 0.0,
"instances_before": {
"api-e3ad2cfc": 1089,
"api-a442bb8f": 1090
},
"instances_last_5s": {
"api-e3ad2cfc": 1508
},
"timeline_ok_err_per_s": {
"0": [
372,
0
],
"1": [
319,
0
],
"2": [
489,
0
],
"3": [
497,
0
],
"4": [
488,
0
],
"5": [
276,
0
],
"6": [
256,
0
],
"7": [
266,
0
],
"8": [
261,
0
],
"9": [
383,
0
],
"10": [
365,
0
],
"11": [
354,
0
],
"12": [
433,
0
],
"13": [
451,
0
],
"14": [
293,
0
],
"15": [
424,
0
],
"16": [
401,
0
],
"17": [
365,
0
],
"18": [
282,
0
],
"19": [
309,
0
],
"20": [
351,
0
],
"21": [
266,
0
],
"22": [
180,
0
],
"23": [
302,
0
],
"24": [
471,
0
],
"25": [
4,
0
]
},
"docker_stats_mid": [
"messenger-lab4-api-2\t50.60%\t146.7MiB / 384MiB",
"messenger-lab4-lb-1\t12.87%\t16.84MiB / 128MiB",
"messenger-lab4-postgres-1\t22.94%\t59.46MiB / 512MiB",
"messenger-lab4-s3-1\t0.59%\t172.8MiB / 768MiB",
"messenger-lab4-sweeper-1\t0.00%\t58.7MiB / 128MiB",
"messenger-lab4-valkey-1\t1.58%\t10.67MiB / 96MiB"
],
"integrity": {
"stored_messages": 4429,
"confirmed_writes": 4429,
"duplicate_ids": 0,
"duplicate_texts": 0,
"confirmed_missing": 0
}
}
+153
View File
@@ -0,0 +1,153 @@
{
"profile": "closed loop, 8 workers, each: POST message (retry same key) + GET history; client timeout 2 s",
"action": "scripts/stop-container.sh messenger-lab4-api-2",
"action_started_s": 5.0,
"action_finished_s": 6.07,
"action_returncode": 0,
"action_output": [
"2026-10-28T12:55:28Z stopped messenger-lab4-api-2 instance=api-e3ad2cfc state=exited"
],
"elapsed_s": 25.02,
"requests": 6790,
"successful": 6790,
"errors": 0,
"error_ratio": 0.0,
"successful_rps": 271.4,
"latency_ms_success": {
"p50": 16.1,
"p95": 69.7,
"p99": 149.3,
"max": 1033.6
},
"slow_over_500ms_after_action": 16,
"error_window_s": null,
"recovery_s_after_action": 2.97,
"instances_before": {
"api-e3ad2cfc": 867,
"api-f80d6006": 869
},
"instances_last_5s": {
"api-f80d6006": 1379
},
"timeline_ok_err_per_s": {
"0": [
396,
0
],
"1": [
364,
0
],
"2": [
369,
0
],
"3": [
295,
0
],
"4": [
309,
0
],
"5": [
300,
0
],
"6": [
15,
0
],
"7": [
21,
0
],
"8": [
332,
0
],
"9": [
285,
0
],
"10": [
175,
0
],
"11": [
297,
0
],
"12": [
329,
0
],
"13": [
324,
0
],
"14": [
295,
0
],
"15": [
246,
0
],
"16": [
287,
0
],
"17": [
184,
0
],
"18": [
341,
0
],
"19": [
246,
0
],
"20": [
111,
0
],
"21": [
324,
0
],
"22": [
276,
0
],
"23": [
323,
0
],
"24": [
343,
0
],
"25": [
3,
0
]
},
"docker_stats_mid": [
"messenger-lab4-api-1\t46.83%\t85.9MiB / 384MiB",
"messenger-lab4-lb-1\t11.21%\t16.87MiB / 128MiB",
"messenger-lab4-postgres-1\t19.60%\t62.48MiB / 512MiB",
"messenger-lab4-s3-1\t0.63%\t182.8MiB / 768MiB",
"messenger-lab4-sweeper-1\t0.00%\t58.7MiB / 128MiB",
"messenger-lab4-valkey-1\t1.64%\t10.69MiB / 96MiB"
],
"integrity": {
"stored_messages": 3395,
"confirmed_writes": 3395,
"duplicate_ids": 0,
"duplicate_texts": 0,
"confirmed_missing": 0
}
}
+14
View File
@@ -0,0 +1,14 @@
# 2026-10-28T12:50:25Z (immediately after the persistence restart)
## run 1
$ make test-failover ACTION_SCRIPT=scripts/stop-one.sh
Executing explicit failover hook; hook output suppressed to avoid leaking secrets.
{"observed_instances_before": 2, "successful_writes": 111, "failed_attempts": 0, "first_recovery_seconds": 3.254}
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
## run 2
$ make test-failover ACTION_SCRIPT=scripts/stop-one.sh
Executing explicit failover hook; hook output suppressed to avoid leaking secrets.
{"observed_instances_before": 2, "successful_writes": 119, "failed_attempts": 0, "first_recovery_seconds": 1.805}
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
## stop-one.sh log
2026-10-28T12:50:30Z stopped messenger-lab4-api-1 (1765636c87f6) instance=api-32eb21c0 state=exited
2026-10-28T12:50:54Z stopped messenger-lab4-api-1 (1765636c87f6) instance=api-53bf8995 state=exited
+13
View File
@@ -0,0 +1,13 @@
# 2026-10-28T12:44:24Z
$ student-tests/idempotency_test.py
ok - round 1: 32 parallel requests, 1 message, replicas {'api-657e97b1': 16, 'api-4d7d8490': 16}
ok - round 2: 32 parallel requests, 1 message, replicas {'api-657e97b1': 16, 'api-4d7d8490': 16}
ok - round 3: 32 parallel requests, 1 message, replicas {'api-657e97b1': 16, 'api-4d7d8490': 16}
ok - round 4: 32 parallel requests, 1 message, replicas {'api-657e97b1': 16, 'api-4d7d8490': 16}
ok - round 5: 32 parallel requests, 1 message, replicas {'api-657e97b1': 16, 'api-4d7d8490': 16}
ok - different body with same key -> 409, original replays unchanged
ok - same key independent per user and per chat
ok - missing/invalid Idempotency-Key -> 400, max-length key accepted
ok - replay needs a valid session and chat access (404 outsider, 401 revoked)
ok - DB rows in chat: 8, history items: 8, no duplicate texts
PASS: shared idempotency
+17
View File
@@ -0,0 +1,17 @@
{
"lab": 4,
"workload": "closed-loop POST messages; no automatic retries",
"requested_duration_seconds": 30.0,
"elapsed_seconds": 30.033,
"concurrency": 4,
"successful_requests": 14146,
"failed_requests": 0,
"error_ratio": 0.0,
"successful_rps": 471.014,
"successful_latency_ms": {
"p50": 7.387,
"p95": 12.989,
"p99": 32.668
},
"note": "Latency percentiles cover successes only. Timeouts/errors are counted separately; closed-loop has coordinated omission and client overhead."
}
+49
View File
@@ -0,0 +1,49 @@
{
"label": "body-in-RAM, 10x noise",
"kind": "noise",
"file_bytes": 9617088,
"concurrency": 10,
"statuses": {
"201": 10
},
"per_instance": {
"api-41dde5be": 5,
"api-1312fe88": 5
},
"wall_seconds": 3.89,
"latency_s": {
"p50": 3.8085,
"max": 3.883
},
"memory_mib": {
"messenger-lab4-api-1": {
"baseline_anon": 63.9,
"peak_anon": 147.0,
"delta_anon": 83.1,
"baseline_current": 69.1,
"peak_current": 154.1,
"peak_file_cache": 0.0
},
"messenger-lab4-api-2": {
"baseline_anon": 64.0,
"peak_anon": 141.3,
"delta_anon": 77.3,
"baseline_current": 69.5,
"peak_current": 149.8,
"peak_file_cache": 0.0
},
"messenger-lab4-s3-1": {
"baseline_anon": 324.5,
"peak_anon": 426.0,
"delta_anon": 101.5,
"baseline_current": 700.3,
"peak_current": 768.0,
"peak_file_cache": 368.7
}
},
"api_env": {
"UPLOAD_SPOOL_BYTES": "16777216",
"UPLOAD_CONCURRENCY": "16",
"DECODE_CONCURRENCY": "1"
}
}
+49
View File
@@ -0,0 +1,49 @@
{
"label": "body-in-RAM, 20x noise",
"kind": "noise",
"file_bytes": 9617088,
"concurrency": 20,
"statuses": {
"201": 20
},
"per_instance": {
"api-7a770f14": 10,
"api-d37e4357": 10
},
"wall_seconds": 6.04,
"latency_s": {
"p50": 5.1419999999999995,
"max": 6.039
},
"memory_mib": {
"messenger-lab4-api-1": {
"baseline_anon": 63.9,
"peak_anon": 201.6,
"delta_anon": 137.6,
"baseline_current": 69.3,
"peak_current": 212.7,
"peak_file_cache": 0.0
},
"messenger-lab4-api-2": {
"baseline_anon": 64.1,
"peak_anon": 206.6,
"delta_anon": 142.5,
"baseline_current": 69.2,
"peak_current": 218.6,
"peak_file_cache": 0.0
},
"messenger-lab4-s3-1": {
"baseline_anon": 326.7,
"peak_anon": 449.2,
"delta_anon": 122.5,
"baseline_current": 688.2,
"peak_current": 768.0,
"peak_file_cache": 373.1
}
},
"api_env": {
"UPLOAD_SPOOL_BYTES": "16777216",
"UPLOAD_CONCURRENCY": "16",
"DECODE_CONCURRENCY": "1"
}
}
+49
View File
@@ -0,0 +1,49 @@
{
"label": "body-in-RAM, 40x noise",
"kind": "noise",
"file_bytes": 9617088,
"concurrency": 40,
"statuses": {
"201": 40
},
"per_instance": {
"api-3c932187": 20,
"api-a0b8ffd2": 20
},
"wall_seconds": 9.86,
"latency_s": {
"p50": 7.7555,
"max": 9.859
},
"memory_mib": {
"messenger-lab4-api-1": {
"baseline_anon": 64.0,
"peak_anon": 257.9,
"delta_anon": 194.0,
"baseline_current": 69.3,
"peak_current": 270.4,
"peak_file_cache": 0.0
},
"messenger-lab4-api-2": {
"baseline_anon": 64.0,
"peak_anon": 284.8,
"delta_anon": 220.8,
"baseline_current": 69.6,
"peak_current": 296.2,
"peak_file_cache": 0.0
},
"messenger-lab4-s3-1": {
"baseline_anon": 333.1,
"peak_anon": 433.5,
"delta_anon": 100.4,
"baseline_current": 736.0,
"peak_current": 768.0,
"peak_file_cache": 387.7
}
},
"api_env": {
"UPLOAD_SPOOL_BYTES": "16777216",
"UPLOAD_CONCURRENCY": "16",
"DECODE_CONCURRENCY": "1"
}
}
+49
View File
@@ -0,0 +1,49 @@
{
"label": "stream, 10x noise",
"kind": "noise",
"file_bytes": 9617088,
"concurrency": 10,
"statuses": {
"201": 10
},
"per_instance": {
"api-4c952443": 5,
"api-6a870ec1": 5
},
"wall_seconds": 2.73,
"latency_s": {
"p50": 2.5810000000000004,
"max": 2.729
},
"memory_mib": {
"messenger-lab4-api-1": {
"baseline_anon": 64.0,
"peak_anon": 102.5,
"delta_anon": 38.5,
"baseline_current": 69.4,
"peak_current": 155.3,
"peak_file_cache": 45.9
},
"messenger-lab4-api-2": {
"baseline_anon": 63.9,
"peak_anon": 96.3,
"delta_anon": 32.4,
"baseline_current": 69.2,
"peak_current": 147.2,
"peak_file_cache": 45.9
},
"messenger-lab4-s3-1": {
"baseline_anon": 324.8,
"peak_anon": 379.5,
"delta_anon": 54.7,
"baseline_current": 741.6,
"peak_current": 768.0,
"peak_file_cache": 384.9
}
},
"api_env": {
"UPLOAD_SPOOL_BYTES": "1048576",
"UPLOAD_CONCURRENCY": "16",
"DECODE_CONCURRENCY": "1"
}
}
+49
View File
@@ -0,0 +1,49 @@
{
"label": "stream, 10x 40Mpx",
"kind": "pixels",
"file_bytes": 116709,
"concurrency": 10,
"statuses": {
"201": 10
},
"per_instance": {
"api-6d8b2e85": 5,
"api-982fda78": 5
},
"wall_seconds": 3.17,
"latency_s": {
"p50": 2.0375,
"max": 3.167
},
"memory_mib": {
"messenger-lab4-api-1": {
"baseline_anon": 63.9,
"peak_anon": 225.8,
"delta_anon": 161.8,
"baseline_current": 69.9,
"peak_current": 233.3,
"peak_file_cache": 0.0
},
"messenger-lab4-api-2": {
"baseline_anon": 64.0,
"peak_anon": 227.8,
"delta_anon": 163.7,
"baseline_current": 68.7,
"peak_current": 235.2,
"peak_file_cache": 0.0
},
"messenger-lab4-s3-1": {
"baseline_anon": 323.6,
"peak_anon": 324.7,
"delta_anon": 1.1,
"baseline_current": 698.3,
"peak_current": 700.4,
"peak_file_cache": 346.3
}
},
"api_env": {
"UPLOAD_SPOOL_BYTES": "1048576",
"UPLOAD_CONCURRENCY": "16",
"DECODE_CONCURRENCY": "1"
}
}
+49
View File
@@ -0,0 +1,49 @@
{
"label": "stream, 20x noise",
"kind": "noise",
"file_bytes": 9617088,
"concurrency": 20,
"statuses": {
"201": 20
},
"per_instance": {
"api-0b7cc085": 10,
"api-bc5d6770": 10
},
"wall_seconds": 5.2,
"latency_s": {
"p50": 4.5794999999999995,
"max": 5.193
},
"memory_mib": {
"messenger-lab4-api-1": {
"baseline_anon": 63.9,
"peak_anon": 96.0,
"delta_anon": 32.1,
"baseline_current": 69.1,
"peak_current": 196.8,
"peak_file_cache": 91.7
},
"messenger-lab4-api-2": {
"baseline_anon": 64.0,
"peak_anon": 101.4,
"delta_anon": 37.3,
"baseline_current": 69.4,
"peak_current": 200.3,
"peak_file_cache": 91.7
},
"messenger-lab4-s3-1": {
"baseline_anon": 323.7,
"peak_anon": 421.9,
"delta_anon": 98.2,
"baseline_current": 733.9,
"peak_current": 768.0,
"peak_file_cache": 399.3
}
},
"api_env": {
"UPLOAD_SPOOL_BYTES": "1048576",
"UPLOAD_CONCURRENCY": "16",
"DECODE_CONCURRENCY": "1"
}
}
+49
View File
@@ -0,0 +1,49 @@
{
"label": "stream, 40x noise",
"kind": "noise",
"file_bytes": 9617088,
"concurrency": 40,
"statuses": {
"201": 40
},
"per_instance": {
"api-426f6ce1": 20,
"api-a3f1971e": 20
},
"wall_seconds": 9.24,
"latency_s": {
"p50": 6.92,
"max": 9.231
},
"memory_mib": {
"messenger-lab4-api-1": {
"baseline_anon": 63.9,
"peak_anon": 113.0,
"delta_anon": 49.1,
"baseline_current": 69.6,
"peak_current": 268.4,
"peak_file_cache": 146.8
},
"messenger-lab4-api-2": {
"baseline_anon": 64.0,
"peak_anon": 110.0,
"delta_anon": 45.9,
"baseline_current": 69.4,
"peak_current": 269.5,
"peak_file_cache": 146.8
},
"messenger-lab4-s3-1": {
"baseline_anon": 330.5,
"peak_anon": 403.0,
"delta_anon": 72.5,
"baseline_current": 759.4,
"peak_current": 768.0,
"peak_file_cache": 403.0
}
},
"api_env": {
"UPLOAD_SPOOL_BYTES": "1048576",
"UPLOAD_CONCURRENCY": "16",
"DECODE_CONCURRENCY": "1"
}
}
+31
View File
@@ -0,0 +1,31 @@
# 2026-10-28T12:49:29Z
## before
/messenger-lab4-api-1 started=2026-10-28T12:49:07.33200605Z status=running
/messenger-lab4-api-2 started=2026-10-28T12:49:07.446368967Z status=running
/messenger-lab4-lb-1 started=2026-10-28T12:49:07.548902801Z status=running
/messenger-lab4-migrate-1 started=2026-10-28T12:48:43.194072928Z status=exited
/messenger-lab4-postgres-1 started=2026-10-28T12:48:40.625567385Z status=running
/messenger-lab4-s3-1 started=2026-10-28T12:48:40.624710052Z status=running
/messenger-lab4-s3-init-1 started=2026-10-28T12:48:54.221527128Z status=exited
/messenger-lab4-sweeper-1 started=2026-10-28T12:49:07.330576425Z status=running
/messenger-lab4-valkey-1 started=2026-10-28T12:48:40.623424302Z status=running
messenger-lab4_pgdata
messenger-lab4_s3data
$ make test-persistence ACTION_SCRIPT=scripts/restart.sh
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
/messenger-lab4-api-1 started=2026-10-28T12:50:19.211923042Z status=running
/messenger-lab4-api-2 started=2026-10-28T12:50:19.32544125Z status=running
/messenger-lab4-lb-1 started=2026-10-28T12:50:19.431133834Z status=running
/messenger-lab4-migrate-1 started=2026-10-28T12:49:55.030515461Z status=exited
/messenger-lab4-postgres-1 started=2026-10-28T12:49:52.442082085Z status=running
/messenger-lab4-s3-1 started=2026-10-28T12:49:52.439265918Z status=running
/messenger-lab4-s3-init-1 started=2026-10-28T12:50:06.033067342Z status=exited
/messenger-lab4-sweeper-1 started=2026-10-28T12:50:19.21224375Z status=running
/messenger-lab4-valkey-1 started=2026-10-28T12:49:52.44208621Z status=running
messenger-lab4_pgdata
messenger-lab4_s3data
## s3-init on restart
WARNING s3-bootstrap: write probe failed (attempt 1/30): ReadTimeoutError
INFO s3-bootstrap: write path warm: put/get/delete probe 0.008s
+23
View File
@@ -0,0 +1,23 @@
# 2026-10-28, найдено экспериментом upload_memory.py (до исправления; тексты выводов сокращены вручную)
# Конфигурация ДО: s3 memory limit 512M, без -*.concurrentUploadLimitMB, без GOMEMLIMIT,
# в API нет ограничения параллельных S3 PUT (UPLOAD_CONCURRENCY=16 на реплику).
$ python3 student-tests/upload_memory.py --concurrency 20 # 20 x 9.6 MiB noise PNG
"statuses": {"201": 4, "503": 16}
API logs:
8 WARNING:messenger.s3:s3 put failed: EndpointConnectionError
8 WARNING:messenger.s3:compensating delete failed; sweeper will retry later
S3 memory.current (cgroup), выборка каждые 0.25 с во время прогона:
511MiB ... 511MiB (упор в лимит 512M), затем процесс weed исчезает без panic,
контейнер перезапускается (RestartCount растёт), в логе при старте:
W volume_checking.go:399 volume 6: repaired the unindexed tail of /data/messenger-attachments_6.dat: re-indexed 1 needle(s)
Вывод: OOM kill SeaweedFS под 20 параллельными 10 MiB PUT. Данных не потеряно: API ответил 503,
pending-строки удалены компенсацией, а оставшиеся объекты/строки подбирает sweeper.
# ПОСЛЕ исправления (S3_PUT_CONCURRENCY=4 в каждой реплике, -s3/-filer/-volume.concurrentUploadLimitMB=128,
# GOMEMLIMIT=450MiB, limit 768M) — см. evidence/memory/stream-{20,40}-noise.json:
20 параллельно: 201 x 20, S3 anon peak 421.9 MiB
40 параллельно: 201 x 40, S3 anon peak 403.0 MiB, RestartCount s3 = 0
+18
View File
@@ -0,0 +1,18 @@
# 2026-10-28T12:44:21Z
$ make test-s3-security
object key: originals/<random 128-bit hex>, unrelated to attachment id and filename
anonymous_get_object 403
anonymous_list_bucket 403
anonymous_list_all 403
api_create_bucket AccessDenied
api_put_bucket_policy_public AccessDenied
api_put_object_acl_public AccessDenied
api_delete_bucket AccessDenied
api_get_own_bucket_object ALLOWED
s3:9333 master UI ConnectionRefusedError
s3:8888 filer UI ConnectionRefusedError
s3:8080 volume ConnectionRefusedError
s3:9000 S3 API OPEN
s3 published host ports: none ({})
lb -> s3:9000 (edge network): unreachable (exit status 1)
PASS: private bucket, least-privilege API credentials, no exposed admin interfaces
+3
View File
@@ -0,0 +1,3 @@
# 2026-10-28T12:44:14Z
$ make test
PASS: lab4 public API scenario; infrastructure and grading evidence remain separate.
+4
View File
@@ -0,0 +1,4 @@
2026-10-28T12:53:49Z stopped messenger-lab4-api-1 (1765636c87f6) instance=api-a882f11d state=exited
2026-10-28T12:53:59Z stopped messenger-lab4-api-2 (2977947aaf31) instance=api-04d7b1b1 state=exited
2026-10-28T12:54:50Z stopped messenger-lab4-api-1 instance=api-a442bb8f state=exited
2026-10-28T12:55:28Z stopped messenger-lab4-api-2 instance=api-e3ad2cfc state=exited
+45
View File
@@ -0,0 +1,45 @@
# 2026-10-28T12:43:46Z clean volumes
$ docker compose --env-file .env config --quiet && docker compose --env-file .env up -d --build --wait
Container messenger-lab4-postgres-1 Healthy
Container messenger-lab4-s3-1 Healthy
Container messenger-lab4-migrate-1 Exited
Container messenger-lab4-valkey-1 Healthy
Container messenger-lab4-migrate-1 Exited
Container messenger-lab4-postgres-1 Healthy
Container messenger-lab4-s3-init-1 Exited
Container messenger-lab4-s3-init-1 Exited
Container messenger-lab4-migrate-1 Exited
Container messenger-lab4-s3-init-1 Exited
Container messenger-lab4-s3-1 Healthy
Container messenger-lab4-valkey-1 Healthy
Container messenger-lab4-postgres-1 Healthy
Container messenger-lab4-sweeper-1 Healthy
Container messenger-lab4-api-2 Healthy
Container messenger-lab4-api-1 Healthy
Container messenger-lab4-lb-1 Healthy
$ docker compose ps
NAME IMAGE STATUS PORTS
messenger-lab4-api-1 mtusi-messenger:lab4 Up 5 seconds (healthy) 8080/tcp
messenger-lab4-api-2 mtusi-messenger:lab4 Up 5 seconds (healthy) 8080/tcp
messenger-lab4-lb-1 haproxy:3.2.4-alpine Up 5 seconds (healthy) 127.0.0.1:8088->8080/tcp
messenger-lab4-migrate-1 mtusi-messenger:lab4 Exited (0) 12 seconds ago
messenger-lab4-postgres-1 postgres:17.6-alpine3.22 Up 15 seconds (healthy)
messenger-lab4-s3-1 chrislusf/seaweedfs:4.51 Up 15 seconds (healthy)
messenger-lab4-s3-init-1 mtusi-messenger:lab4 Exited (0) 6 seconds ago
messenger-lab4-sweeper-1 mtusi-messenger:lab4 Up 5 seconds (healthy)
messenger-lab4-valkey-1 valkey/valkey:8.1.4-alpine3.22 Up 15 seconds (healthy)
$ docker compose logs migrate s3-init
INFO migrate: applying 0001_init
INFO migrate: applying 0002_idempotency
INFO migrate: applying 0003_attachments
INFO migrate: migrations up to date: 3 applied now, 0 before
INFO s3-bootstrap: bucket messenger-attachments created
INFO s3-bootstrap: anonymous list/get denied: bucket is private
$ limits
/messenger-lab4-api-1 cpus=500000000 mem=402653184 networks=messenger-lab4_data messenger-lab4_edge
/messenger-lab4-api-2 cpus=500000000 mem=402653184 networks=messenger-lab4_data messenger-lab4_edge
/messenger-lab4-lb-1 cpus=500000000 mem=134217728 networks=messenger-lab4_edge
/messenger-lab4-postgres-1 cpus=1000000000 mem=536870912 networks=messenger-lab4_data
/messenger-lab4-s3-1 cpus=1000000000 mem=805306368 networks=messenger-lab4_data
/messenger-lab4-sweeper-1 cpus=250000000 mem=134217728 networks=messenger-lab4_data
/messenger-lab4-valkey-1 cpus=250000000 mem=100663296 networks=messenger-lab4_data
+7
View File
@@ -0,0 +1,7 @@
# 2026-10-28T12:53:44Z
$ make test-upload-failover
round 1: uploaded via api-a882f11d (messenger-lab4-api-1); 2026-10-28T12:53:49Z stopped messenger-lab4-api-1 (1765636c87f6) instance=api-a882f11d state=exited
round 1: 10/10 downloads byte-identical via ['api-04d7b1b1']
round 2: uploaded via api-04d7b1b1 (messenger-lab4-api-2); 2026-10-28T12:53:59Z stopped messenger-lab4-api-2 (2977947aaf31) instance=api-04d7b1b1 state=exited
round 2: 10/10 downloads byte-identical via ['api-a442bb8f']
PASS: attachment downloaded through another replica after its uploader stopped (2 rounds)