lab4: S3, MinIO, reconciler, трек 2, README

This commit is contained in:
2026-11-12 20:14:39 +03:00
parent ec540a1a72
commit d88f77cccc
104 changed files with 204719 additions and 47 deletions
+200294
View File
File diff suppressed because it is too large Load Diff
+13
View File
@@ -0,0 +1,13 @@
QUERY PLAN
-----------------------------------------------------------------------------------------------------------------------------------------------------
Limit (cost=0.42..5.54 rows=50 width=66) (actual time=0.103..0.111 rows=50 loops=1)
Buffers: shared hit=4
-> Index Scan using ix_messages_chat_created_id on messages (cost=0.42..8222.03 rows=80203 width=66) (actual time=0.102..0.107 rows=50 loops=1)
Index Cond: (chat_id = '66666666-6666-4666-8666-666666666666'::uuid)
Buffers: shared hit=4
Planning:
Buffers: shared hit=107
Planning Time: 0.865 ms
Execution Time: 0.168 ms
(9 rows)
+22
View File
@@ -0,0 +1,22 @@
QUERY PLAN
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
Limit (cost=6279.67..6285.42 rows=50 width=66) (actual time=7.323..8.152 rows=50 loops=1)
Buffers: shared hit=1063 read=72
-> Gather Merge (cost=6279.67..11696.05 rows=47099 width=66) (actual time=7.322..8.148 rows=50 loops=1)
Workers Planned: 1
Workers Launched: 1
Buffers: shared hit=1063 read=72
-> Sort (cost=5279.66..5397.40 rows=47099 width=66) (actual time=6.368..6.368 rows=26 loops=2)
Sort Key: created_at, id
Sort Method: top-N heapsort Memory: 38kB
Buffers: shared hit=1063 read=72
Worker 0: Sort Method: top-N heapsort Memory: 38kB
-> Parallel Index Scan using ix_messages_chat_only on messages (cost=0.42..3715.06 rows=47099 width=66) (actual time=0.031..2.837 rows=40000 loops=2)
--More-- ␍ ␍ Index Cond: (chat_id = '66666666-6666-4666-8666-66666666666--More-- ␍ ␍6'::uuid)
--More-- ␍ ␍ Buffers: shared hit=1048 read=72
--More-- ␍ ␍ Planning:
--More-- ␍ ␍ Buffers: shared hit=98 read=1
--More-- ␍ ␍ Planning Time: 0.335 ms
--More-- ␍ ␍ Execution Time: 8.200 ms
--More-- ␍ ␍(18 rows)
--More-- ␍ ␍
+29
View File
@@ -0,0 +1,29 @@
./scripts/failover-test.sh app1
Останавливаю app1
16:50:48.3N
Останавливаю app1...
app1 остановлен
Шлю запросы каждые 0.5 сек, смотрю код и x-instance-id
16:50:48.3N code=200 x-instance-id: 4749a273-c09f-47b2-9172-f373b786233b
16:50:51.3N code=200 x-instance-id: 4749a273-c09f-47b2-9172-f373b786233b
16:50:51.3N code=200 x-instance-id: 4749a273-c09f-47b2-9172-f373b786233b
16:50:52.3N code=200 x-instance-id: 4749a273-c09f-47b2-9172-f373b786233b
16:50:52.3N code=200 x-instance-id: 4749a273-c09f-47b2-9172-f373b786233b
16:50:53.3N code=200 x-instance-id: 4749a273-c09f-47b2-9172-f373b786233b
16:50:53.3N code=200 x-instance-id: 4749a273-c09f-47b2-9172-f373b786233b
16:50:54.3N code=200 x-instance-id: 4749a273-c09f-47b2-9172-f373b786233b
16:50:55.3N code=200 x-instance-id: 4749a273-c09f-47b2-9172-f373b786233b
16:50:55.3N code=200 x-instance-id: 4749a273-c09f-47b2-9172-f373b786233b
16:50:56.3N code=200 x-instance-id: 4749a273-c09f-47b2-9172-f373b786233b
16:50:58.3N code=200 x-instance-id: 4749a273-c09f-47b2-9172-f373b786233b
16:50:59.3N code=200 x-instance-id: 4749a273-c09f-47b2-9172-f373b786233b
16:50:59.3N code=200 x-instance-id: 4749a273-c09f-47b2-9172-f373b786233b
16:51:00.3N code=200 x-instance-id: 4749a273-c09f-47b2-9172-f373b786233b
16:51:00.3N code=200 x-instance-id: 4749a273-c09f-47b2-9172-f373b786233b
16:51:01.3N code=200 x-instance-id: 4749a273-c09f-47b2-9172-f373b786233b
16:51:02.3N code=200 x-instance-id: 4749a273-c09f-47b2-9172-f373b786233b
16:51:02.3N code=200 x-instance-id: 4749a273-c09f-47b2-9172-f373b786233b
16:51:03.3N code=200 x-instance-id: 4749a273-c09f-47b2-9172-f373b786233b
Поднимаю app1 обратно
+29
View File
@@ -0,0 +1,29 @@
./scripts/failover-test.sh app2
Останавливаю app2
16:51:08.3N
Останавливаю app2...
app2 остановлен
Шлю запросы каждые 0.5 сек, смотрю код и x-instance-id
16:51:09.3N code=200 x-instance-id: 534c1846-b123-481b-a9c4-71c7049315ae
16:51:11.3N code=200 x-instance-id: 534c1846-b123-481b-a9c4-71c7049315ae
16:51:14.3N code=200 x-instance-id: 534c1846-b123-481b-a9c4-71c7049315ae
16:51:14.3N code=200 x-instance-id: 534c1846-b123-481b-a9c4-71c7049315ae
16:51:15.3N code=200 x-instance-id: 534c1846-b123-481b-a9c4-71c7049315ae
16:51:15.3N code=200 x-instance-id: 534c1846-b123-481b-a9c4-71c7049315ae
16:51:16.3N code=200 x-instance-id: 534c1846-b123-481b-a9c4-71c7049315ae
16:51:17.3N code=200 x-instance-id: 534c1846-b123-481b-a9c4-71c7049315ae
16:51:17.3N code=200 x-instance-id: 534c1846-b123-481b-a9c4-71c7049315ae
16:51:18.3N code=200 x-instance-id: 534c1846-b123-481b-a9c4-71c7049315ae
16:51:18.3N code=200 x-instance-id: 534c1846-b123-481b-a9c4-71c7049315ae
16:51:19.3N code=200 x-instance-id: 534c1846-b123-481b-a9c4-71c7049315ae
16:51:21.3N code=200 x-instance-id: 534c1846-b123-481b-a9c4-71c7049315ae
16:51:22.3N code=200 x-instance-id: 534c1846-b123-481b-a9c4-71c7049315ae
16:51:22.3N code=200 x-instance-id: 534c1846-b123-481b-a9c4-71c7049315ae
16:51:23.3N code=200 x-instance-id: 534c1846-b123-481b-a9c4-71c7049315ae
16:51:24.3N code=200 x-instance-id: 534c1846-b123-481b-a9c4-71c7049315ae
16:51:24.3N code=200 x-instance-id: 534c1846-b123-481b-a9c4-71c7049315ae
16:51:25.3N code=200 x-instance-id: 534c1846-b123-481b-a9c4-71c7049315ae
16:51:25.3N code=200 x-instance-id: 534c1846-b123-481b-a9c4-71c7049315ae
Поднимаю app2 обратно
+10
View File
@@ -0,0 +1,10 @@
HTTP/1.1 400 Bad Request
Server: nginx/1.29.4
Date: Wed, 11 Nov 2026 17:04:13 GMT
Content-Type: application/json
Content-Length: 145
Connection: keep-alive
x-request-id: 69432ca6-ed29-4dbd-a76c-18a468b47182
x-instance-id: 9080c907-3eed-49de-b870-092b89ee4eb4
{"error":{"code":"invalid_request","message":"Ошибка валидации данных","request_id":"69432ca6-ed29-4dbd-a76c-18a468b47182"}}
+18
View File
@@ -0,0 +1,18 @@
python3 tests/load.py --base-url "http://localhost:8080"
{
"lab": 3,
"workload": "closed-loop POST messages; no automatic retries",
"requested_duration_seconds": 30,
"elapsed_seconds": 30.609,
"concurrency": 4,
"successful_requests": 8195,
"failed_requests": 8,
"error_ratio": 0.000975,
"successful_rps": 267.73,
"successful_latency_ms": {
"p50": 9.403,
"p95": 12.088,
"p99": 17.671
},
"note": "Latency percentiles cover successes only. Timeouts/errors are counted separately; closed-loop has coordinated omission and client overhead."
}
@@ -0,0 +1,17 @@
{
"lab": 3,
"workload": "closed-loop POST messages; no automatic retries",
"requested_duration_seconds": 30,
"elapsed_seconds": 32.212,
"concurrency": 20,
"successful_requests": 7940,
"failed_requests": 60,
"error_ratio": 0.0075,
"successful_rps": 246.491,
"successful_latency_ms": {
"p50": 32.546,
"p95": 76.906,
"p99": 114.623
},
"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 @@
=== Замер для 2 реплик ===
Лимиты: cpus=0.5, memory=512M на реплику (суммарно 1 CPU / 1 GB)
Конфигурация: app1 + app2 за Nginx
Нагрузка: make load (POST /messages, 30 сек, concurrency 4)
{
"lab": 3,
"workload": "closed-loop POST messages; no automatic retries",
"requested_duration_seconds": 30,
"elapsed_seconds": 31.155,
"concurrency": 4,
"successful_requests": 8156,
"failed_requests": 3,
"error_ratio": 0.000368,
"successful_rps": 261.789,
"successful_latency_ms": {
"p50": 8.613,
"p95": 36.591,
"p99": 48.722
},
"note": "Latency percentiles cover successes only. Timeouts/errors are counted separately; closed-loop has coordinated omission and client overhead."
}
@@ -0,0 +1,17 @@
{
"lab": 3,
"workload": "closed-loop POST messages; no automatic retries",
"requested_duration_seconds": 30,
"elapsed_seconds": 33.193,
"concurrency": 20,
"successful_requests": 8386,
"failed_requests": 60,
"error_ratio": 0.007104,
"successful_rps": 252.642,
"successful_latency_ms": {
"p50": 18.858,
"p95": 78.217,
"p99": 156.447
},
"note": "Latency percentiles cover successes only. Timeouts/errors are counted separately; closed-loop has coordinated omission and client overhead."
}
+17
View File
@@ -0,0 +1,17 @@
{
"lab": 3,
"workload": "closed-loop POST messages; no automatic retries",
"requested_duration_seconds": 30,
"elapsed_seconds": 31.089,
"concurrency": 4,
"successful_requests": 8190,
"failed_requests": 12,
"error_ratio": 0.001463,
"successful_rps": 263.441,
"successful_latency_ms": {
"p50": 7.843,
"p95": 11.567,
"p99": 16.163
},
"note": "Latency percentiles cover successes only. Timeouts/errors are counted separately; closed-loop has coordinated omission and client overhead."
}
+17
View File
@@ -0,0 +1,17 @@
{
"lab": 3,
"workload": "closed-loop POST messages; no automatic retries",
"requested_duration_seconds": 30,
"elapsed_seconds": 32.952,
"concurrency": 20,
"successful_requests": 8299,
"failed_requests": 20,
"error_ratio": 0.002404,
"successful_rps": 251.855,
"successful_latency_ms": {
"p50": 9.001,
"p95": 274.971,
"p99": 389.683
},
"note": "Latency percentiles cover successes only. Timeouts/errors are counted separately; closed-loop has coordinated omission and client overhead."
}
+18
View File
@@ -0,0 +1,18 @@
python3 tests/load.py --base-url "http://localhost:8080"
{
"lab": 3,
"workload": "closed-loop POST messages; no automatic retries",
"requested_duration_seconds": 30,
"elapsed_seconds": 30.999,
"concurrency": 4,
"successful_requests": 8165,
"failed_requests": 12,
"error_ratio": 0.001468,
"successful_rps": 263.396,
"successful_latency_ms": {
"p50": 7.054,
"p95": 11.933,
"p99": 23.37
},
"note": "Latency percentiles cover successes only. Timeouts/errors are counted separately; closed-loop has coordinated omission and client overhead."
}
+18
View File
@@ -0,0 +1,18 @@
python3 tests/load.py --base-url "http://localhost:8080"
{
"lab": 3,
"workload": "closed-loop POST messages; no automatic retries",
"requested_duration_seconds": 30,
"elapsed_seconds": 32.012,
"concurrency": 4,
"successful_requests": 8160,
"failed_requests": 2,
"error_ratio": 0.000245,
"successful_rps": 254.903,
"successful_latency_ms": {
"p50": 6.556,
"p95": 53.415,
"p99": 69.04
},
"note": "Latency percentiles cover successes only. Timeouts/errors are counted separately; closed-loop has coordinated omission and client overhead."
}
+25
View File
@@ -0,0 +1,25 @@
=== Проверка private bucket ===
Object key: de86cd68-f019-4b7b-83f7-47d9d2fcd03a.png
=== Прямой GET без авторизации (ожидаем 403) ===
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
␍ 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0␍100 413 100 413 0 0 132k 0 --:--:-- --:--:-- --:--:-- 134k
HTTP/1.1 403 Forbidden
Accept-Ranges: bytes
Content-Length: 413
Content-Type: application/xml
Server: Silo
Strict-Transport-Security: max-age=31536000; includeSubDomains
Vary: Origin
Vary: Accept-Encoding
X-Amz-Id-2: dd9025bab4ad464b049177c95eb6ebf374d3b3fd1af9251148b658df7ac2e3e8
X-Amz-Request-Id: 18E75A22BC9CBD47
X-Content-Type-Options: nosniff
X-Ratelimit-Limit: 2160
X-Ratelimit-Remaining: 2160
X-Xss-Protection: 1; mode=block
Date: Thu, 12 Nov 2026 16:48:01 GMT
<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>AccessDenied</Code><Message>Access Denied.</Message><Key>de86cd68-f019-4b7b-83f7-47d9d2fcd03a.png</Key><BucketName>messenger-attachments</BucketName><Resource>/messenger-attachments/de86cd68-f019-4b7b-83f7-47d9d2fcd03a.png</Resource><RequestId>18E75A22BC9CBD47</RequestId><HostId>dd9025bab4ad464b049177c95eb6ebf374d3b3fd1af9251148b658df7ac2e3e8</HostId></Error>
+28
View File
@@ -0,0 +1,28 @@
NAME MEM USAGE / LIMIT CPU %
mtusi2026lab4-app2-1 94.89MiB / 512MiB 0.21%
mtusi2026lab4-app1-1 95.96MiB / 512MiB 0.18%
mtusi_messenger_nginx 2.594MiB / 8.722GiB 0.00%
mtusi_messenger_db 46.91MiB / 8.722GiB 0.75%
mtusi2026lab4-minio-1 271.8MiB / 8.722GiB 1.31%
mtusi_messenger_redis 9.613MiB / 8.722GiB 0.87%
RAM Experiment: 10 concurrent uploads, ~5 MB each
Chat ID: 55d6b9f8-5fb5-4771-b4a6-47dee2886c12
Генерируем 10 картинок (шум, ~5 МБ)...
Размеры: min=5.62, max=7.15, avg=6.37 МБ
Суммарно: 63.72 МБ
Запускаем 10 одновременных загрузок...
=== Результаты ===
Всего: 10
Успешных (201): 10
Ошибок: 0
Latency: min=0.65s, max=0.88s, avg=0.81s
Общее время: 0.89s
NAME MEM USAGE / LIMIT CPU %
mtusi2026lab4-app2-1 94.9MiB / 512MiB 4.69%
mtusi2026lab4-app1-1 161.7MiB / 512MiB 8.94%
mtusi_messenger_nginx 2.594MiB / 8.722GiB 0.00%
mtusi_messenger_db 54.61MiB / 8.722GiB 0.03%
mtusi2026lab4-minio-1 280.1MiB / 8.722GiB 0.06%
mtusi_messenger_redis 9.617MiB / 8.722GiB 0.75%
+122
View File
@@ -0,0 +1,122 @@
================================================================
RECONCILER TEST — Thu Nov 12 19:44:47 MSK 2026
================================================================
=== 1. Создание пользователя (reconcile_tester_1794501887) ===
HTTP 201
Body: {"id":"eeb6a83d-a4ad-4fba-a2c3-38eefe0e0e1d","username":"reconcile_tester_1794501887","display_name":"Reconciler Test","created_at":"2026-11-12T16:44:47.844572Z"}
=== 2. Логин ===
HTTP 201
Токен получен: xluXtVfFzEGG7Mvi0C9g...
User ID: eeb6a83d-a4ad-4fba-a2c3-38eefe0e0e1d
=== 3. Создание чата ===
Chat ID: 52d0da4c-7af8-4548-8dcf-b3be6badcae6
=== 4. Создаём ORPHAN ===
Orphan attachment_id: 0bbfa860-f5f5-42a5-9611-29f55f5baafd
Orphan object_key: aec0da17-d643-41ce-a3f0-d8a83e96ad97.png
Запись удалена из БД — ORPHAN
=== 5. Создаём MISSING ===
Missing attachment_id: 414ecbba-4119-414f-8796-8c41128f8e70
Missing object_key: 43dbaa2d-2f62-44cd-9d27-2aec1bb36164.png
Removed `myminio/messenger-attachments/43dbaa2d-2f62-44cd-9d27-2aec1bb36164.png`.
Файл удалён из MinIO — MISSING
=== Пауза 11 секунд (orphan станет старше grace_period 10 сек) ===
=== 6. DRY-RUN (ожидаем ORPHAN + MISSING) ===
/app/scripts/reconcile.py:81: DeprecationWarning: Parsing dates involving a day of month without a year specified is ambiguious
and fails to parse leap day. The default behavior will change in Python 3.15
to either always raise an exception or to use a different default year (TBD).
To avoid trouble, add a specific year to the input & format.
See https://github.com/python/cpython/issues/70647.
minio_client.stat_object(BUCKET, key)
Поиск orphan объектов в S3, файлы без записи в БД
Файлов в БД: 102
Объектов в MinIO: 99
[ORPHAN] aec0da17-d643-41ce-a3f0-d8a83e96ad97.png (возраст: 0:00:12.293643, старше grace_period)
[DRY-RUN] Найдено 1 orphan. Удаление не выполнено.
Поиск missing объектов, записи в БД без файла в MinIO
Записей в БД: 102
[SKIP] id=ec42f559-a4ed-4237-87bd-8ed4791cbb12, key=33655bad-fe2d-4144-b621-b667d8eee105.png — используется в сообщении, не удаляем
[SKIP] id=57462036-5532-4a23-8a84-4437c1e89c64, key=aa776ea9-b469-4e4c-b5af-6f0e2b514a12.png — используется в сообщении, не удаляем
[SKIP] id=0858aa8f-d096-4ac3-ae8f-68b66411fe2e, key=f120b3d7-f213-42ea-ab3e-9b837a0167a0.png — используется в сообщении, не удаляем
[MISSING] id=414ecbba-4119-414f-8796-8c41128f8e70, key=43dbaa2d-2f62-44cd-9d27-2aec1bb36164.png — не используется, можно удалить
[DRY-RUN] Missing: 1 (удалить), 3 (используется, SKIP). Удаление не выполнено.
Итог
Orphan S3 без БД: 1
Missing БД без S3 (удалено): 1
Режим: DRY-RUN (ничего не удалено)
=== 7. EXECUTE ===
/app/scripts/reconcile.py:81: DeprecationWarning: Parsing dates involving a day of month without a year specified is ambiguious
and fails to parse leap day. The default behavior will change in Python 3.15
to either always raise an exception or to use a different default year (TBD).
To avoid trouble, add a specific year to the input & format.
See https://github.com/python/cpython/issues/70647.
minio_client.stat_object(BUCKET, key)
Поиск orphan объектов в S3, файлы без записи в БД
Файлов в БД: 102
Объектов в MinIO: 99
[ORPHAN] aec0da17-d643-41ce-a3f0-d8a83e96ad97.png (возраст: 0:00:13.113091, старше grace_period)
[DELETED] aec0da17-d643-41ce-a3f0-d8a83e96ad97.png
Удалено 1 orphan-объектов.
Поиск missing объектов, записи в БД без файла в MinIO
Записей в БД: 102
[SKIP] id=ec42f559-a4ed-4237-87bd-8ed4791cbb12, key=33655bad-fe2d-4144-b621-b667d8eee105.png — используется в сообщении, не удаляем
[SKIP] id=57462036-5532-4a23-8a84-4437c1e89c64, key=aa776ea9-b469-4e4c-b5af-6f0e2b514a12.png — используется в сообщении, не удаляем
[SKIP] id=0858aa8f-d096-4ac3-ae8f-68b66411fe2e, key=f120b3d7-f213-42ea-ab3e-9b837a0167a0.png — используется в сообщении, не удаляем
[MISSING] id=414ecbba-4119-414f-8796-8c41128f8e70, key=43dbaa2d-2f62-44cd-9d27-2aec1bb36164.png — не используется, можно удалить
Удалено 1 неиспользуемых missing из БД.
[SKIP] 3 используемых missing — не удалены (защита от битых сообщений).
Итог
Orphan S3 без БД: 1
Missing БД без S3 (удалено): 1
Режим: EXECUTE (изменения применены)
=== 8. Проверка: orphan удалён из MinIO ===
Orphan в MinIO: mc: <ERROR> Unable to stat `myminio/messenger-attachments/aec0da17-d643-41ce-a3f0-d8a83e96ad97.png`. Object does not exist.
=== 9. Проверка: missing удалён из БД ===
Записей с id=414ecbba-4119-414f-8796-8c41128f8e70 в БД: 0
=== 10. Идемпотентность: повторный DRY-RUN ===
/app/scripts/reconcile.py:81: DeprecationWarning: Parsing dates involving a day of month without a year specified is ambiguious
and fails to parse leap day. The default behavior will change in Python 3.15
to either always raise an exception or to use a different default year (TBD).
To avoid trouble, add a specific year to the input & format.
See https://github.com/python/cpython/issues/70647.
minio_client.stat_object(BUCKET, key)
Поиск orphan объектов в S3, файлы без записи в БД
Файлов в БД: 101
Объектов в MinIO: 98
Orphan-объектов не найдено.
Поиск missing объектов, записи в БД без файла в MinIO
Записей в БД: 101
[SKIP] id=ec42f559-a4ed-4237-87bd-8ed4791cbb12, key=33655bad-fe2d-4144-b621-b667d8eee105.png — используется в сообщении, не удаляем
[SKIP] id=57462036-5532-4a23-8a84-4437c1e89c64, key=aa776ea9-b469-4e4c-b5af-6f0e2b514a12.png — используется в сообщении, не удаляем
[SKIP] id=0858aa8f-d096-4ac3-ae8f-68b66411fe2e, key=f120b3d7-f213-42ea-ab3e-9b837a0167a0.png — используется в сообщении, не удаляем
[DRY-RUN] Missing: 0 (удалить), 3 (используется, SKIP). Удаление не выполнено.
Итог
Orphan S3 без БД: 0
Missing БД без S3 (удалено): 0
Режим: DRY-RUN (ничего не удалено)
================================================================
ИТОГ
================================================================
PASS:
- Пользователь reconcile_tester_1794501887 создан (HTTP 201), логин 201, токен получен
- ORPHAN удалён из MinIO
- MISSING удалён из БД
- Повторный dry-run: 0/0 (идемпотентность)
View File
+32
View File
@@ -0,0 +1,32 @@
./scripts/rolling-load.sh
Нагрузка: 30 запросов с интервалом 0.5 сек
16:51:30 code=200 instance=534c1846-b123-481b-a9c4-71c7049315ae
16:51:30 code=200 instance=0a6121d9-07cc-4491-9937-e8b68e5156c5
16:51:31 code=200 instance=0a6121d9-07cc-4491-9937-e8b68e5156c5
16:51:33 code=200 instance=0a6121d9-07cc-4491-9937-e8b68e5156c5
16:51:34 code=200 instance=06026485-762d-4e6a-a368-e1bac311a756
16:51:35 code=200 instance=0a6121d9-07cc-4491-9937-e8b68e5156c5
16:51:35 code=200 instance=06026485-762d-4e6a-a368-e1bac311a756
16:51:36 code=200 instance=0a6121d9-07cc-4491-9937-e8b68e5156c5
16:51:36 code=200 instance=06026485-762d-4e6a-a368-e1bac311a756
16:51:37 code=200 instance=0a6121d9-07cc-4491-9937-e8b68e5156c5
16:51:37 code=200 instance=06026485-762d-4e6a-a368-e1bac311a756
16:51:38 code=200 instance=0a6121d9-07cc-4491-9937-e8b68e5156c5
16:51:38 code=200 instance=06026485-762d-4e6a-a368-e1bac311a756
16:51:39 code=200 instance=06026485-762d-4e6a-a368-e1bac311a756
16:51:40 code=200 instance=06026485-762d-4e6a-a368-e1bac311a756
16:51:41 code=200 instance=86e75a44-8448-4aec-99c1-a2d9378f0dc2
16:51:41 code=200 instance=06026485-762d-4e6a-a368-e1bac311a756
16:51:42 code=200 instance=86e75a44-8448-4aec-99c1-a2d9378f0dc2
16:51:43 code=200 instance=06026485-762d-4e6a-a368-e1bac311a756
16:51:43 code=200 instance=86e75a44-8448-4aec-99c1-a2d9378f0dc2
16:51:44 code=200 instance=06026485-762d-4e6a-a368-e1bac311a756
16:51:44 code=200 instance=86e75a44-8448-4aec-99c1-a2d9378f0dc2
16:51:45 code=200 instance=06026485-762d-4e6a-a368-e1bac311a756
16:51:45 code=200 instance=86e75a44-8448-4aec-99c1-a2d9378f0dc2
16:51:46 code=200 instance=06026485-762d-4e6a-a368-e1bac311a756
16:51:46 code=200 instance=86e75a44-8448-4aec-99c1-a2d9378f0dc2
16:51:47 code=200 instance=06026485-762d-4e6a-a368-e1bac311a756
16:51:47 code=200 instance=86e75a44-8448-4aec-99c1-a2d9378f0dc2
16:51:48 code=200 instance=06026485-762d-4e6a-a368-e1bac311a756
16:51:49 code=200 instance=86e75a44-8448-4aec-99c1-a2d9378f0dc2
+159
View File
@@ -0,0 +1,159 @@
./scripts/rolling-update.sh
Rolling update: app1
Container mtusi2026lab3-app1-1 Stopping
Container mtusi2026lab3-app1-1 Stopped
#0 building with "desktop-linux" instance using docker driver
#1 [app1 internal] load build definition from Dockerfile
#1 transferring dockerfile: 685B done
#1 DONE 0.0s
#2 [app1 internal] load metadata for docker.io/library/python:3.13-slim
#2 DONE 1.8s
#3 [app1 internal] load .dockerignore
#3 transferring context: 279B done
#3 DONE 0.0s
#4 [app1 1/9] FROM docker.io/library/python:3.13-slim@sha256:09a17cad02668ae61ece136b4fd36ac3849e14f670ebedb637ea3e15580525bc
#4 DONE 0.0s
#5 [app1 internal] load build context
#5 transferring context: 4.73kB done
#5 DONE 0.0s
#6 [app1 4/9] RUN pip install --no-cache-dir -r requirements-dev.txt
#6 CACHED
#7 [app1 3/9] COPY requirements-dev.txt .
#7 CACHED
#8 [app1 2/9] WORKDIR /app
#8 CACHED
#9 [app1 8/9] COPY alembic/ alembic/
#9 CACHED
#10 [app1 6/9] COPY app/ app/
#10 CACHED
#11 [app1 7/9] COPY alembic.ini .
#11 CACHED
#12 [app1 5/9] RUN useradd --create-home --shell /bin/bash appuser
#12 CACHED
#13 [app1 9/9] RUN chown -R appuser:appuser /app/alembic
#13 CACHED
#14 [app1] exporting to image
#14 exporting layers done
#14 writing image sha256:af1621af7e8af7324cc026feef618c950fa872eeb17c4333dade10b720a57503 done
#14 naming to docker.io/library/mtusi2026lab3-app1 done
#14 DONE 0.0s
#15 [app1] resolving provenance for metadata file
#15 DONE 0.0s
Container mtusi_messenger_redis Running
Container mtusi_messenger_db Running
Container mtusi2026lab3-app1-1 Created
Container mtusi_messenger_redis Waiting
Container mtusi_messenger_db Waiting
Container mtusi_messenger_redis Healthy
Container mtusi_messenger_db Healthy
Container mtusi2026lab3-app1-1 Starting
Container mtusi2026lab3-app1-1 Started
Жду, пока app1 станет healthy...
Rolling update: app2
Container mtusi2026lab3-app2-1 Stopping
Container mtusi2026lab3-app2-1 Stopped
#0 building with "desktop-linux" instance using docker driver
#1 [app2 internal] load build definition from Dockerfile
#1 transferring dockerfile: 685B done
#1 DONE 0.0s
#2 [app2 internal] load metadata for docker.io/library/python:3.13-slim
#2 DONE 0.3s
#3 [app2 internal] load .dockerignore
#3 transferring context: 279B done
#3 DONE 0.0s
#4 [app2 1/9] FROM docker.io/library/python:3.13-slim@sha256:09a17cad02668ae61ece136b4fd36ac3849e14f670ebedb637ea3e15580525bc
#4 DONE 0.0s
#5 [app2 internal] load build context
#5 transferring context: 4.73kB done
#5 DONE 0.0s
#6 [app2 3/9] COPY requirements-dev.txt .
#6 CACHED
#7 [app2 7/9] COPY alembic.ini .
#7 CACHED
#8 [app2 8/9] COPY alembic/ alembic/
#8 CACHED
#9 [app2 5/9] RUN useradd --create-home --shell /bin/bash appuser
#9 CACHED
#10 [app2 2/9] WORKDIR /app
#10 CACHED
#11 [app2 4/9] RUN pip install --no-cache-dir -r requirements-dev.txt
#11 CACHED
#12 [app2 6/9] COPY app/ app/
#12 CACHED
#13 [app2 9/9] RUN chown -R appuser:appuser /app/alembic
#13 CACHED
#14 [app2] exporting to image
#14 exporting layers done
#14 writing image sha256:9c5ffbef790bf603d2cd9d54e18df8b05aa9541f5201974646cfd5fb1d46720b done
#14 naming to docker.io/library/mtusi2026lab3-app2 done
#14 DONE 0.0s
#15 [app2] resolving provenance for metadata file
#15 DONE 0.0s
Container mtusi_messenger_redis Running
Container mtusi_messenger_db Running
Container mtusi2026lab3-app2-1 Created
Container mtusi_messenger_redis Waiting
Container mtusi_messenger_db Waiting
Container mtusi_messenger_db Healthy
Container mtusi_messenger_redis Healthy
Container mtusi2026lab3-app2-1 Starting
Container mtusi2026lab3-app2-1 Started
Жду, пока app2 станет healthy...
Проверка: обе реплики живы
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
␍ 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0␍100 15 100 15 0 0 2824 0 --:--:-- --:--:-- --:--:-- 3000
HTTP/1.1 200 OK
Server: nginx/1.29.4
Date: Fri, 06 Nov 2026 13:51:44 GMT
Content-Type: application/json
Content-Length: 15
Connection: keep-alive
x-instance-id: 06026485-762d-4e6a-a368-e1bac311a756
x-request-id: 9fd1f3e6-0c5a-4cce-a727-35467ef553b8
{"status":"ok"} % Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
␍ 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0␍100 15 100 15 0 0 3764 0 --:--:-- --:--:-- --:--:-- 5000
HTTP/1.1 200 OK
Server: nginx/1.29.4
Date: Fri, 06 Nov 2026 13:51:44 GMT
Content-Type: application/json
Content-Length: 15
Connection: keep-alive
x-instance-id: 86e75a44-8448-4aec-99c1-a2d9378f0dc2
x-request-id: 23fcdcf5-8f9c-48f3-8973-4c5a49186e23
{"status":"ok"}
+99
View File
@@ -0,0 +1,99 @@
set -e
mkdir -p evidence
{
echo "================================================================"
echo " RECONCILER TEST — $(date)"
echo "================================================================"
echo ""
echo "=== 1. Логин ==="
curl -s -X POST http://localhost:8080/api/v1/users \
-H "Content-Type: application/json" \
-d '{"username": "reconcile_tester", "display_name": "Reconciler Test", "password": "secret1234567"}' > /dev/null
TOKEN=$(curl -s -X POST http://localhost:8080/api/v1/auth/sessions \
-u "reconcile_tester:secret1234567" \
| python3 -c "import sys, json; print(json.load(sys.stdin)['token'])")
echo "Токен получен: ${TOKEN:0:20}..."
USER_ID=$(curl -s -X GET http://localhost:8080/api/v1/users/me \
-H "Authorization: Bearer $TOKEN" \
| python3 -c "import sys, json; print(json.load(sys.stdin)['id'])")
echo "User ID: $USER_ID"
echo ""
echo "=== 2. Создание чата ==="
CHAT_ID=$(curl -s -X POST http://localhost:8080/api/v1/chats \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d "{\"title\": \"Reconcile Test\", \"member_ids\": [\"$USER_ID\"]}" \
| python3 -c "import sys, json; print(json.load(sys.stdin)['id'])")
echo "Chat ID: $CHAT_ID"
echo ""
echo "=== 3. Загрузка файла (файл → MinIO, метаданные → БД) ==="
RESP=$(curl -s -X POST "http://localhost:8080/api/v1/chats/$CHAT_ID/attachments?filename=reconcile-test.png" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: image/png" \
--data-binary @tests/fixtures/sample.png)
echo "Ответ на загрузку: $RESP"
ATT_ID=$(echo "$RESP" | python3 -c "import sys, json; print(json.load(sys.stdin)['id'])")
echo "Attachment ID: $ATT_ID"
echo ""
echo "=== 4. Получаем object_key из БД ==="
OBJECT_KEY=$(docker compose exec -T db psql -U messenger -d messenger_db -t -c \
"SELECT object_key FROM attachments WHERE id = '$ATT_ID';" | tr -d ' \n')
echo "Object key: $OBJECT_KEY"
echo ""
echo "=== 5. Удаляем файл из MinIO (создаём MISSING) ==="
docker compose exec -T minio sh -c \
"mc alias set myminio http://localhost:9000 minioadmin minioadmin > /dev/null && mc rm myminio/messenger-attachments/$OBJECT_KEY"
echo "Файл удалён из MinIO. В БД запись осталась — это MISSING."
echo ""
echo "=== 6. RECONCILER — DRY-RUN (должен найти MISSING, не удалять) ==="
docker compose exec -T -w /app -e PYTHONPATH=/app app1 \
python scripts/reconcile.py --dry-run
echo ""
echo "=== 7. RECONCILER — EXECUTE (удаляет запись из БД) ==="
docker compose exec -T -w /app -e PYTHONPATH=/app app1 \
python scripts/reconcile.py --execute
echo ""
echo "=== 8. Проверяем, что запись удалена из БД ==="
COUNT=$(docker compose exec -T db psql -U messenger -d messenger_db -t -c \
"SELECT COUNT(*) FROM attachments WHERE id = '$ATT_ID';" | tr -d ' \n')
echo "Записей с id=$ATT_ID в БД: $COUNT"
echo ""
echo "=== 9. ФИНАЛЬНЫЙ DRY-RUN (всё должно быть чисто) ==="
docker compose exec -T -w /app -e PYTHONPATH=/app app1 \
python scripts/reconcile.py --dry-run
echo ""
echo "================================================================"
echo " ИТОГ"
echo "================================================================"
if [ "$COUNT" = "0" ]; then
echo "PASS: missing-объект найден и удалён из БД"
echo ""
echo "Что проверено:"
echo " - Загрузка файла: байты → MinIO, метаданные → PostgreSQL"
echo " - Создание MISSING: файл удалён из MinIO, запись в БД осталась"
echo " - Dry-run: reconciler нашёл [MISSING], но не удалил"
echo " - Execute: reconciler удалил запись из БД"
echo " - Проверка: COUNT(*) = 0 — запись удалена"
echo " - Идемпотентность: финальный dry-run чист"
else
echo "FAIL: запись всё ещё в БД (count=$COUNT)"
fi
} 2>&1 | tee evidence/reconciler.txt
echo ""
echo "Лог сохранён в evidence/reconciler.txt"
+23
View File
@@ -0,0 +1,23 @@
=== S3 credentials: api-user с ограниченной политикой ===
=== 1. Пользователи MinIO ===
enabled api-user api-attachments-p...
=== 2. api-user пытается создать пользователя → Access Denied ===
mc: <ERROR> Unable to add new user. Access Denied.
=== 3. api-user пытается создать бакет → Access Denied ===
mc: <ERROR> Unable to make bucket `myminio/test-bucket`. Access Denied.
=== 4. api-user пытается удалить бакет → Access Denied ===
mc: <ERROR> Failed to remove `myminio/messenger-attachments`. Access Denied.
=== 5. Политика api-user ===
AccessKey: api-user
Status: enabled
PolicyName: api-attachments-policy
MemberOf: []
=== 6. .env S3 (без секрета) ===
S3_ACCESS_KEY_ID=api-user
S3_SECRET_ACCESS_KEY=***
Binary file not shown.

After

Width:  |  Height:  |  Size: 130 KiB

+10
View File
@@ -0,0 +1,10 @@
HTTP/1.1 200 OK
Server: nginx/1.29.4
Date: Sat, 31 Oct 2026 14:20:31 GMT
Content-Type: application/json
Content-Length: 133
Connection: keep-alive
x-instance-id: 0bde7749-b376-47a1-b6b5-d6996cc8f451
x-request-id: b58b0c54-8f13-48ba-a469-b63f3bdd62f5
{"id":"75ff0b0b-2cc0-43cf-af38-a50ff2968506","username":"lbtest","display_name":"LB Test","created_at":"2026-10-31T14:06:35.944873Z"}
+10
View File
@@ -0,0 +1,10 @@
HTTP/1.1 200 OK
Server: nginx/1.29.4
Date: Sat, 31 Oct 2026 14:20:31 GMT
Content-Type: application/json
Content-Length: 133
Connection: keep-alive
x-instance-id: fd34912d-faf5-44cf-bb1c-5a6b6ab368dd
x-request-id: c4499fdd-21c8-4b60-90be-e47e079ede18
{"id":"75ff0b0b-2cc0-43cf-af38-a50ff2968506","username":"lbtest","display_name":"LB Test","created_at":"2026-10-31T14:06:35.944873Z"}
+10
View File
@@ -0,0 +1,10 @@
HTTP/1.1 200 OK
Server: nginx/1.29.4
Date: Sat, 31 Oct 2026 14:20:31 GMT
Content-Type: application/json
Content-Length: 133
Connection: keep-alive
x-instance-id: 0bde7749-b376-47a1-b6b5-d6996cc8f451
x-request-id: 40834f73-64c3-40de-adfe-049ecc07a4d4
{"id":"75ff0b0b-2cc0-43cf-af38-a50ff2968506","username":"lbtest","display_name":"LB Test","created_at":"2026-10-31T14:06:35.944873Z"}
+10
View File
@@ -0,0 +1,10 @@
HTTP/1.1 200 OK
Server: nginx/1.29.4
Date: Sat, 31 Oct 2026 14:20:31 GMT
Content-Type: application/json
Content-Length: 133
Connection: keep-alive
x-instance-id: fd34912d-faf5-44cf-bb1c-5a6b6ab368dd
x-request-id: 3a53c323-e47a-4eb4-8321-bd289f81d751
{"id":"75ff0b0b-2cc0-43cf-af38-a50ff2968506","username":"lbtest","display_name":"LB Test","created_at":"2026-10-31T14:06:35.944873Z"}
+28
View File
@@ -0,0 +1,28 @@
OBJECT_KEY=$(docker compose exec -T db psql -U messenger -d messenger_db -t -c "SELECT object_key FROM attachments ORDER BY created_at DESC LIMIT 1;" | tr -d ' \n')
echo "Object key: $OBJECT_KEY"=== STREAM LIMIT TEST (100 МБ → 413) ===
============================================================
STREAM LIMIT TEST
============================================================
Chat ID: 0827b408-d73f-4850-a6e6-ef9cd68bd8f5
=== Отправляем 100 МБ чанками (ожидаем 413, без OOM) ===
Status: 413 (ожидаем 413)
Время: 0.11s
============================================================
PASS: потоковый лимит работает, 413
============================================================
=== ПАМЯТЬ ПОСЛЕ (не выросла) ===
NAME MEM USAGE / LIMIT CPU %
mtusi2026lab4-app1-1 96.2MiB / 512MiB 0.21%
mtusi2026lab4-app2-1 94.42MiB / 512MiB 0.20%
mtusi_messenger_nginx 2.535MiB / 8.722GiB 0.00%
mtusi_messenger_redis 9.66MiB / 8.722GiB 0.77%
mtusi_messenger_db 22.11MiB / 8.722GiB 0.00%
mtusi2026lab4-minio-1 128.2MiB / 8.722GiB 0.10%
=== ВЫВОД ===
Status 413 за 0.11s — прервали на 10 МБ, не дочитывая 100 МБ
Память app1 не выросла, OOM нет, app1 жив
Потоковое чтение (request.stream()) + Nginx (client_max_body_size 10M) — двухуровневая защита
+30
View File
@@ -0,0 +1,30 @@
=== ДО ===
NAME MEM USAGE / LIMIT CPU %
mtusi2026lab4-app2-1 94.89MiB / 512MiB 0.18%
mtusi2026lab4-app1-1 94.97MiB / 512MiB 0.23%
mtusi_messenger_nginx 2.594MiB / 8.722GiB 0.00%
mtusi_messenger_db 46.87MiB / 8.722GiB 0.65%
mtusi2026lab4-minio-1 271.5MiB / 8.722GiB 0.46%
mtusi_messenger_redis 9.613MiB / 8.722GiB 0.89%
============================================================
STREAM LIMIT TEST
============================================================
Chat ID: e9b20faf-911a-4b3d-a936-3ad2c2b8e340
=== Отправляем 100 МБ чанками (ожидаем 413, без OOM) ===
Status: 413 (ожидаем 413)
Время: 0.11s
============================================================
PASS: потоковый лимит работает, 413
============================================================
=== ПОСЛЕ ===
NAME MEM USAGE / LIMIT CPU %
mtusi2026lab4-app2-1 94.89MiB / 512MiB 0.23%
mtusi2026lab4-app1-1 95.96MiB / 512MiB 0.23%
mtusi_messenger_nginx 2.594MiB / 8.722GiB 0.00%
mtusi_messenger_db 46.87MiB / 8.722GiB 0.01%
mtusi2026lab4-minio-1 271.5MiB / 8.722GiB 0.02%
mtusi_messenger_redis 9.613MiB / 8.722GiB 0.44%
+46
View File
@@ -0,0 +1,46 @@
============================= test session starts ==============================
platform darwin -- Python 3.13.2, pytest-8.3.4, pluggy-1.6.0 -- /Users/kirill/Downloads/drone_simulation_project/.venv/bin/python
cachedir: .pytest_cache
rootdir: /Users/kirill/Desktop/esp/temka/mtusi2026lab4
plugins: platformdirs-4.12.2, anyio-3.6.2
collecting ... collected 5 items
tests/test_attachments.py::test_file_too_large PASSED [ 20%]
tests/test_attachments.py::test_corrupted_image PASSED [ 40%]
tests/test_attachments.py::test_mime_spoofing PASSED [ 60%]
tests/test_attachments.py::test_foreign_attachment_access PASSED [ 80%]
tests/test_attachments.py::test_attachment_from_other_chat FAILED [100%]
=================================== FAILURES ===================================
_______________________ test_attachment_from_other_chat ________________________
def test_attachment_from_other_chat():
"""Файл из чужого чата нельзя прикрепить к своему сообщению."""
# Пользователь 1 создает чат и файл
token1 = register_and_login("test_chat_1")
chat_id1 = create_chat(token1)
content = make_png(10, 10)
resp_upload = upload_file(token1, chat_id1, content)
att_id = resp_upload.json()["id"]
# Пользователь 2 создает свой чат
token2 = register_and_login("test_chat_2")
chat_id2 = create_chat(token2)
# Пользователь 2 пытается отправить сообщение в СВОЙ чат, прикрепив ЧУЖОЙ файл
headers2 = {"Authorization": f"Bearer {token2}"}
resp_msg = requests.post(
f"{BASE_URL}/api/v1/chats/{chat_id2}/messages",
headers={**headers2, "Idempotency-Key": str(uuid.uuid4())},
json={"text": "взлом", "attachment_ids": [att_id]}
)
# В идеале должно быть 400 (нельзя прикрепить чужое), но зависит от реализации
> assert resp_msg.status_code in (400, 403, 404), f"Ожидался отказ, получен {resp_msg.status_code}"
E AssertionError: Ожидался отказ, получен 201
E assert 201 in (400, 403, 404)
E + where 201 = <Response [201]>.status_code
tests/test_attachments.py:108: AssertionError
=========================== short test summary info ============================
FAILED tests/test_attachments.py::test_attachment_from_other_chat - Assertion...
========================= 1 failed, 4 passed in 4.48s ==========================
+12
View File
@@ -0,0 +1,12 @@
python3 -m pytest tests/test_resilience.py -v
============================= test session starts ==============================
platform darwin -- Python 3.13.2, pytest-8.3.4, pluggy-1.6.0 -- /Users/kirill/Downloads/drone_simulation_project/.venv/bin/python3
cachedir: .pytest_cache
rootdir: /Users/kirill/Desktop/esp/temka/mtusi2026lab3
plugins: platformdirs-4.12.2, anyio-3.6.2
collecting ... collected 2 items
tests/test_resilience.py::test_postgres_down_returns_503 PASSED [ 50%]
tests/test_resilience.py::test_redis_down_returns_500_json PASSED [100%]
============================== 2 passed in 6.84s ===============================
+13
View File
@@ -0,0 +1,13 @@
python3 -m pytest tests/test_lab3.py -v
============================= test session starts ==============================
platform darwin -- Python 3.13.2, pytest-8.3.4, pluggy-1.6.0 -- /Users/kirill/Downloads/drone_simulation_project/.venv/bin/python3
cachedir: .pytest_cache
rootdir: /Users/kirill/Desktop/esp/temka/mtusi2026lab3
plugins: platformdirs-4.12.2, anyio-3.6.2
collecting ... collected 3 items
tests/test_lab3.py::test_idempotency_same_body_returns_same_id PASSED [ 33%]
tests/test_lab3.py::test_idempotency_different_body_returns_409 PASSED [ 66%]
tests/test_lab3.py::test_shared_session_across_replicas PASSED [100%]
============================== 3 passed in 1.50s ===============================
+23
View File
@@ -0,0 +1,23 @@
/app/scripts/reconcile.py:81: DeprecationWarning: Parsing dates involving a day of month without a year specified is ambiguious
and fails to parse leap day. The default behavior will change in Python 3.15
to either always raise an exception or to use a different default year (TBD).
To avoid trouble, add a specific year to the input & format.
See https://github.com/python/cpython/issues/70647.
minio_client.stat_object(BUCKET, key)
Поиск orphan объектов в S3, файлы без записи в БД
Файлов в БД: 112
Объектов в MinIO: 108
Orphan-объектов не найдено.
Поиск missing объектов, записи в БД без файла в MinIO
Записей в БД: 112
[SKIP] id=ec42f559-a4ed-4237-87bd-8ed4791cbb12, key=33655bad-fe2d-4144-b621-b667d8eee105.png — используется в сообщении, не удаляем
[SKIP] id=57462036-5532-4a23-8a84-4437c1e89c64, key=aa776ea9-b469-4e4c-b5af-6f0e2b514a12.png — используется в сообщении, не удаляем
[SKIP] id=0858aa8f-d096-4ac3-ae8f-68b66411fe2e, key=f120b3d7-f213-42ea-ab3e-9b837a0167a0.png — используется в сообщении, не удаляем
[SKIP] id=c97cdf01-3663-4c11-9e30-fd83c7bc0e5a, key=de86cd68-f019-4b7b-83f7-47d9d2fcd03a.png — используется в сообщении, не удаляем
[DRY-RUN] Missing: 0 (удалить), 4 (используется, SKIP). Удаление не выполнено.
Итог
Orphan S3 без БД: 0
Missing БД без S3 (удалено): 0
Режим: DRY-RUN (ничего не удалено)
+13
View File
@@ -0,0 +1,13 @@
Поиск orphan объектов в S3, файлы без записи в БД
Файлов в БД: 0
Объектов в MinIO: 0
Orphan-объектов не найдено.
Поиск missing объектов, записи в БД без файла в MinIO
Записей в БД: 0
Missing-записей не найдено.
Итог
Orphan S3 без БД: 0
Missing БД без S3: 0
Режим: DRY-RUN (ничего не удалено)
+62
View File
@@ -0,0 +1,62 @@
=== GRACE PERIOD TEST — Thu Nov 12 19:47:14 MSK 2026 ===
Токен получен: Og1fzgz0vqjdVCg0QUoh...
Chat ID: 2ec9048c-21d6-4c5e-9cc0-23921d61f547
Attachment ID: 9d31bb57-66a5-4c25-8dcc-314f1b12221f
Object key: 33e8916a-122e-4e45-9722-f37d6fd56b74.png
Запись удалена из БД — ORPHAN
=== DRY-RUN сразу (файл свежий, < grace 10 сек) ===
/app/scripts/reconcile.py:81: DeprecationWarning: Parsing dates involving a day of month without a year specified is ambiguious
and fails to parse leap day. The default behavior will change in Python 3.15
to either always raise an exception or to use a different default year (TBD).
To avoid trouble, add a specific year to the input & format.
See https://github.com/python/cpython/issues/70647.
minio_client.stat_object(BUCKET, key)
Файлов в БД: 111
Объектов в MinIO: 109
[SKIP] 33e8916a-122e-4e45-9722-f37d6fd56b74.png (возраст: 0:00:00.957545 — свежий, не трогаем)
[SKIP] id=ec42f559-a4ed-4237-87bd-8ed4791cbb12, key=33655bad-fe2d-4144-b621-b667d8eee105.png — используется в сообщении, не удаляем
[SKIP] id=57462036-5532-4a23-8a84-4437c1e89c64, key=aa776ea9-b469-4e4c-b5af-6f0e2b514a12.png — используется в сообщении, не удаляем
[SKIP] id=0858aa8f-d096-4ac3-ae8f-68b66411fe2e, key=f120b3d7-f213-42ea-ab3e-9b837a0167a0.png — используется в сообщении, не удаляем
[DRY-RUN] Missing: 0 (удалить), 3 (используется, SKIP). Удаление не выполнено.
=== Пауза 11 секунд ===
=== DRY-RUN через 11 секунд (файл старше grace 10 сек) ===
/app/scripts/reconcile.py:81: DeprecationWarning: Parsing dates involving a day of month without a year specified is ambiguious
and fails to parse leap day. The default behavior will change in Python 3.15
to either always raise an exception or to use a different default year (TBD).
To avoid trouble, add a specific year to the input & format.
See https://github.com/python/cpython/issues/70647.
minio_client.stat_object(BUCKET, key)
Файлов в БД: 111
Объектов в MinIO: 109
[ORPHAN] 33e8916a-122e-4e45-9722-f37d6fd56b74.png (возраст: 0:00:12.908644, старше grace_period)
[SKIP] id=ec42f559-a4ed-4237-87bd-8ed4791cbb12, key=33655bad-fe2d-4144-b621-b667d8eee105.png — используется в сообщении, не удаляем
[SKIP] id=57462036-5532-4a23-8a84-4437c1e89c64, key=aa776ea9-b469-4e4c-b5af-6f0e2b514a12.png — используется в сообщении, не удаляем
[SKIP] id=0858aa8f-d096-4ac3-ae8f-68b66411fe2e, key=f120b3d7-f213-42ea-ab3e-9b837a0167a0.png — используется в сообщении, не удаляем
[DRY-RUN] Missing: 0 (удалить), 3 (используется, SKIP). Удаление не выполнено.
=== EXECUTE (удаляем созревший orphan) ===
/app/scripts/reconcile.py:81: DeprecationWarning: Parsing dates involving a day of month without a year specified is ambiguious
and fails to parse leap day. The default behavior will change in Python 3.15
to either always raise an exception or to use a different default year (TBD).
To avoid trouble, add a specific year to the input & format.
See https://github.com/python/cpython/issues/70647.
minio_client.stat_object(BUCKET, key)
Объектов в MinIO: 109
[DELETED] 33e8916a-122e-4e45-9722-f37d6fd56b74.png
Удалено 1 orphan-объектов.
=== Проверка: orphan удалён из MinIO ===
Orphan в MinIO: mc: <ERROR> Unable to stat `myminio/messenger-attachments/33e8916a-122e-4e45-9722-f37d6fd56b74.png`. Object does not exist.
================================================================
ИТОГ
================================================================
1. Сразу (1 сек) → [SKIP] — свежий, не удаляется
2. Через 11 сек (12 сек > 10 сек) → [ORPHAN] — «созрел»
3. Execute → [DELETED] — удалён из MinIO
4. Это доказывает grace period: свежие не удаляются, старые — удаляются
+13
View File
@@ -0,0 +1,13 @@
Загружаем 50 файлов (по ~1 МБ)...
Chat ID: e82639fa-0981-4c2b-b27b-3401e68f1f31
Размер файла: 117.5 КБ
Загружено: 10/50
Загружено: 20/50
Загружено: 30/50
Загружено: 40/50
Загружено: 50/50
=== Результаты ===
Успешно: 50
Ошибок: 0
Время: 0.64s
+44
View File
@@ -0,0 +1,44 @@
=== USED ATTACHMENT TEST — Thu Nov 12 19:47:32 MSK 2026 ===
Chat ID: 8fda8190-2d4f-4fa7-b2f2-5f01f3a36fad
Attachment ID: c97cdf01-3663-4c11-9e30-fd83c7bc0e5a
Object key: de86cd68-f019-4b7b-83f7-47d9d2fcd03a.png
Сообщение создано с attachment_ids=[c97cdf01-3663-4c11-9e30-fd83c7bc0e5a] — файл ИСПОЛЬЗУЕТСЯ
Removed `myminio/messenger-attachments/de86cd68-f019-4b7b-83f7-47d9d2fcd03a.png`.
Файл удалён из MinIO — missing (используется)
=== DRY-RUN (ожидаем [SKIP] для используемого) ===
/app/scripts/reconcile.py:81: DeprecationWarning: Parsing dates involving a day of month without a year specified is ambiguious
and fails to parse leap day. The default behavior will change in Python 3.15
to either always raise an exception or to use a different default year (TBD).
To avoid trouble, add a specific year to the input & format.
See https://github.com/python/cpython/issues/70647.
minio_client.stat_object(BUCKET, key)
Записей в БД: 112
[SKIP] id=ec42f559-a4ed-4237-87bd-8ed4791cbb12, key=33655bad-fe2d-4144-b621-b667d8eee105.png — используется в сообщении, не удаляем
[SKIP] id=57462036-5532-4a23-8a84-4437c1e89c64, key=aa776ea9-b469-4e4c-b5af-6f0e2b514a12.png — используется в сообщении, не удаляем
[SKIP] id=0858aa8f-d096-4ac3-ae8f-68b66411fe2e, key=f120b3d7-f213-42ea-ab3e-9b837a0167a0.png — используется в сообщении, не удаляем
[SKIP] id=c97cdf01-3663-4c11-9e30-fd83c7bc0e5a, key=de86cd68-f019-4b7b-83f7-47d9d2fcd03a.png — используется в сообщении, не удаляем
[DRY-RUN] Missing: 0 (удалить), 4 (используется, SKIP). Удаление не выполнено.
=== EXECUTE (используемый не удаляется) ===
/app/scripts/reconcile.py:81: DeprecationWarning: Parsing dates involving a day of month without a year specified is ambiguious
and fails to parse leap day. The default behavior will change in Python 3.15
to either always raise an exception or to use a different default year (TBD).
To avoid trouble, add a specific year to the input & format.
See https://github.com/python/cpython/issues/70647.
minio_client.stat_object(BUCKET, key)
[SKIP] id=ec42f559-a4ed-4237-87bd-8ed4791cbb12, key=33655bad-fe2d-4144-b621-b667d8eee105.png — используется в сообщении, не удаляем
[SKIP] id=57462036-5532-4a23-8a84-4437c1e89c64, key=aa776ea9-b469-4e4c-b5af-6f0e2b514a12.png — используется в сообщении, не удаляем
[SKIP] id=0858aa8f-d096-4ac3-ae8f-68b66411fe2e, key=f120b3d7-f213-42ea-ab3e-9b837a0167a0.png — используется в сообщении, не удаляем
[SKIP] id=c97cdf01-3663-4c11-9e30-fd83c7bc0e5a, key=de86cd68-f019-4b7b-83f7-47d9d2fcd03a.png — используется в сообщении, не удаляем
[SKIP] 4 используемых missing — не удалены (защита от битых сообщений).
Записей с id=c97cdf01-3663-4c11-9e30-fd83c7bc0e5a в БД: 1
================================================================
ИТОГ
================================================================
PASS: используемый missing НЕ удалён (остался в БД, [SKIP])