2 lab
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
PASS: dependency failures stay untrusted
|
||||
Command: python student-tests/deps.py --base-url http://127.0.0.1:8080
|
||||
Redis stopped: /health/ready 503, request without a token 401, request with a token 503.
|
||||
Postgres stopped: /health/ready 503, anonymous 401, registration 503.
|
||||
Both services were started again and /health/ready returned 200.
|
||||
Date: 2026-10-23
|
||||
@@ -0,0 +1,4 @@
|
||||
PASS: session expired after 3.0 s
|
||||
API was recreated with SESSION_TTL_SECONDS=2, then restored to 3600.
|
||||
Command: python student-tests/expiry.py --base-url http://127.0.0.1:8080 --wait 3
|
||||
Date: 2026-10-23
|
||||
@@ -0,0 +1,5 @@
|
||||
PASS: persistence preserved confirmed data and existing session. Hook scope needs operator evidence.
|
||||
Command, from a Linux container joined to the compose network, because Windows Python cannot execute scripts/restart.sh (WinError 193):
|
||||
docker run --rm --network mtusilab2_lab -v /var/run/docker.sock:/var/run/docker.sock -v "$PWD:/work" -w /work alpine:3.24.1 sh -c "apk add --no-cache python3 docker-cli docker-cli-compose && chmod +x scripts/restart.sh && python3 tests/resilience.py --mode persistence --action-script scripts/restart.sh --base-url http://api:8080"
|
||||
The hook restarts api, postgres and redis and does not remove volumes.
|
||||
Date: 2026-10-23
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,77 @@
|
||||
===== keyset_deep_history_index =====
|
||||
QUERY PLAN
|
||||
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
Limit (cost=1.16..39.32 rows=50 width=110) (actual time=0.151..0.163 rows=50 loops=1)
|
||||
Buffers: shared hit=14
|
||||
-> Incremental Sort (cost=1.16..5285.82 rows=6926 width=110) (actual time=0.150..0.159 rows=50 loops=1)
|
||||
Sort Key: created_at, ((id)::text)
|
||||
Presorted Key: created_at
|
||||
Full-sort Groups: 2 Sort Method: quicksort Average Memory: 33kB Peak Memory: 33kB
|
||||
Buffers: shared hit=14
|
||||
-> Index Scan using messages_history_idx on messages (cost=0.42..4980.14 rows=6926 width=110) (actual time=0.046..0.062 rows=51 loops=1)
|
||||
Index Cond: ((chat_id = 'a65fabe7-45b1-48f8-9e69-1ce146591e08'::uuid) AND (ROW(created_at, id) > ROW('2026-01-01 00:01:00.001+00'::timestamp with time zone, '4040726d-3600-430a-adda-fe4b752b1044'::uuid)))
|
||||
Buffers: shared hit=5
|
||||
Planning:
|
||||
Buffers: shared hit=127
|
||||
Planning Time: 0.918 ms
|
||||
Execution Time: 0.262 ms
|
||||
(14 rows)
|
||||
|
||||
===== offset_deep_same_chat =====
|
||||
QUERY PLAN
|
||||
---------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
Limit (cost=9985.13..9993.45 rows=50 width=110) (actual time=30.434..30.447 rows=50 loops=1)
|
||||
Buffers: shared hit=1124
|
||||
-> Incremental Sort (cost=0.61..11646.06 rows=69981 width=110) (actual time=0.143..29.165 rows=60050 loops=1)
|
||||
Sort Key: created_at, ((id)::text)
|
||||
Presorted Key: created_at
|
||||
Full-sort Groups: 1877 Sort Method: quicksort Average Memory: 33kB Peak Memory: 33kB
|
||||
Buffers: shared hit=1124
|
||||
-> Index Scan using messages_history_idx on messages (cost=0.42..9159.61 rows=69981 width=110) (actual time=0.045..20.330 rows=60051 loops=1)
|
||||
Index Cond: (chat_id = 'a65fabe7-45b1-48f8-9e69-1ce146591e08'::uuid)
|
||||
Buffers: shared hit=1115
|
||||
Planning:
|
||||
Buffers: shared hit=128
|
||||
Planning Time: 0.912 ms
|
||||
Execution Time: 30.490 ms
|
||||
(14 rows)
|
||||
|
||||
===== keyset_first_page_at_least_10000 =====
|
||||
QUERY PLAN
|
||||
-----------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
Limit (cost=0.74..17.47 rows=50 width=110) (actual time=0.139..0.153 rows=50 loops=1)
|
||||
Buffers: shared hit=14
|
||||
-> Incremental Sort (cost=0.74..6679.62 rows=19958 width=110) (actual time=0.139..0.150 rows=50 loops=1)
|
||||
Sort Key: created_at, ((id)::text)
|
||||
Presorted Key: created_at
|
||||
Full-sort Groups: 2 Sort Method: quicksort Average Memory: 33kB Peak Memory: 33kB
|
||||
Buffers: shared hit=14
|
||||
-> Index Scan using messages_history_idx on messages (cost=0.42..5831.91 rows=19958 width=110) (actual time=0.043..0.059 rows=51 loops=1)
|
||||
Index Cond: (chat_id = '09ba6f62-1a1f-449c-89ae-9ca655000b36'::uuid)
|
||||
Buffers: shared hit=5
|
||||
Planning:
|
||||
Buffers: shared hit=128
|
||||
Planning Time: 0.918 ms
|
||||
Execution Time: 0.191 ms
|
||||
(14 rows)
|
||||
|
||||
===== keyset_deep_created_at_index_only =====
|
||||
QUERY PLAN
|
||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
Limit (cost=1.04..39.19 rows=50 width=110) (actual time=0.212..0.257 rows=50 loops=1)
|
||||
Buffers: shared hit=11 read=3
|
||||
-> Incremental Sort (cost=1.04..5352.98 rows=7015 width=110) (actual time=0.211..0.252 rows=50 loops=1)
|
||||
Sort Key: created_at, ((id)::text)
|
||||
Presorted Key: created_at
|
||||
Full-sort Groups: 2 Sort Method: quicksort Average Memory: 33kB Peak Memory: 33kB
|
||||
Buffers: shared hit=11 read=3
|
||||
-> Index Scan using messages_time_created on messages_time (cost=0.29..5043.54 rows=7015 width=110) (actual time=0.067..0.116 rows=51 loops=1)
|
||||
Index Cond: (created_at >= '2026-01-01 00:01:00.001+00'::timestamp with time zone)
|
||||
Filter: ((chat_id = 'a65fabe7-45b1-48f8-9e69-1ce146591e08'::uuid) AND (ROW(created_at, id) > ROW('2026-01-01 00:01:00.001+00'::timestamp with time zone, '4040726d-3600-430a-adda-fe4b752b1044'::uuid)))
|
||||
Rows Removed by Filter: 1
|
||||
Buffers: shared hit=2 read=3
|
||||
Planning:
|
||||
Buffers: shared hit=106 read=1
|
||||
Planning Time: 1.195 ms
|
||||
Execution Time: 0.391 ms
|
||||
(16 rows)
|
||||
@@ -0,0 +1,99 @@
|
||||
{
|
||||
"track": 2,
|
||||
"hypothesis": "Keyset on (chat_id, created_at, id) reads about one page even deep in a large chat. OFFSET on the same index walks the skipped prefix. An index on created_at alone is also selective at a timestamp that only the largest chat has reached, so it is not a substitute for bounding the walk by chat_id. The extra history index increases insert time. A custom-format dump restored into a second Postgres volume matches the snapshot and omits a row committed after pg_dump started.",
|
||||
"hardware": {
|
||||
"platform": "Windows-11-10.0.22621-SP0",
|
||||
"cpu_count": 16,
|
||||
"ram_gib": 15.3,
|
||||
"api_limit": "2 CPU, 768 MiB"
|
||||
},
|
||||
"postgres": {
|
||||
"image": "postgres:16.10-alpine",
|
||||
"version": "16.10",
|
||||
"synchronous_commit": "on",
|
||||
"fsync": "on"
|
||||
},
|
||||
"redis_persistence": "appendonly\nyes\nappendfsync\neverysec",
|
||||
"distribution": {
|
||||
"messages": 100040,
|
||||
"chats": 73,
|
||||
"largest_chat": 70000,
|
||||
"empty_chats": 25,
|
||||
"sizes": [
|
||||
70000,
|
||||
20000,
|
||||
8000,
|
||||
1500,
|
||||
400,
|
||||
80,
|
||||
15,
|
||||
5,
|
||||
1,
|
||||
0
|
||||
]
|
||||
},
|
||||
"queries": {
|
||||
"keyset_deep_history_index": {
|
||||
"execution_ms": 0.262,
|
||||
"buffers": "",
|
||||
"shared_hit": 14,
|
||||
"shared_read": 0,
|
||||
"uses_history_index": true,
|
||||
"node": "Index Scan"
|
||||
},
|
||||
"offset_deep_same_chat": {
|
||||
"execution_ms": 30.49,
|
||||
"buffers": "",
|
||||
"shared_hit": 1124,
|
||||
"shared_read": 0,
|
||||
"uses_history_index": true,
|
||||
"node": "Index Scan"
|
||||
},
|
||||
"keyset_first_page_at_least_10000": {
|
||||
"execution_ms": 0.191,
|
||||
"buffers": "",
|
||||
"shared_hit": 14,
|
||||
"shared_read": 0,
|
||||
"uses_history_index": true,
|
||||
"node": "Index Scan"
|
||||
},
|
||||
"keyset_deep_created_at_index_only": {
|
||||
"execution_ms": 0.391,
|
||||
"buffers": "",
|
||||
"shared_hit": 11,
|
||||
"shared_read": 0,
|
||||
"uses_history_index": false,
|
||||
"node": "Index Scan"
|
||||
}
|
||||
},
|
||||
"write": {
|
||||
"rows": 50000,
|
||||
"primary_key_ms": 118.0,
|
||||
"primary_key_and_history_index_ms": 153.0
|
||||
},
|
||||
"backup": {
|
||||
"dump_seconds": 0.466,
|
||||
"restore_seconds": 0.667,
|
||||
"dump_bytes": 2980396,
|
||||
"counts_before_dump": {
|
||||
"users": 2,
|
||||
"chats": 73,
|
||||
"chat_members": 146,
|
||||
"messages": 100040
|
||||
},
|
||||
"counts_source_after_extra_commit": {
|
||||
"users": 2,
|
||||
"chats": 73,
|
||||
"chat_members": 146,
|
||||
"messages": 100041
|
||||
},
|
||||
"counts_restored": {
|
||||
"users": 2,
|
||||
"chats": 73,
|
||||
"chat_members": 146,
|
||||
"messages": 100040
|
||||
},
|
||||
"sample_match": true,
|
||||
"extra_row_in_restore": 0
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user