Implement lab4 private S3 attachments and reconciliation track

This commit is contained in:
ferraronp
2026-11-12 18:15:42 +03:00
parent ec540a1a72
commit 87ce432b81
56 changed files with 2465 additions and 41 deletions
+11
View File
@@ -0,0 +1,11 @@
{
"concurrency": 10,
"uploads": 10,
"failed_requests": 0,
"elapsed_seconds": 2.796,
"upload_rps": 3.577,
"latency_p50_ms": 2164.0,
"latency_max_ms": 2344.0,
"bytes_per_file": 111817,
"note": "Capture peak API RSS with docker stats; this script is client-side only."
}
@@ -0,0 +1,11 @@
{
"concurrency": 10,
"uploads": 10,
"failed_requests": 0,
"elapsed_seconds": 2.985,
"upload_rps": 3.35,
"latency_p50_ms": 2312.5,
"latency_max_ms": 2453.0,
"bytes_per_file": 111817,
"note": "Capture peak API RSS with docker stats; this script is client-side only."
}
@@ -0,0 +1,11 @@
{
"concurrency": 10,
"uploads": 10,
"failed_requests": 0,
"elapsed_seconds": 3.031,
"upload_rps": 3.299,
"latency_p50_ms": 2296.0,
"latency_max_ms": 2546.0,
"bytes_per_file": 111817,
"note": "Capture peak API RSS with docker stats; this script is client-side only."
}
@@ -0,0 +1,11 @@
{
"concurrency": 10,
"uploads": 10,
"failed_requests": 0,
"elapsed_seconds": 3.203,
"upload_rps": 3.122,
"latency_p50_ms": 2461.0,
"latency_max_ms": 2750.0,
"bytes_per_file": 111817,
"note": "Capture peak API RSS with docker stats; this script is client-side only."
}
@@ -0,0 +1,11 @@
{
"concurrency": 10,
"uploads": 10,
"failed_requests": 0,
"elapsed_seconds": 3.5,
"upload_rps": 2.857,
"latency_p50_ms": 2523.5,
"latency_max_ms": 2907.0,
"bytes_per_file": 111817,
"note": "Capture peak API RSS with docker stats; this script is client-side only."
}
@@ -0,0 +1,11 @@
{
"concurrency": 10,
"uploads": 10,
"failed_requests": 0,
"elapsed_seconds": 2.64,
"upload_rps": 3.788,
"latency_p50_ms": 2242.0,
"latency_max_ms": 2297.0,
"bytes_per_file": 111817,
"note": "Capture peak API RSS with docker stats; this script is client-side only."
}
@@ -0,0 +1,11 @@
{
"concurrency": 10,
"uploads": 10,
"failed_requests": 0,
"elapsed_seconds": 2.969,
"upload_rps": 3.368,
"latency_p50_ms": 2281.0,
"latency_max_ms": 2453.0,
"bytes_per_file": 111817,
"note": "Capture peak API RSS with docker stats; this script is client-side only."
}
@@ -0,0 +1,11 @@
{
"concurrency": 10,
"uploads": 10,
"failed_requests": 0,
"elapsed_seconds": 2.64,
"upload_rps": 3.788,
"latency_p50_ms": 2187.5,
"latency_max_ms": 2281.0,
"bytes_per_file": 111817,
"note": "Capture peak API RSS with docker stats; this script is client-side only."
}
@@ -0,0 +1,11 @@
{
"concurrency": 10,
"uploads": 10,
"failed_requests": 0,
"elapsed_seconds": 2.843,
"upload_rps": 3.517,
"latency_p50_ms": 2336.0,
"latency_max_ms": 2406.0,
"bytes_per_file": 111817,
"note": "Capture peak API RSS with docker stats; this script is client-side only."
}
@@ -0,0 +1,11 @@
{
"concurrency": 10,
"uploads": 10,
"failed_requests": 0,
"elapsed_seconds": 3.031,
"upload_rps": 3.299,
"latency_p50_ms": 2398.5,
"latency_max_ms": 2578.0,
"bytes_per_file": 111817,
"note": "Capture peak API RSS with docker stats; this script is client-side only."
}
@@ -0,0 +1,11 @@
{
"concurrency": 10,
"uploads": 10,
"failed_requests": 0,
"elapsed_seconds": 3.281,
"upload_rps": 3.048,
"latency_p50_ms": 2390.5,
"latency_max_ms": 2735.0,
"bytes_per_file": 111817,
"note": "Capture peak API RSS with docker stats; this script is client-side only."
}
@@ -0,0 +1,16 @@
"stage";"repeat";"s3_keys_scanned";"db_rows_scanned";"scan_elapsed_seconds"
"0";"1";"36";"18";"0,624"
"0";"2";"36";"18";"0,294"
"0";"3";"36";"18";"0,207"
"0";"4";"36";"18";"0,234"
"0";"5";"36";"18";"0,245"
"1";"1";"136";"68";"0,27"
"1";"2";"136";"68";"0,284"
"1";"3";"136";"68";"0,285"
"1";"4";"136";"68";"0,294"
"1";"5";"136";"68";"0,401"
"2";"1";"236";"118";"0,568"
"2";"2";"236";"118";"0,341"
"2";"3";"236";"118";"0,289"
"2";"4";"236";"118";"0,409"
"2";"5";"236";"118";"0,3"
1 stage repeat s3_keys_scanned db_rows_scanned scan_elapsed_seconds
2 0 1 36 18 0,624
3 0 2 36 18 0,294
4 0 3 36 18 0,207
5 0 4 36 18 0,234
6 0 5 36 18 0,245
7 1 1 136 68 0,27
8 1 2 136 68 0,284
9 1 3 136 68 0,285
10 1 4 136 68 0,294
11 1 5 136 68 0,401
12 2 1 236 118 0,568
13 2 2 236 118 0,341
14 2 3 236 118 0,289
15 2 4 236 118 0,409
16 2 5 236 118 0,3
@@ -0,0 +1,11 @@
# Reconcile cost — verified series, 12.11.2026
The 15 values below were transcribed from the pasted PowerShell stdout. The original CSV was saved on the user's Windows computer at `evidence/reconcile-cost-20261112-180238.csv` and is **not contained in this package**.
| Stage | S3 keys | DB rows | Runs | Mean (s) | Median (s) |
|---:|---:|---:|---:|---:|---:|
| 0 | 36 | 18 | 5 | 0.3208 | 0.245 |
| 1 | 136 | 68 | 5 | 0.3068 | 0.285 |
| 2 | 236 | 118 | 5 | 0.3814 | 0.341 |
No `--apply` or DELETE was executed during the cost sweep. Each measured value is internal `scan_elapsed_seconds`.
+110
View File
@@ -0,0 +1,110 @@
# Lab4 — фактические свидетельства локального запуска
**Источник:** обезличенные выдержки из переданных stdout PowerShell/Docker, 12 ноября 2026.
**Статус:** результаты переписаны вручную из консольных логов, не являются сырым автоматическим CI-протоколом. Не содержат токенов и паролей.
## Функциональность и инфраструктура
```text
PASS: offline skeleton structure, local refs and Python syntax; application NOT tested.
PASS: lab4 public API scenario; infrastructure and grading evidence remain separate.
PASS: lab4 negative image, MIME, size, filename, ACL and cross-chat checks
PASS: parallel idempotency across 2 replicas; one message, replay 201, conflicting body 409
{"private_bucket": true, "anonymous_listing": "denied", "anonymous_object_get": "denied"}
PASS: dry-run, orphan grace, recover primary from backup, apply idempotence
PASS: persistence preserved confirmed data and existing session. Hook scope needs operator evidence.
{"observed_instances_before": 2, "successful_writes": 6, "failed_attempts": 1, "first_recovery_seconds": 6.156}
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
```
## 10 конкурентных загрузок
```json
{
"concurrency": 10,
"uploads": 10,
"failed_requests": 0,
"elapsed_seconds": 2.796,
"upload_rps": 3.577,
"latency_p50_ms": 2164.0,
"latency_max_ms": 2344.0,
"bytes_per_file": 111817
}
```
Наблюдения Docker stats (выборочно, не непрерывный max):
- `api1`: максимум **109.1 MiB / 384 MiB**
- `api2`: максимум **96.21 MiB / 384 MiB**
## Удаление оригинала и восстановление
```text
fault: delete-primary
object_key: attachments/045ee0a6-be0d-4712-884f-b82145888ad6/original
dry-run: s3_keys_scanned=31, db_rows_scanned=16,
missing_primary_repairable=[045ee0a6-be0d-4712-884f-b82145888ad6],
actions=[], errors=[], scan_elapsed_seconds=0.162
apply: action=restore,
key=attachments/045ee0a6-be0d-4712-884f-b82145888ad6/original,
from=recovery/045ee0a6-be0d-4712-884f-b82145888ad6/original,
errors=[], scan_elapsed_seconds=0.216
verify dry-run: s3_keys_scanned=32, db_rows_scanned=16,
missing_primary_repairable=[], actions=[], errors=[], scan_elapsed_seconds=0.159
repeat apply (following extra uploads): s3_keys_scanned=34, db_rows_scanned=17,
actions=[], errors=[], scan_elapsed_seconds=0.179
```
## Создание и зачистка orphan
```text
fault: orphan-created
key: attachments/db466391-0d91-4757-990f-f2bb93872f5d/original
dry-run: s3_keys_scanned=35, db_rows_scanned=17,
orphan_keys_young=[attachments/db466391-0d91-4757-990f-f2bb93872f5d/original],
orphan_keys=[], actions=[], errors=[], scan_elapsed_seconds=0.190
apply before grace: orphan_keys_young=[...], actions=[], errors=[], scan_elapsed_seconds=0.225
Start-Sleep -Seconds 310
apply after grace: orphan_keys=[attachments/db466391-0d91-4757-990f-f2bb93872f5d/original],
actions=[{"action":"delete-old-orphan","key":"attachments/db466391-0d91-4757-990f-f2bb93872f5d/original"}],
errors=[], scan_elapsed_seconds=0.228
final dry-run: s3_keys_scanned=34, db_rows_scanned=17,
orphan_keys=[], orphan_keys_young=[],
missing_primary_repairable=[], missing_backup_repairable=[],
missing_both_unrecoverable=[], actions=[], errors=[],
scan_elapsed_seconds=0.213
```
## S3 downtime
```text
docker compose --env-file .env stop s3
# HTTP/1.1 503 Service Unavailable via localhost:8080/health/ready
docker compose --env-file .env up -d s3
docker compose --env-file .env up -d --wait api1 api2 lb
python tests/smoke.py
PASS: lab4 public API scenario; infrastructure and grading evidence remain separate.
```
## Сравнительная стоимость reconciler: 3 размера, 15 dry-run
Методика: `scripts/measure_reconcile.ps1` (5 повторов на этап, 5 пакетов × 10 upload перед следующим этапом). 10 пакетов по 10 PNG-файлов прошли с `failed_requests: 0`; данные добавлялись только через публичное API. Измерен `scan_elapsed_seconds` самого reconciler, без времени запуска Compose. Исходный файл с машины тестирования: `evidence/reconcile-cost-20261112-180238.csv`.
| Этап | S3 keys | DB rows | Значения, с | Mean, с | Median, с |
|---|---:|---:|---|---:|---:|
| 0 | 36 | 18 | 0,624; 0,294; 0,207; 0,234; 0,245 | 0,3208 | 0,245 |
| 1 | 136 | 68 | 0,270; 0,284; 0,285; 0,294; 0,401 | 0,3068 | 0,285 |
| 2 | 236 | 118 | 0,568; 0,341; 0,289; 0,409; 0,300 | 0,3814 | 0,341 |
Итог: +100 записей БД и +200 ключей S3, 15 проходов. Медианы возрастают при увеличении числа объектов, но на этих малых локальных выборках нельзя утверждать асимптотику или throughput production. Числа переписаны из пользовательского stdout; оригинальный CSV хранится у пользователя.
**Не проверено:** интеграционная имитация одновременной потери обеих S3-копий, реальный отказ PG COMMIT во время upload. Отдельные успешные `smoke.py` не подтверждают автоматически все критерии на 5.