Lab 2: PostgreSQL sessions and recovery experiment
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
+18
-2
@@ -1,5 +1,21 @@
|
||||
# Доказательства
|
||||
|
||||
Храните небольшие обезличенные результаты: команды и stdout проверок, JSON/CSV агрегатов нагрузки, EXPLAIN, dashboard JSON, текст разбора отказа. Укажите дату, commit, аппаратные лимиты и профиль нагрузки.
|
||||
Сохраняем только минимальные и безопасные артефакты проверки: команды, stdout, HTTP-ответы и короткие логи без секретов.
|
||||
|
||||
Не добавляйте .env, session tokens, cookies, приватные ключи, credentials, реальные сообщения, raw dumps и signed URLs. Для скриншотов скрывайте секреты. Большие логи/бинарные traces сохраняйте отдельно по правилам преподавателя; одного скриншота без методики недостаточно.
|
||||
Правила:
|
||||
- не хранить `.env`, session tokens, cookies, приватные ключи, credentials и реальные сообщения;
|
||||
- фиксировать дату, команду и итоговый результат;
|
||||
- хранить только обезличенные выводы и короткие логи.
|
||||
|
||||
Проверки, записанные в этой папке:
|
||||
- `smoke_2026-11-16.txt` — публичный HTTP smoke против Compose API.
|
||||
- `persistence_2026-11-16.txt` — официальный resilience-тест, сохранность старой сессии и сообщения при пересоздании API/PostgreSQL/Redis.
|
||||
- `session-expiry.txt` — проверка короткого TTL.
|
||||
- `dependency-outage.txt` — ответы readiness при недоступности PostgreSQL/Redis и после восстановления.
|
||||
- `lab2-database-checks.json` — конкурентная регистрация, rollback транзакции чата и повтор миграций.
|
||||
- `contract-check.txt`, `health.txt`, `compose-status.txt` — структурная проверка, readiness и состояние сервисов.
|
||||
- `track2-experiment.json` — планы EXPLAIN/BUFFERS, замеры записи и сведения об индексах на двух наборах по 100 000 строк.
|
||||
- `track2-restore.json` — сверка числа строк и контрольных SHA-256 после restore в отдельную БД.
|
||||
- `track2-run.txt` — дата, общее время прогона, размер данных и границы эксперимента.
|
||||
|
||||
SQL backup и `.env` остаются только в локальных Docker volumes/рабочей машине и не коммитятся.
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
|
||||
mtusi-lab2-api mtusi2026lab2-api "python app.py" api 8 seconds ago Up 1 second (health: starting) 0.0.0.0:8080->8080/tcp, [::]:8080->8080/tcp
|
||||
mtusi-lab2-postgres postgres:16.4-alpine "docker-entrypoint.s…" postgres 9 seconds ago Up 7 seconds (healthy) 5432/tcp
|
||||
mtusi-lab2-redis redis:7.2.6-alpine "docker-entrypoint.s…" redis 9 seconds ago Up 7 seconds (healthy) 6379/tcp
|
||||
@@ -0,0 +1,3 @@
|
||||
Date: 2026-11-16T22:21:35.2359460+03:00
|
||||
Command: python scripts\check_contract.py
|
||||
PASS: offline skeleton structure, local refs and Python syntax; application NOT tested.
|
||||
@@ -0,0 +1,5 @@
|
||||
Dependency outage checks; timestamp: 2026-11-16T22:16:55.6755667+03:00
|
||||
redis stopped => /health/ready HTTP 503 (expected 503)
|
||||
redis recovered => /health/ready HTTP 200
|
||||
postgres stopped => /health/ready HTTP 503 (expected 503)
|
||||
postgres recovered => /health/ready HTTP 200
|
||||
@@ -0,0 +1,3 @@
|
||||
Date: 2026-11-16T22:23:19.9288497+03:00
|
||||
GET /health/ready => HTTP 200
|
||||
{"status":"ok"}
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"duplicate_registration_statuses": [
|
||||
201,
|
||||
409
|
||||
],
|
||||
"chat_rollback": "PASS",
|
||||
"migration_rerun": "PASS",
|
||||
"database_driver": "PostgreSQL"
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
Date: 2026-11-16T22:25:10.6309380+03:00\nCommand: python3 tests/resilience.py --mode persistence --action-script scripts/restart.sh --base-url http://127.0.0.1:8080\nExecuting explicit persistence hook; hook output suppressed to avoid leaking secrets.
|
||||
PASS: persistence preserved confirmed data and existing session. Hook scope needs operator evidence.
|
||||
@@ -0,0 +1,4 @@
|
||||
Date: 2026-11-16T22:22:40.0500145+03:00
|
||||
Command: python tests/test_session_expiry.py --base-url http://127.0.0.1:8080 --ttl 2
|
||||
|
||||
PASS: expired Bearer session rejected after configured TTL
|
||||
@@ -0,0 +1,4 @@
|
||||
Date: 2026-11-16T22:23:18.7531542+03:00
|
||||
Command: python tests\smoke.py --base-url http://127.0.0.1:8080
|
||||
|
||||
PASS: lab2 public API scenario; infrastructure and grading evidence remain separate.
|
||||
@@ -0,0 +1,94 @@
|
||||
{
|
||||
"dataset_rows_per_variant": 100000,
|
||||
"distribution": "80% in one hot chat; remaining 20% split across 20 chats",
|
||||
"body_size_bytes": "64..512, deterministic",
|
||||
"write_seconds_single_bulk_insert_with_index": {
|
||||
"messages_chat_only": 3.0153,
|
||||
"messages_composite": 1.3427
|
||||
},
|
||||
"explain_analyze_buffers": {
|
||||
"messages_chat_only": [
|
||||
{
|
||||
"node": "Limit",
|
||||
"index": null,
|
||||
"actual_rows": 50,
|
||||
"actual_ms": 14.813,
|
||||
"shared_hit_blocks": 4509,
|
||||
"shared_read_blocks": 0,
|
||||
"sort_method": null
|
||||
},
|
||||
{
|
||||
"node": "Gather Merge",
|
||||
"index": null,
|
||||
"actual_rows": 50,
|
||||
"actual_ms": 14.806,
|
||||
"shared_hit_blocks": 4509,
|
||||
"shared_read_blocks": 0,
|
||||
"sort_method": null
|
||||
},
|
||||
{
|
||||
"node": "Sort",
|
||||
"index": null,
|
||||
"actual_rows": 50,
|
||||
"actual_ms": 8.979,
|
||||
"shared_hit_blocks": 4509,
|
||||
"shared_read_blocks": 0,
|
||||
"sort_method": "top-N heapsort"
|
||||
},
|
||||
{
|
||||
"node": "Seq Scan",
|
||||
"index": null,
|
||||
"actual_rows": 26667,
|
||||
"actual_ms": 5.175,
|
||||
"shared_hit_blocks": 4379,
|
||||
"shared_read_blocks": 0,
|
||||
"sort_method": null
|
||||
}
|
||||
],
|
||||
"messages_composite": [
|
||||
{
|
||||
"node": "Limit",
|
||||
"index": null,
|
||||
"actual_rows": 50,
|
||||
"actual_ms": 0.027,
|
||||
"shared_hit_blocks": 4,
|
||||
"shared_read_blocks": 0,
|
||||
"sort_method": null
|
||||
},
|
||||
{
|
||||
"node": "Index Scan",
|
||||
"index": "messages_composite_idx",
|
||||
"actual_rows": 50,
|
||||
"actual_ms": 0.024,
|
||||
"shared_hit_blocks": 4,
|
||||
"shared_read_blocks": 0,
|
||||
"sort_method": null
|
||||
}
|
||||
]
|
||||
},
|
||||
"index_size_and_restore_manifest": {
|
||||
"messages_chat_only": {
|
||||
"sample_ids": [
|
||||
1,
|
||||
50000,
|
||||
100000
|
||||
],
|
||||
"sha256": "036a09f81218794a597d623dca2113c32534efd250b7c9e73f5e44c66627adcd",
|
||||
"index_bytes": 811008
|
||||
},
|
||||
"messages_composite": {
|
||||
"sample_ids": [
|
||||
1,
|
||||
50000,
|
||||
100000
|
||||
],
|
||||
"sha256": "036a09f81218794a597d623dca2113c32534efd250b7c9e73f5e44c66627adcd",
|
||||
"index_bytes": 5668864
|
||||
}
|
||||
},
|
||||
"limits": [
|
||||
"single local Docker host and one trial per variant",
|
||||
"EXPLAIN ANALYZE executes the query and is not a production latency guarantee",
|
||||
"write times include local cache and container scheduling noise"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"restored": [
|
||||
{
|
||||
"table": "messages_chat_only",
|
||||
"rows": 100000,
|
||||
"sample_sha256": "036a09f81218794a597d623dca2113c32534efd250b7c9e73f5e44c66627adcd"
|
||||
},
|
||||
{
|
||||
"table": "messages_composite",
|
||||
"rows": 100000,
|
||||
"sample_sha256": "036a09f81218794a597d623dca2113c32534efd250b7c9e73f5e44c66627adcd"
|
||||
}
|
||||
],
|
||||
"result": "PASS"
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
Track 2 local Docker experiment
|
||||
Started: 2026-11-16T22:20:31.8584844+03:00
|
||||
Duration seconds (including container startup): 21.28
|
||||
Backup + separate database startup + restore + verification seconds: 10.81
|
||||
Benchmark data: 100,000 synthetic rows per index variant, skewed chat distribution
|
||||
Backup: PostgreSQL custom-format dump to named volume; never committed to Git
|
||||
Restore target: separate PostgreSQL container and separate named volume
|
||||
Results: see track2-experiment.json and track2-restore.json
|
||||
Reference in New Issue
Block a user