feat(lab2): PostgreSQL 18 persistence, Argon2id auth, Redis 7.4 sessions & cache, Grade 5 tracks
Skeleton contracts / contracts (pull_request) Canceled after 0s
Skeleton contracts / contracts (pull_request) Canceled after 0s
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
Limit (cost=0.42..17.21 rows=50 width=85) (actual time=0.043..0.051 rows=50.00 loops=1)
|
||||
Buffers: shared hit=5
|
||||
-> Index Scan using idx_messages_chat_created_id on messages (cost=0.42..7474.82 rows=22260 width=85) (actual time=0.042..0.046 rows=50.00 loops=1)
|
||||
Index Cond: ((chat_id = '22222222-2222-4222-8222-222222222222'::uuid) AND (ROW(created_at, id) > ROW('2026-02-01 00:00:50.001+00'::timestamp with time zone, '849cff37-c885-4e43-a645-07c3b941a69e'::uuid)))
|
||||
Index Searches: 1
|
||||
Buffers: shared hit=5
|
||||
Planning:
|
||||
Buffers: shared hit=111
|
||||
Planning Time: 1.140 ms
|
||||
Execution Time: 0.152 ms
|
||||
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"argon2id_and_auth_semantics": {
|
||||
"status": "PASS",
|
||||
"kdf_prefix": "$argon2id$v=19$m=19456,t=1,p=2$",
|
||||
"token_length_hex": 64
|
||||
},
|
||||
"concurrent_registration_race": {
|
||||
"threads": 20,
|
||||
"status_201": 1,
|
||||
"status_409": 19,
|
||||
"status": "PASS"
|
||||
},
|
||||
"composite_chat_rollback": {
|
||||
"chats_before": 2,
|
||||
"chats_after": 2,
|
||||
"members_before": 4,
|
||||
"members_after": 4,
|
||||
"status": "PASS"
|
||||
},
|
||||
"redis_outage_resilience": {
|
||||
"authenticated_fallback_status": 200,
|
||||
"invalid_token_status": 401,
|
||||
"status": "PASS"
|
||||
},
|
||||
"postgres_outage_resilience": {
|
||||
"health_ready_status": 503,
|
||||
"write_endpoint_status": 503,
|
||||
"error_code": "unavailable",
|
||||
"leaked_internals": false,
|
||||
"status": "PASS"
|
||||
},
|
||||
"short_ttl_expiry": {
|
||||
"session_ttl_seconds": 2,
|
||||
"status_immediate": 200,
|
||||
"status_after_2_5s": 401,
|
||||
"status": "PASS"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"lab": 2,
|
||||
"workload": "closed-loop POST messages; no automatic retries",
|
||||
"requested_duration_seconds": 15.0,
|
||||
"elapsed_seconds": 15.109,
|
||||
"concurrency": 4,
|
||||
"successful_requests": 7131,
|
||||
"failed_requests": 0,
|
||||
"error_ratio": 0.0,
|
||||
"successful_rps": 471.97,
|
||||
"successful_latency_ms": {
|
||||
"p50": 0.0,
|
||||
"p95": 31.0,
|
||||
"p99": 32.0
|
||||
},
|
||||
"note": "Latency percentiles cover successes only. Timeouts/errors are counted separately; closed-loop has coordinated omission and client overhead."
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"test": "make test-persistence ACTION_SCRIPT=scripts/restart.sh",
|
||||
"before_restart": [
|
||||
"/mtusi-lab2-postgres: StartedAt=2026-11-03T10:22:50.114289112Z Status=running",
|
||||
"/mtusi-lab2-redis: StartedAt=2026-11-03T10:22:50.081920441Z Status=running",
|
||||
"/mtusi-lab2-api: StartedAt=2026-11-03T10:22:52.491827310Z Status=running"
|
||||
],
|
||||
"after_restart": [
|
||||
"/mtusi-lab2-postgres: StartedAt=2026-11-03T10:24:31.512839104Z Status=running",
|
||||
"/mtusi-lab2-redis: StartedAt=2026-11-03T10:24:31.489120395Z Status=running",
|
||||
"/mtusi-lab2-api: StartedAt=2026-11-03T10:24:31.309481729Z Status=running"
|
||||
],
|
||||
"result": "PASS: persistence preserved confirmed data and existing session. All 3 containers (postgres, redis, api) confirmed restarted with new StartedAt timestamps."
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
{
|
||||
"track": "Track 1: Cache Consistency, Stampede Protection, Read-After-Write, and Cache Restart",
|
||||
"read_after_write_experiment": {
|
||||
"naive_ttl_saw_immediate_write": false,
|
||||
"naive_ttl_stale_read_observed": true,
|
||||
"write_through_versioned_cycles": 20,
|
||||
"write_through_versioned_stale_reads": 0
|
||||
},
|
||||
"cache_stampede_40_concurrent_readers": {
|
||||
"unprotected_naive": {
|
||||
"concurrency": 40,
|
||||
"sql_queries_executed": 1,
|
||||
"singleflight_shared": 0,
|
||||
"latency_p50_ms": 20.281,
|
||||
"latency_p95_ms": 26.554,
|
||||
"latency_p99_ms": 29.075
|
||||
},
|
||||
"protected_singleflight": {
|
||||
"concurrency": 40,
|
||||
"sql_queries_executed": 1,
|
||||
"singleflight_shared": 2,
|
||||
"latency_p50_ms": 20.698,
|
||||
"latency_p95_ms": 28.369,
|
||||
"latency_p99_ms": 28.93
|
||||
},
|
||||
"warm_cache_40_reads": {
|
||||
"requests": 40,
|
||||
"sql_queries_executed": 0,
|
||||
"cache_hits": 80,
|
||||
"latency_p50_ms": 3.721,
|
||||
"latency_p95_ms": 27.718,
|
||||
"latency_p99_ms": 28.19
|
||||
}
|
||||
},
|
||||
"redis_restart_recovery": {
|
||||
"status_after_restart": 200,
|
||||
"messages_verified": 41,
|
||||
"session_preserved": true
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
{
|
||||
"track": "Track 2: Query Plan on >=100,000 Skewed Messages and Backup/Restore Verification",
|
||||
"dataset": {
|
||||
"total_messages": 110044,
|
||||
"hot_chat_messages": 80000,
|
||||
"medium_chats": "4 chats x 5,000 messages = 20,000",
|
||||
"small_chats": "10 chats x 1,000 messages = 10,000",
|
||||
"deep_pagination_offset_tested": 50000
|
||||
},
|
||||
"write_cost_40k_messages": {
|
||||
"without_composite_index_ms": 2705.72,
|
||||
"with_composite_index_ms": 2739.69,
|
||||
"index_write_overhead_pct": 1.26
|
||||
},
|
||||
"query_plans_at_depth_50000": {
|
||||
"composite_keyset_index": {
|
||||
"index": "idx_messages_chat_created_id (chat_id, created_at ASC, id ASC)",
|
||||
"query_type": "Keyset: WHERE chat_id = $1 AND (created_at, id) > ($2, $3) ORDER BY created_at ASC, id ASC LIMIT 50",
|
||||
"node_type": "Limit",
|
||||
"execution_time_ms": 0.155,
|
||||
"shared_hit_blocks": 5,
|
||||
"shared_read_blocks": 0
|
||||
},
|
||||
"single_column_index_with_offset": {
|
||||
"index": "idx_messages_chat_only (chat_id)",
|
||||
"query_type": "Offset: WHERE chat_id = $1 ORDER BY created_at ASC, id ASC OFFSET 50000 LIMIT 50",
|
||||
"node_type": "Limit",
|
||||
"execution_time_ms": 51.121,
|
||||
"shared_hit_blocks": 1569,
|
||||
"shared_read_blocks": 0
|
||||
},
|
||||
"no_index_seq_scan": {
|
||||
"index": "NONE (Seq Scan + Top-N Sort)",
|
||||
"query_type": "Keyset without index",
|
||||
"node_type": "Limit",
|
||||
"execution_time_ms": 12.871,
|
||||
"shared_hit_blocks": 1578,
|
||||
"shared_read_blocks": 0
|
||||
}
|
||||
},
|
||||
"backup_and_restore": {
|
||||
"tool": "pg_dump -Fc / pg_restore",
|
||||
"backup_duration_ms": 701.29,
|
||||
"restore_duration_ms": 892.3,
|
||||
"source_messages_count": 110044,
|
||||
"restored_messages_count": 110044,
|
||||
"sample_sha256_before": "1e7c064d9dfbe2c5dd889df86a623fb5ea36d543ce8781e5995da2297a768eca",
|
||||
"sample_sha256_after": "1e7c064d9dfbe2c5dd889df86a623fb5ea36d543ce8781e5995da2297a768eca",
|
||||
"exact_match": true
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user