Complete lab2 grade 4 implementation and report
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
Дата: 2026-10-09.
|
||||
Версия: рабочее дерево после 83e3810 (добавление Redis).
|
||||
|
||||
> docker compose up -d --build --wait api
|
||||
Сборка успешна (go vet, go test, go build); API, PostgreSQL и Redis Healthy.
|
||||
|
||||
> py student-tests/cache-failures.py
|
||||
PASS: public profile cached; TTL <=60s; Redis hit confirmed; TTL not extended
|
||||
PASS: malformed cache entry replaced from PostgreSQL
|
||||
PASS: expired profile refilled from PostgreSQL
|
||||
PASS: Redis stopped -> PostgreSQL fallback 200 (0.438s); anonymous request 401
|
||||
PASS: Redis restart -> profile refilled; same Bearer token remains valid
|
||||
PASS: PostgreSQL stopped with warm cache -> 503 (3.172s); anonymous request 401
|
||||
PASS: PostgreSQL recovered; logout invalidates token even with cached profile
|
||||
|
||||
Код завершения: 0. Зависимости восстановлены в finally.
|
||||
Для проверки истечения тест сокращает TTL только собственного ключа через PEXPIRE;
|
||||
реальный TTL 60 секунд отдельно проверяется по PTTL, чтение его не продлевает.
|
||||
Тест не выводит пароли/токены. Измерения — одиночные запросы, не нагрузочный benchmark.
|
||||
|
||||
> py tests/smoke.py --base-url http://localhost:8080
|
||||
PASS: lab2 public API scenario; infrastructure and grading evidence remain separate.
|
||||
|
||||
> py tests/resilience.py --mode persistence --action-script scripts/restart.cmd --base-url http://localhost:8080
|
||||
Executing explicit persistence hook; hook output suppressed to avoid leaking secrets.
|
||||
PASS: persistence preserved confirmed data and existing session. Hook scope needs operator evidence.
|
||||
|
||||
Область рестарта: api, postgres, redis; снимки в restart-all-containers.json.
|
||||
StartedAt всех трёх изменился; именованный volume PostgreSQL сохранился.
|
||||
@@ -0,0 +1,17 @@
|
||||
Дата: 2026-10-09.
|
||||
Версия: рабочее дерево после 83e3810.
|
||||
|
||||
Метод: отдельная копия git ls-files --cached --others --exclude-standard,
|
||||
без .git, .env и secrets. Это не git clone: изменения ещё не закоммичены.
|
||||
Compose project: lab2-clean-check; порт копии изменён на 18080.
|
||||
Новый пароль создан scripts/init-local.ps1; новый volume lab2-clean-check_postgres_data.
|
||||
Docker использовал кеш слоёв сборки; загрузка зависимостей с нуля не проверялась.
|
||||
|
||||
> ./scripts/init-local.ps1
|
||||
Local PostgreSQL password created in secrets/ (value not printed).
|
||||
> docker compose -p lab2-clean-check up -d --build --wait api
|
||||
PASS: новый volume создан; migrate завершён; api/postgres/redis Healthy.
|
||||
> py tests/smoke.py --base-url http://localhost:18080
|
||||
PASS: lab2 public API scenario; infrastructure and grading evidence remain separate.
|
||||
> docker compose -p lab2-clean-check exec -T postgres psql -X -U messenger -d messenger -c 'TABLE schema_migrations;'
|
||||
version: 1; applied_at: 2026-10-09 20:12:41.436626+00; 1 row.
|
||||
@@ -0,0 +1,42 @@
|
||||
Дата: 2026-10-09.
|
||||
Версия: рабочее дерево после 83e3810, перед MR.
|
||||
|
||||
> ./scripts/init-local.ps1
|
||||
Local .env created (non-secret session TTL).
|
||||
Existing PostgreSQL password preserved.
|
||||
> docker compose --env-file .env config --quiet
|
||||
Exit code: 0.
|
||||
> make check test PYTHON=py
|
||||
py scripts/check_contract.py
|
||||
PASS: offline skeleton structure, local refs and Python syntax; application NOT tested.
|
||||
py tests/smoke.py --base-url "http://localhost:8080"
|
||||
PASS: lab2 public API scenario; infrastructure and grading evidence remain separate.
|
||||
|
||||
> py student-tests/sessions.py --expiry
|
||||
Условие: API пересоздан с SESSION_TTL_SECONDS=2, Redis включён.
|
||||
PASS: wrong/missing credentials 401; login JSON body 400
|
||||
PASS: short TTL session works before expiry and returns 401 after expiry
|
||||
|
||||
> git check-ignore .env secrets/postgres_password.txt
|
||||
.env
|
||||
secrets/postgres_password.txt
|
||||
> git ls-files secrets .env
|
||||
Пустой вывод: секреты не отслеживаются.
|
||||
> git diff 65003b6 --stat -- README.md COURSE.md contracts tests
|
||||
Пустой вывод: задание, контракт и публичные тесты сохранены.
|
||||
|
||||
Повторная проверка перед загрузкой: 10.10.2026.
|
||||
> make check test PYTHON=py
|
||||
PASS: offline skeleton structure, local refs and Python syntax; application NOT tested.
|
||||
PASS: lab2 public API scenario; infrastructure and grading evidence remain separate.
|
||||
> docker compose --env-file .env config --quiet
|
||||
Exit code: 0.
|
||||
> go test ./...
|
||||
PASS: все пакеты с тестами; internal/password — cached.
|
||||
> go vet ./...
|
||||
Exit code: 0; замечаний нет.
|
||||
> git diff --check
|
||||
Ошибок whitespace нет; Git предупреждает о преобразовании LF/CRLF.
|
||||
Все локальные ссылки REPORT.md существуют. Lab1: git status --short пуст.
|
||||
Отказы, persistence и EXPLAIN в этой повторной проверке не запускались;
|
||||
их результаты от 09.10.2026 сохранены в соответствующих evidence-файлах.
|
||||
@@ -0,0 +1,461 @@
|
||||
{
|
||||
"date": "2026-10-09",
|
||||
"messages_in_chat": 12000,
|
||||
"chat_id": "06ecd609-697c-48aa-9150-8bce12447663",
|
||||
"page_size": 50,
|
||||
"sql_limit": 51,
|
||||
"concurrency": 1,
|
||||
"warmups": 1,
|
||||
"repeats": 3,
|
||||
"postgres_version": "17.9 (Debian 17.9-1.pgdg12+1)",
|
||||
"docker_cpus_memory_bytes": "16 16389435392",
|
||||
"postgres_cpu_memory_limits": "0 0",
|
||||
"method": "SQL-generated fixture; ANALYZE; prepared query; one warmup and three serial measurements; no concurrent writers",
|
||||
"limitations": "warm cache, one synthetic chat; not HTTP latency or throughput; no crash-durability measurement",
|
||||
"cases": {
|
||||
"first_page": {
|
||||
"prepare": "PREPARE history(uuid,integer) AS SELECT id::text,chat_id::text,sender_id::text,text,created_at FROM messages WHERE chat_id=$1 ORDER BY messages.created_at,messages.id LIMIT $2;",
|
||||
"execute": "EXECUTE history('06ecd609-697c-48aa-9150-8bce12447663',51)",
|
||||
"plans": [
|
||||
{
|
||||
"Plan": {
|
||||
"Node Type": "Limit",
|
||||
"Parallel Aware": false,
|
||||
"Async Capable": false,
|
||||
"Startup Cost": 0.29,
|
||||
"Total Cost": 5.04,
|
||||
"Plan Rows": 51,
|
||||
"Plan Width": 143,
|
||||
"Actual Startup Time": 0.039,
|
||||
"Actual Total Time": 0.066,
|
||||
"Actual Rows": 51,
|
||||
"Actual Loops": 1,
|
||||
"Shared Hit Blocks": 3,
|
||||
"Shared Read Blocks": 0,
|
||||
"Shared Dirtied Blocks": 0,
|
||||
"Shared Written Blocks": 0,
|
||||
"Local Hit Blocks": 0,
|
||||
"Local Read Blocks": 0,
|
||||
"Local Dirtied Blocks": 0,
|
||||
"Local Written Blocks": 0,
|
||||
"Temp Read Blocks": 0,
|
||||
"Temp Written Blocks": 0,
|
||||
"Plans": [
|
||||
{
|
||||
"Node Type": "Index Scan",
|
||||
"Parent Relationship": "Outer",
|
||||
"Parallel Aware": false,
|
||||
"Async Capable": false,
|
||||
"Scan Direction": "Forward",
|
||||
"Index Name": "messages_chat_history_idx",
|
||||
"Relation Name": "messages",
|
||||
"Alias": "messages",
|
||||
"Startup Cost": 0.29,
|
||||
"Total Cost": 1118.17,
|
||||
"Plan Rows": 12000,
|
||||
"Plan Width": 143,
|
||||
"Actual Startup Time": 0.038,
|
||||
"Actual Total Time": 0.059,
|
||||
"Actual Rows": 51,
|
||||
"Actual Loops": 1,
|
||||
"Index Cond": "(chat_id = '06ecd609-697c-48aa-9150-8bce12447663'::uuid)",
|
||||
"Rows Removed by Index Recheck": 0,
|
||||
"Shared Hit Blocks": 3,
|
||||
"Shared Read Blocks": 0,
|
||||
"Shared Dirtied Blocks": 0,
|
||||
"Shared Written Blocks": 0,
|
||||
"Local Hit Blocks": 0,
|
||||
"Local Read Blocks": 0,
|
||||
"Local Dirtied Blocks": 0,
|
||||
"Local Written Blocks": 0,
|
||||
"Temp Read Blocks": 0,
|
||||
"Temp Written Blocks": 0
|
||||
}
|
||||
]
|
||||
},
|
||||
"Planning": {
|
||||
"Shared Hit Blocks": 113,
|
||||
"Shared Read Blocks": 0,
|
||||
"Shared Dirtied Blocks": 0,
|
||||
"Shared Written Blocks": 0,
|
||||
"Local Hit Blocks": 0,
|
||||
"Local Read Blocks": 0,
|
||||
"Local Dirtied Blocks": 0,
|
||||
"Local Written Blocks": 0,
|
||||
"Temp Read Blocks": 0,
|
||||
"Temp Written Blocks": 0
|
||||
},
|
||||
"Planning Time": 0.692,
|
||||
"Triggers": [],
|
||||
"Execution Time": 0.116
|
||||
},
|
||||
{
|
||||
"Plan": {
|
||||
"Node Type": "Limit",
|
||||
"Parallel Aware": false,
|
||||
"Async Capable": false,
|
||||
"Startup Cost": 0.29,
|
||||
"Total Cost": 5.04,
|
||||
"Plan Rows": 51,
|
||||
"Plan Width": 143,
|
||||
"Actual Startup Time": 0.035,
|
||||
"Actual Total Time": 0.059,
|
||||
"Actual Rows": 51,
|
||||
"Actual Loops": 1,
|
||||
"Shared Hit Blocks": 3,
|
||||
"Shared Read Blocks": 0,
|
||||
"Shared Dirtied Blocks": 0,
|
||||
"Shared Written Blocks": 0,
|
||||
"Local Hit Blocks": 0,
|
||||
"Local Read Blocks": 0,
|
||||
"Local Dirtied Blocks": 0,
|
||||
"Local Written Blocks": 0,
|
||||
"Temp Read Blocks": 0,
|
||||
"Temp Written Blocks": 0,
|
||||
"Plans": [
|
||||
{
|
||||
"Node Type": "Index Scan",
|
||||
"Parent Relationship": "Outer",
|
||||
"Parallel Aware": false,
|
||||
"Async Capable": false,
|
||||
"Scan Direction": "Forward",
|
||||
"Index Name": "messages_chat_history_idx",
|
||||
"Relation Name": "messages",
|
||||
"Alias": "messages",
|
||||
"Startup Cost": 0.29,
|
||||
"Total Cost": 1118.17,
|
||||
"Plan Rows": 12000,
|
||||
"Plan Width": 143,
|
||||
"Actual Startup Time": 0.034,
|
||||
"Actual Total Time": 0.053,
|
||||
"Actual Rows": 51,
|
||||
"Actual Loops": 1,
|
||||
"Index Cond": "(chat_id = '06ecd609-697c-48aa-9150-8bce12447663'::uuid)",
|
||||
"Rows Removed by Index Recheck": 0,
|
||||
"Shared Hit Blocks": 3,
|
||||
"Shared Read Blocks": 0,
|
||||
"Shared Dirtied Blocks": 0,
|
||||
"Shared Written Blocks": 0,
|
||||
"Local Hit Blocks": 0,
|
||||
"Local Read Blocks": 0,
|
||||
"Local Dirtied Blocks": 0,
|
||||
"Local Written Blocks": 0,
|
||||
"Temp Read Blocks": 0,
|
||||
"Temp Written Blocks": 0
|
||||
}
|
||||
]
|
||||
},
|
||||
"Planning": {
|
||||
"Shared Hit Blocks": 113,
|
||||
"Shared Read Blocks": 0,
|
||||
"Shared Dirtied Blocks": 0,
|
||||
"Shared Written Blocks": 0,
|
||||
"Local Hit Blocks": 0,
|
||||
"Local Read Blocks": 0,
|
||||
"Local Dirtied Blocks": 0,
|
||||
"Local Written Blocks": 0,
|
||||
"Temp Read Blocks": 0,
|
||||
"Temp Written Blocks": 0
|
||||
},
|
||||
"Planning Time": 0.632,
|
||||
"Triggers": [],
|
||||
"Execution Time": 0.106
|
||||
},
|
||||
{
|
||||
"Plan": {
|
||||
"Node Type": "Limit",
|
||||
"Parallel Aware": false,
|
||||
"Async Capable": false,
|
||||
"Startup Cost": 0.29,
|
||||
"Total Cost": 5.04,
|
||||
"Plan Rows": 51,
|
||||
"Plan Width": 143,
|
||||
"Actual Startup Time": 0.037,
|
||||
"Actual Total Time": 0.064,
|
||||
"Actual Rows": 51,
|
||||
"Actual Loops": 1,
|
||||
"Shared Hit Blocks": 3,
|
||||
"Shared Read Blocks": 0,
|
||||
"Shared Dirtied Blocks": 0,
|
||||
"Shared Written Blocks": 0,
|
||||
"Local Hit Blocks": 0,
|
||||
"Local Read Blocks": 0,
|
||||
"Local Dirtied Blocks": 0,
|
||||
"Local Written Blocks": 0,
|
||||
"Temp Read Blocks": 0,
|
||||
"Temp Written Blocks": 0,
|
||||
"Plans": [
|
||||
{
|
||||
"Node Type": "Index Scan",
|
||||
"Parent Relationship": "Outer",
|
||||
"Parallel Aware": false,
|
||||
"Async Capable": false,
|
||||
"Scan Direction": "Forward",
|
||||
"Index Name": "messages_chat_history_idx",
|
||||
"Relation Name": "messages",
|
||||
"Alias": "messages",
|
||||
"Startup Cost": 0.29,
|
||||
"Total Cost": 1118.17,
|
||||
"Plan Rows": 12000,
|
||||
"Plan Width": 143,
|
||||
"Actual Startup Time": 0.036,
|
||||
"Actual Total Time": 0.057,
|
||||
"Actual Rows": 51,
|
||||
"Actual Loops": 1,
|
||||
"Index Cond": "(chat_id = '06ecd609-697c-48aa-9150-8bce12447663'::uuid)",
|
||||
"Rows Removed by Index Recheck": 0,
|
||||
"Shared Hit Blocks": 3,
|
||||
"Shared Read Blocks": 0,
|
||||
"Shared Dirtied Blocks": 0,
|
||||
"Shared Written Blocks": 0,
|
||||
"Local Hit Blocks": 0,
|
||||
"Local Read Blocks": 0,
|
||||
"Local Dirtied Blocks": 0,
|
||||
"Local Written Blocks": 0,
|
||||
"Temp Read Blocks": 0,
|
||||
"Temp Written Blocks": 0
|
||||
}
|
||||
]
|
||||
},
|
||||
"Planning": {
|
||||
"Shared Hit Blocks": 113,
|
||||
"Shared Read Blocks": 0,
|
||||
"Shared Dirtied Blocks": 0,
|
||||
"Shared Written Blocks": 0,
|
||||
"Local Hit Blocks": 0,
|
||||
"Local Read Blocks": 0,
|
||||
"Local Dirtied Blocks": 0,
|
||||
"Local Written Blocks": 0,
|
||||
"Temp Read Blocks": 0,
|
||||
"Temp Written Blocks": 0
|
||||
},
|
||||
"Planning Time": 0.681,
|
||||
"Triggers": [],
|
||||
"Execution Time": 0.111
|
||||
}
|
||||
]
|
||||
},
|
||||
"after_6000": {
|
||||
"prepare": "PREPARE history(uuid,integer,timestamptz,uuid) AS SELECT id::text,chat_id::text,sender_id::text,text,created_at FROM messages WHERE chat_id=$1 AND (created_at,id)>($3,$4::uuid) ORDER BY messages.created_at,messages.id LIMIT $2;",
|
||||
"execute": "EXECUTE history('06ecd609-697c-48aa-9150-8bce12447663',51,'2026-10-08T19:47:14.460524+00:00','fc066765-6778-4d9f-b1ed-60f49ecef3db')",
|
||||
"plans": [
|
||||
{
|
||||
"Plan": {
|
||||
"Node Type": "Limit",
|
||||
"Parallel Aware": false,
|
||||
"Async Capable": false,
|
||||
"Startup Cost": 0.29,
|
||||
"Total Cost": 6.41,
|
||||
"Plan Rows": 51,
|
||||
"Plan Width": 143,
|
||||
"Actual Startup Time": 0.172,
|
||||
"Actual Total Time": 0.208,
|
||||
"Actual Rows": 51,
|
||||
"Actual Loops": 1,
|
||||
"Shared Hit Blocks": 4,
|
||||
"Shared Read Blocks": 0,
|
||||
"Shared Dirtied Blocks": 0,
|
||||
"Shared Written Blocks": 0,
|
||||
"Local Hit Blocks": 0,
|
||||
"Local Read Blocks": 0,
|
||||
"Local Dirtied Blocks": 0,
|
||||
"Local Written Blocks": 0,
|
||||
"Temp Read Blocks": 0,
|
||||
"Temp Written Blocks": 0,
|
||||
"Plans": [
|
||||
{
|
||||
"Node Type": "Index Scan",
|
||||
"Parent Relationship": "Outer",
|
||||
"Parallel Aware": false,
|
||||
"Async Capable": false,
|
||||
"Scan Direction": "Forward",
|
||||
"Index Name": "messages_chat_history_idx",
|
||||
"Relation Name": "messages",
|
||||
"Alias": "messages",
|
||||
"Startup Cost": 0.29,
|
||||
"Total Cost": 721.62,
|
||||
"Plan Rows": 6004,
|
||||
"Plan Width": 143,
|
||||
"Actual Startup Time": 0.171,
|
||||
"Actual Total Time": 0.201,
|
||||
"Actual Rows": 51,
|
||||
"Actual Loops": 1,
|
||||
"Index Cond": "((chat_id = '06ecd609-697c-48aa-9150-8bce12447663'::uuid) AND (ROW(created_at, id) > ROW('2026-10-08 19:47:14.460524+00'::timestamp with time zone, 'fc066765-6778-4d9f-b1ed-60f49ecef3db'::uuid)))",
|
||||
"Rows Removed by Index Recheck": 0,
|
||||
"Shared Hit Blocks": 4,
|
||||
"Shared Read Blocks": 0,
|
||||
"Shared Dirtied Blocks": 0,
|
||||
"Shared Written Blocks": 0,
|
||||
"Local Hit Blocks": 0,
|
||||
"Local Read Blocks": 0,
|
||||
"Local Dirtied Blocks": 0,
|
||||
"Local Written Blocks": 0,
|
||||
"Temp Read Blocks": 0,
|
||||
"Temp Written Blocks": 0
|
||||
}
|
||||
]
|
||||
},
|
||||
"Planning": {
|
||||
"Shared Hit Blocks": 112,
|
||||
"Shared Read Blocks": 0,
|
||||
"Shared Dirtied Blocks": 0,
|
||||
"Shared Written Blocks": 0,
|
||||
"Local Hit Blocks": 0,
|
||||
"Local Read Blocks": 0,
|
||||
"Local Dirtied Blocks": 0,
|
||||
"Local Written Blocks": 0,
|
||||
"Temp Read Blocks": 0,
|
||||
"Temp Written Blocks": 0
|
||||
},
|
||||
"Planning Time": 1.21,
|
||||
"Triggers": [],
|
||||
"Execution Time": 0.432
|
||||
},
|
||||
{
|
||||
"Plan": {
|
||||
"Node Type": "Limit",
|
||||
"Parallel Aware": false,
|
||||
"Async Capable": false,
|
||||
"Startup Cost": 0.29,
|
||||
"Total Cost": 6.41,
|
||||
"Plan Rows": 51,
|
||||
"Plan Width": 143,
|
||||
"Actual Startup Time": 0.045,
|
||||
"Actual Total Time": 0.076,
|
||||
"Actual Rows": 51,
|
||||
"Actual Loops": 1,
|
||||
"Shared Hit Blocks": 4,
|
||||
"Shared Read Blocks": 0,
|
||||
"Shared Dirtied Blocks": 0,
|
||||
"Shared Written Blocks": 0,
|
||||
"Local Hit Blocks": 0,
|
||||
"Local Read Blocks": 0,
|
||||
"Local Dirtied Blocks": 0,
|
||||
"Local Written Blocks": 0,
|
||||
"Temp Read Blocks": 0,
|
||||
"Temp Written Blocks": 0,
|
||||
"Plans": [
|
||||
{
|
||||
"Node Type": "Index Scan",
|
||||
"Parent Relationship": "Outer",
|
||||
"Parallel Aware": false,
|
||||
"Async Capable": false,
|
||||
"Scan Direction": "Forward",
|
||||
"Index Name": "messages_chat_history_idx",
|
||||
"Relation Name": "messages",
|
||||
"Alias": "messages",
|
||||
"Startup Cost": 0.29,
|
||||
"Total Cost": 721.62,
|
||||
"Plan Rows": 6004,
|
||||
"Plan Width": 143,
|
||||
"Actual Startup Time": 0.043,
|
||||
"Actual Total Time": 0.069,
|
||||
"Actual Rows": 51,
|
||||
"Actual Loops": 1,
|
||||
"Index Cond": "((chat_id = '06ecd609-697c-48aa-9150-8bce12447663'::uuid) AND (ROW(created_at, id) > ROW('2026-10-08 19:47:14.460524+00'::timestamp with time zone, 'fc066765-6778-4d9f-b1ed-60f49ecef3db'::uuid)))",
|
||||
"Rows Removed by Index Recheck": 0,
|
||||
"Shared Hit Blocks": 4,
|
||||
"Shared Read Blocks": 0,
|
||||
"Shared Dirtied Blocks": 0,
|
||||
"Shared Written Blocks": 0,
|
||||
"Local Hit Blocks": 0,
|
||||
"Local Read Blocks": 0,
|
||||
"Local Dirtied Blocks": 0,
|
||||
"Local Written Blocks": 0,
|
||||
"Temp Read Blocks": 0,
|
||||
"Temp Written Blocks": 0
|
||||
}
|
||||
]
|
||||
},
|
||||
"Planning": {
|
||||
"Shared Hit Blocks": 112,
|
||||
"Shared Read Blocks": 0,
|
||||
"Shared Dirtied Blocks": 0,
|
||||
"Shared Written Blocks": 0,
|
||||
"Local Hit Blocks": 0,
|
||||
"Local Read Blocks": 0,
|
||||
"Local Dirtied Blocks": 0,
|
||||
"Local Written Blocks": 0,
|
||||
"Temp Read Blocks": 0,
|
||||
"Temp Written Blocks": 0
|
||||
},
|
||||
"Planning Time": 0.609,
|
||||
"Triggers": [],
|
||||
"Execution Time": 0.143
|
||||
},
|
||||
{
|
||||
"Plan": {
|
||||
"Node Type": "Limit",
|
||||
"Parallel Aware": false,
|
||||
"Async Capable": false,
|
||||
"Startup Cost": 0.29,
|
||||
"Total Cost": 6.41,
|
||||
"Plan Rows": 51,
|
||||
"Plan Width": 143,
|
||||
"Actual Startup Time": 0.045,
|
||||
"Actual Total Time": 0.076,
|
||||
"Actual Rows": 51,
|
||||
"Actual Loops": 1,
|
||||
"Shared Hit Blocks": 4,
|
||||
"Shared Read Blocks": 0,
|
||||
"Shared Dirtied Blocks": 0,
|
||||
"Shared Written Blocks": 0,
|
||||
"Local Hit Blocks": 0,
|
||||
"Local Read Blocks": 0,
|
||||
"Local Dirtied Blocks": 0,
|
||||
"Local Written Blocks": 0,
|
||||
"Temp Read Blocks": 0,
|
||||
"Temp Written Blocks": 0,
|
||||
"Plans": [
|
||||
{
|
||||
"Node Type": "Index Scan",
|
||||
"Parent Relationship": "Outer",
|
||||
"Parallel Aware": false,
|
||||
"Async Capable": false,
|
||||
"Scan Direction": "Forward",
|
||||
"Index Name": "messages_chat_history_idx",
|
||||
"Relation Name": "messages",
|
||||
"Alias": "messages",
|
||||
"Startup Cost": 0.29,
|
||||
"Total Cost": 721.62,
|
||||
"Plan Rows": 6004,
|
||||
"Plan Width": 143,
|
||||
"Actual Startup Time": 0.044,
|
||||
"Actual Total Time": 0.069,
|
||||
"Actual Rows": 51,
|
||||
"Actual Loops": 1,
|
||||
"Index Cond": "((chat_id = '06ecd609-697c-48aa-9150-8bce12447663'::uuid) AND (ROW(created_at, id) > ROW('2026-10-08 19:47:14.460524+00'::timestamp with time zone, 'fc066765-6778-4d9f-b1ed-60f49ecef3db'::uuid)))",
|
||||
"Rows Removed by Index Recheck": 0,
|
||||
"Shared Hit Blocks": 4,
|
||||
"Shared Read Blocks": 0,
|
||||
"Shared Dirtied Blocks": 0,
|
||||
"Shared Written Blocks": 0,
|
||||
"Local Hit Blocks": 0,
|
||||
"Local Read Blocks": 0,
|
||||
"Local Dirtied Blocks": 0,
|
||||
"Local Written Blocks": 0,
|
||||
"Temp Read Blocks": 0,
|
||||
"Temp Written Blocks": 0
|
||||
}
|
||||
]
|
||||
},
|
||||
"Planning": {
|
||||
"Shared Hit Blocks": 112,
|
||||
"Shared Read Blocks": 0,
|
||||
"Shared Dirtied Blocks": 0,
|
||||
"Shared Written Blocks": 0,
|
||||
"Local Hit Blocks": 0,
|
||||
"Local Read Blocks": 0,
|
||||
"Local Dirtied Blocks": 0,
|
||||
"Local Written Blocks": 0,
|
||||
"Temp Read Blocks": 0,
|
||||
"Temp Written Blocks": 0
|
||||
},
|
||||
"Planning Time": 0.603,
|
||||
"Triggers": [],
|
||||
"Execution Time": 0.193
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
Date: 2026-10-09
|
||||
Command: py student-tests/explain-history.py
|
||||
Messages: 12000
|
||||
|
||||
PASS: first_page: history index, 51 rows, no full scan; median SQL execution 0.111 ms
|
||||
PASS: after_6000: history index, 51 rows, no full scan; median SQL execution 0.193 ms
|
||||
PASS: 12000 messages; HTTP cursor after 6000 returns message 6001; plans saved in evidence
|
||||
|
||||
Control: py tests/smoke.py --base-url http://localhost:8080
|
||||
PASS: lab2 public API scenario; infrastructure and grading evidence remain separate.
|
||||
|
||||
first_page
|
||||
PREPARE history(uuid,integer) AS SELECT id::text,chat_id::text,sender_id::text,text,created_at FROM messages WHERE chat_id=$1 ORDER BY messages.created_at,messages.id LIMIT $2;
|
||||
Limit (cost=0.29..5.04 rows=51 width=143) (actual time=0.042..0.066 rows=51 loops=1)
|
||||
Buffers: shared hit=3
|
||||
-> Index Scan using messages_chat_history_idx on messages (cost=0.29..1118.17 rows=12000 width=143) (actual time=0.040..0.059 rows=51 loops=1)
|
||||
Index Cond: (chat_id = '06ecd609-697c-48aa-9150-8bce12447663'::uuid)
|
||||
Buffers: shared hit=3
|
||||
Planning:
|
||||
Buffers: shared hit=113
|
||||
Planning Time: 0.702 ms
|
||||
Execution Time: 0.118 ms
|
||||
|
||||
after_6000
|
||||
PREPARE history(uuid,integer,timestamptz,uuid) AS SELECT id::text,chat_id::text,sender_id::text,text,created_at FROM messages WHERE chat_id=$1 AND (created_at,id)>($3,$4::uuid) ORDER BY messages.created_at,messages.id LIMIT $2;
|
||||
Limit (cost=0.29..6.41 rows=51 width=143) (actual time=0.043..0.080 rows=51 loops=1)
|
||||
Buffers: shared hit=4
|
||||
-> Index Scan using messages_chat_history_idx on messages (cost=0.29..721.62 rows=6004 width=143) (actual time=0.042..0.074 rows=51 loops=1)
|
||||
Index Cond: ((chat_id = '06ecd609-697c-48aa-9150-8bce12447663'::uuid) AND (ROW(created_at, id) > ROW('2026-10-08 19:47:14.460524+00'::timestamp with time zone, 'fc066765-6778-4d9f-b1ed-60f49ecef3db'::uuid)))
|
||||
Buffers: shared hit=4
|
||||
Planning:
|
||||
Buffers: shared hit=112
|
||||
Planning Time: 0.629 ms
|
||||
Execution Time: 0.152 ms
|
||||
@@ -0,0 +1,61 @@
|
||||
{
|
||||
"before": [
|
||||
{
|
||||
"service": "api",
|
||||
"id": "67ad51ae8ed17299021179b31c5d1125c35ee0679af469710762a295bf8e5687",
|
||||
"started_at": "2026-10-09T15:14:50.117640501Z",
|
||||
"status": "running",
|
||||
"data_volumes": [
|
||||
|
||||
]
|
||||
},
|
||||
{
|
||||
"service": "postgres",
|
||||
"id": "836bb4b071ea3cb8ed7b3bd1622898b3e5beb2bb28237616b4bca6e11d9cc55a",
|
||||
"started_at": "2026-10-09T15:15:20.187696938Z",
|
||||
"status": "running",
|
||||
"data_volumes": [
|
||||
"messenger-lab2_postgres_data"
|
||||
]
|
||||
},
|
||||
{
|
||||
"service": "redis",
|
||||
"id": "1014dede60b3f51332adc8f3b988e8c69dcac3ce8ab01fa18d81094b12b53cd7",
|
||||
"started_at": "2026-10-09T15:15:11.322251556Z",
|
||||
"status": "running",
|
||||
"data_volumes": [
|
||||
|
||||
]
|
||||
}
|
||||
],
|
||||
"after": [
|
||||
{
|
||||
"service": "api",
|
||||
"id": "67ad51ae8ed17299021179b31c5d1125c35ee0679af469710762a295bf8e5687",
|
||||
"started_at": "2026-10-09T15:16:04.389539436Z",
|
||||
"status": "running",
|
||||
"data_volumes": [
|
||||
|
||||
]
|
||||
},
|
||||
{
|
||||
"service": "postgres",
|
||||
"id": "836bb4b071ea3cb8ed7b3bd1622898b3e5beb2bb28237616b4bca6e11d9cc55a",
|
||||
"started_at": "2026-10-09T15:15:56.366913858Z",
|
||||
"status": "running",
|
||||
"data_volumes": [
|
||||
"messenger-lab2_postgres_data"
|
||||
]
|
||||
},
|
||||
{
|
||||
"service": "redis",
|
||||
"id": "1014dede60b3f51332adc8f3b988e8c69dcac3ce8ab01fa18d81094b12b53cd7",
|
||||
"started_at": "2026-10-09T15:15:56.350855874Z",
|
||||
"status": "running",
|
||||
"data_volumes": [
|
||||
|
||||
]
|
||||
}
|
||||
],
|
||||
"volumes_preserved": true
|
||||
}
|
||||
Reference in New Issue
Block a user