From 920bdf964121fc97c065885670b07f3dddbf4654 Mon Sep 17 00:00:00 2001 From: masha Date: Thu, 1 Oct 2026 22:08:08 +0300 Subject: [PATCH] Lab2 --- evidence/explain.txt | 50 ++++++++++++++++++++-------------------- evidence/level4.txt | 2 +- evidence/load.json | 12 +++++----- evidence/load.txt | 12 +++++----- evidence/persistence.txt | 18 +++++++-------- 5 files changed, 47 insertions(+), 47 deletions(-) diff --git a/evidence/explain.txt b/evidence/explain.txt index 7d793fdd..5959bb58 100644 --- a/evidence/explain.txt +++ b/evidence/explain.txt @@ -5,64 +5,64 @@ PASS: chat row was rolled back together with members PASS: no chats without members exist in the database == EXPLAIN for message history pagination -messages total: 81809; in explained chat: 10000 +messages total: 83665; in explained chat: 10000 PASS: explained chat has >= 10 000 messages -- first page -Limit (actual time=0.026..0.042 rows=51 loops=1) +Limit (actual time=0.014..0.022 rows=51 loops=1) Buffers: shared hit=4 - -> Index Scan using messages_keyset_idx on messages (actual time=0.025..0.034 rows=51 loops=1) + -> Index Scan using messages_keyset_idx on messages (actual time=0.013..0.019 rows=51 loops=1) Index Cond: (chat_id = 'd00c8d51-a786-404d-aea9-c8447ec0614b'::uuid) Buffers: shared hit=4 Planning: Buffers: shared hit=6 -Planning Time: 0.208 ms -Execution Time: 0.079 ms +Planning Time: 0.096 ms +Execution Time: 0.045 ms -- keyset page after position 9000 -Limit (actual time=0.063..0.084 rows=51 loops=1) +Limit (actual time=0.025..0.036 rows=51 loops=1) Buffers: shared hit=4 read=1 - -> Index Scan using messages_keyset_idx on messages (actual time=0.062..0.076 rows=51 loops=1) + -> Index Scan using messages_keyset_idx on messages (actual time=0.024..0.032 rows=51 loops=1) Index Cond: ((chat_id = 'd00c8d51-a786-404d-aea9-c8447ec0614b'::uuid) AND (ROW(created_at, id) > ROW('2026-09-28 16:11:52.757537+00'::timestamp with time zone, 'cab6bb16-0f15-46a0-8f5e-13cb8416fd5e'::uuid))) Buffers: shared hit=4 read=1 -Planning Time: 0.135 ms -Execution Time: 0.215 ms +Planning Time: 0.058 ms +Execution Time: 0.097 ms -- OFFSET 9000 (not used by the API) -Limit (actual time=8.594..8.607 rows=51 loops=1) +Limit (actual time=5.664..5.672 rows=51 loops=1) Buffers: shared hit=265 - -> Sort (actual time=7.284..8.013 rows=9051 loops=1) + -> Sort (actual time=4.983..5.386 rows=9051 loops=1) Sort Key: created_at, id Sort Method: quicksort Memory: 1713kB Buffers: shared hit=265 - -> Bitmap Heap Scan on messages (actual time=0.651..2.145 rows=10000 loops=1) + -> Bitmap Heap Scan on messages (actual time=0.311..1.323 rows=10000 loops=1) Recheck Cond: (chat_id = 'd00c8d51-a786-404d-aea9-c8447ec0614b'::uuid) Heap Blocks: exact=134 Buffers: shared hit=265 - -> Bitmap Index Scan on messages_keyset_idx (actual time=0.615..0.616 rows=10000 loops=1) + -> Bitmap Index Scan on messages_keyset_idx (actual time=0.291..0.292 rows=10000 loops=1) Index Cond: (chat_id = 'd00c8d51-a786-404d-aea9-c8447ec0614b'::uuid) Buffers: shared hit=131 -Planning Time: 0.150 ms -Execution Time: 9.005 ms +Planning Time: 0.132 ms +Execution Time: 5.876 ms -- keyset page WITHOUT messages_keyset_idx (rolled back) -Limit (actual time=7.478..7.490 rows=51 loops=1) - Buffers: shared hit=1076 - -> Sort (actual time=7.475..7.479 rows=51 loops=1) +Limit (actual time=5.998..6.007 rows=51 loops=1) + Buffers: shared hit=1106 + -> Sort (actual time=5.996..5.999 rows=51 loops=1) Sort Key: created_at, id Sort Method: top-N heapsort Memory: 31kB - Buffers: shared hit=1076 - -> Seq Scan on messages (actual time=2.279..7.304 rows=999 loops=1) + Buffers: shared hit=1106 + -> Seq Scan on messages (actual time=1.232..5.880 rows=999 loops=1) Filter: ((chat_id = 'd00c8d51-a786-404d-aea9-c8447ec0614b'::uuid) AND (ROW(created_at, id) > ROW('2026-09-28 16:11:52.757537+00'::timestamp with time zone, 'cab6bb16-0f15-46a0-8f5e-13cb8416fd5e'::uuid))) - Rows Removed by Filter: 80810 - Buffers: shared hit=1076 + Rows Removed by Filter: 82666 + Buffers: shared hit=1106 Planning: Buffers: shared hit=4 -Planning Time: 0.204 ms -Execution Time: 7.569 ms +Planning Time: 0.166 ms +Execution Time: 6.063 ms PASS: first page reads the index in order, no Sort PASS: keyset cursor is an Index Cond, not a filter over the history PASS: keyset deep page touches fewer buffers than OFFSET (5 < 265) -PASS: index reduces buffers for the deep page (5 < 1076) +PASS: index reduces buffers for the deep page (5 < 1106) PASS: db checks diff --git a/evidence/level4.txt b/evidence/level4.txt index 68f8b4ae..332de50f 100644 --- a/evidence/level4.txt +++ b/evidence/level4.txt @@ -38,7 +38,7 @@ PASS: forged token still 401 without Valkey PASS: anonymous still 401 without Valkey PASS: logout works without Valkey PASS: token revoked during outage -> 401 -PASS: bounded latency during outage (max 0.27s) +PASS: bounded latency during outage (max 0.26s) PASS: token revoked during outage stays 401 after Valkey returns (stale cache flushed) PASS: live session works after recovery diff --git a/evidence/load.json b/evidence/load.json index e282c672..702d0395 100644 --- a/evidence/load.json +++ b/evidence/load.json @@ -2,16 +2,16 @@ "lab": 2, "workload": "closed-loop POST messages; no automatic retries", "requested_duration_seconds": 15.0, - "elapsed_seconds": 15.06, + "elapsed_seconds": 15.022, "concurrency": 4, - "successful_requests": 1850, + "successful_requests": 2519, "failed_requests": 0, "error_ratio": 0.0, - "successful_rps": 122.839, + "successful_rps": 167.693, "successful_latency_ms": { - "p50": 31.423, - "p95": 41.656, - "p99": 55.931 + "p50": 21.44, + "p95": 38.631, + "p99": 48.175 }, "note": "Latency percentiles cover successes only. Timeouts/errors are counted separately; closed-loop has coordinated omission and client overhead." } diff --git a/evidence/load.txt b/evidence/load.txt index e282c672..702d0395 100644 --- a/evidence/load.txt +++ b/evidence/load.txt @@ -2,16 +2,16 @@ "lab": 2, "workload": "closed-loop POST messages; no automatic retries", "requested_duration_seconds": 15.0, - "elapsed_seconds": 15.06, + "elapsed_seconds": 15.022, "concurrency": 4, - "successful_requests": 1850, + "successful_requests": 2519, "failed_requests": 0, "error_ratio": 0.0, - "successful_rps": 122.839, + "successful_rps": 167.693, "successful_latency_ms": { - "p50": 31.423, - "p95": 41.656, - "p99": 55.931 + "p50": 21.44, + "p95": 38.631, + "p99": 48.175 }, "note": "Latency percentiles cover successes only. Timeouts/errors are counted separately; closed-loop has coordinated omission and client overhead." } diff --git a/evidence/persistence.txt b/evidence/persistence.txt index 64233aac..a7cc52e6 100644 --- a/evidence/persistence.txt +++ b/evidence/persistence.txt @@ -1,14 +1,14 @@ ## containers before restart hook -api running Up About a minute 2026-09-30 11:30:01 +0300 MSK -api_short_ttl running Up 3 minutes 2026-09-30 11:30:01 +0300 MSK -db running Up 39 seconds (healthy) 2026-09-29 20:09:08 +0300 MSK -migrate exited Exited (0) 3 minutes ago 2026-09-30 11:30:01 +0300 MSK +api running Up About a minute 2026-10-01 22:00:19 +0300 MSK +api_short_ttl running Up 4 minutes 2026-10-01 22:00:19 +0300 MSK +db running Up About a minute (healthy) 2026-09-29 20:09:08 +0300 MSK +migrate exited Exited (0) 4 minutes ago 2026-10-01 22:00:19 +0300 MSK valkey running Up About a minute (healthy) 2026-09-29 20:09:08 +0300 MSK Executing explicit persistence hook; hook output suppressed to avoid leaking secrets. PASS: persistence preserved confirmed data and existing session. Hook scope needs operator evidence. ## containers after restart hook (Status shows new uptime) -api running Up 3 seconds 2026-09-30 11:30:01 +0300 MSK -api_short_ttl running Up 3 minutes 2026-09-30 11:30:01 +0300 MSK -db running Up 4 seconds (health: starting) 2026-09-29 20:09:08 +0300 MSK -migrate exited Exited (0) 3 minutes ago 2026-09-30 11:30:01 +0300 MSK -valkey running Up 4 seconds (health: starting) 2026-09-29 20:09:08 +0300 MSK +api running Up 1 second 2026-10-01 22:00:19 +0300 MSK +api_short_ttl running Up 4 minutes 2026-10-01 22:00:19 +0300 MSK +db running Up 2 seconds (health: starting) 2026-09-29 20:09:08 +0300 MSK +migrate exited Exited (0) 4 minutes ago 2026-10-01 22:00:19 +0300 MSK +valkey running Up 2 seconds (health: starting) 2026-09-29 20:09:08 +0300 MSK