Реализовать PostgreSQL, Redis-сессии и backup-трек для сдачи lab2 на 5.
Skeleton contracts / contracts (pull_request) Canceled after 0s

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Wladislava1
2026-10-23 11:35:32 +03:00
co-authored by Cursor
parent 65003b6119
commit 70790af646
29 changed files with 2583 additions and 19 deletions
+25
View File
@@ -0,0 +1,25 @@
BEGIN
DROP INDEX
CREATE INDEX
ANALYZE
QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Limit (cost=0.49..12.45 rows=51 width=64) (actual time=0.321..0.389 rows=51 loops=1)
Buffers: shared hit=698 read=4
-> Incremental Sort (cost=0.49..16387.23 rows=69872 width=64) (actual time=0.320..0.385 rows=51 loops=1)
Sort Key: created_at, id
Presorted Key: created_at
Full-sort Groups: 2 Sort Method: quicksort Average Memory: 29kB Peak Memory: 29kB
Buffers: shared hit=698 read=4
-> Index Scan using messages_created_idx on messages (cost=0.29..13242.99 rows=69872 width=64) (actual time=0.067..0.371 rows=52 loops=1)
Index Cond: (created_at >= '2024-06-01 00:00:00.005+00'::timestamp with time zone)
Filter: ((chat_id = '136ef7de-de6a-40ec-b0dc-95d805396a72'::uuid) AND (ROW(created_at, id) > ROW('2024-06-01 00:00:00.005+00'::timestamp with time zone, '56ab725d-bf82-4831-aa7d-81c3f4bd290f'::uuid)))
Rows Removed by Filter: 1173
Buffers: shared hit=698 read=4
Planning:
Buffers: shared hit=48 read=3
Planning Time: 0.180 ms
Execution Time: 0.419 ms
(16 rows)
ROLLBACK
+13
View File
@@ -0,0 +1,13 @@
QUERY PLAN
-----------------------------------------------------------------------------------------------------------------------------------------------
Limit (cost=0.42..12.63 rows=51 width=64) (actual time=0.011..0.026 rows=51 loops=1)
Buffers: shared hit=5
-> Index Scan using messages_history_idx on messages (cost=0.42..16699.34 rows=69722 width=64) (actual time=0.010..0.023 rows=51 loops=1)
Index Cond: (chat_id = '136ef7de-de6a-40ec-b0dc-95d805396a72'::uuid)
Buffers: shared hit=5
Planning:
Buffers: shared hit=137
Planning Time: 0.293 ms
Execution Time: 0.041 ms
(9 rows)
+13
View File
@@ -0,0 +1,13 @@
QUERY PLAN
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Limit (cost=0.42..12.78 rows=51 width=64) (actual time=0.011..0.027 rows=51 loops=1)
Buffers: shared hit=5
-> Index Scan using messages_history_idx on messages (cost=0.42..16814.89 rows=69375 width=64) (actual time=0.010..0.024 rows=51 loops=1)
Index Cond: ((chat_id = '136ef7de-de6a-40ec-b0dc-95d805396a72'::uuid) AND (ROW(created_at, id) > ROW('2024-06-01 00:00:00.005+00'::timestamp with time zone, '56ab725d-bf82-4831-aa7d-81c3f4bd290f'::uuid)))
Buffers: shared hit=5
Planning:
Buffers: shared hit=136
Planning Time: 0.279 ms
Execution Time: 0.051 ms
(9 rows)
+13
View File
@@ -0,0 +1,13 @@
QUERY PLAN
-------------------------------------------------------------------------------------------------------------------------------------------------
Limit (cost=1197.95..1209.93 rows=50 width=64) (actual time=0.707..0.717 rows=50 loops=1)
Buffers: shared hit=126
-> Index Scan using messages_history_idx on messages (cost=0.42..16699.34 rows=69722 width=64) (actual time=0.012..0.593 rows=5050 loops=1)
Index Cond: (chat_id = '136ef7de-de6a-40ec-b0dc-95d805396a72'::uuid)
Buffers: shared hit=126
Planning:
Buffers: shared hit=137
Planning Time: 0.299 ms
Execution Time: 0.732 ms
(9 rows)
+8
View File
@@ -0,0 +1,8 @@
stop redis
redis down: live 200, ready 503, anon/x-user-id 401, bearer 503
stop postgres
postgres down: live 200, ready 503, anon 401, bearer 503
session ttl 2s
expired session -> 401, delta was 1.32s
ttl restored, expires in 3599s
PASS failure checks
+9
View File
@@ -0,0 +1,9 @@
Executing explicit persistence hook; hook output suppressed to avoid leaking secrets.
PASS: persistence preserved confirmed data and existing session. Hook scope needs operator evidence.
Hook scripts/restart.sh перезапускает postgres, redis и api, без down -v.
StartedAt до и после отдельного прогона этого hook:
api 2026-10-21T07:11:11.963838601Z -> 2026-10-21T07:14:08.544990889Z
postgres 2026-10-21T07:10:49.490348132Z -> 2026-10-21T07:14:03.962396834Z
redis 2026-10-21T07:10:43.924825028Z -> 2026-10-21T07:14:03.949445392Z
Токен в persistence-тесте после такого рестарта читал те же данные.
+1
View File
@@ -0,0 +1 @@
PASS: lab2 public API scenario; infrastructure and grading evidence remain separate.
+5
View File
@@ -0,0 +1,5 @@
rollback: api count 119 -> 119, sql probe rows 0
username race: one 201, eleven 409, one row
migrations reapplied, users 26 -> 26, versions 001_init
redis persistence: rdb_last_bgsave_status:ok, aof_enabled:1, aof_last_write_status:ok, aof_current_size:7677
PASS student checks
+81
View File
@@ -0,0 +1,81 @@
{
"loaded_messages": 101000,
"load_seconds": 2.41,
"distribution": {
"big": 70000,
"mid": 20000,
"medium_10x1000": 10000,
"small_100x10": 1000
},
"messages_relation_size": "55 MB",
"history_index_deep": {
"execution_ms": 0.051,
"planning_ms": 0.279,
"buffers": "Buffers: shared hit=5"
},
"history_index_first_page": {
"execution_ms": 0.041,
"buffers": "Buffers: shared hit=5"
},
"offset_5000": {
"execution_ms": 0.732,
"buffers": "Buffers: shared hit=126"
},
"created_at_index_deep": {
"execution_ms": 0.419,
"buffers": "Buffers: shared hit=698 read=4"
},
"write_cost": [
{
"label": "pk_only",
"rows": 20000,
"repeats": [
86.679,
94.932,
88.568
],
"median_ms": 88.568
},
{
"label": "pk_and_history",
"rows": 20000,
"repeats": [
129.405,
102.727,
102.331
],
"median_ms": 102.727
},
{
"label": "pk_history_and_body",
"rows": 20000,
"repeats": [
219.639,
149.201,
306.247
],
"median_ms": 219.639
}
],
"dump_seconds": 0.774,
"restore_seconds": 0.597,
"counts": {
"messages": 101022,
"users": 30,
"chats": 121,
"members": 130,
"big": 70000,
"small": 10,
"small_bodies": "t2-1,t2-2,t2-3,t2-4,t2-5,t2-6,t2-7,t2-8,t2-9,t2-10",
"markers": "t2-1,t2-500,t2-70000"
},
"postgres": "PostgreSQL 16.10 (Debian 16.10-1.pgdg12+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14+deb12u1) 12.2.0, 64-bit",
"durability": [
"fsync=on",
"full_page_writes=on",
"synchronous_commit=on",
"wal_level=replica"
],
"docker_info": "8|8246038528|Docker Desktop",
"api_first_page_matches_sql": true
}