lab2: postgres, sessions, redis, persistence, stale read
Skeleton contracts / contracts (pull_request) Canceled after 0s
Skeleton contracts / contracts (pull_request) Canceled after 0s
This commit is contained in:
Binary file not shown.
@@ -0,0 +1,7 @@
|
||||
Limit (cost=0.29..4.45 rows=50 width=64) (actual time=0.030..0.039 rows=50 loops=1)
|
||||
Buffers: shared hit=3
|
||||
-> Index Scan using messages_chat_created_id_idx on messages
|
||||
Index Cond: (chat_id = '...'::uuid)
|
||||
Buffers: shared hit=3
|
||||
Planning Time: 0.560 ms
|
||||
Execution Time: 0.069 ms
|
||||
Binary file not shown.
@@ -0,0 +1,2 @@
|
||||
1) "session:-p3QE-W4uB-mVaLw_tFMhcm3K65RufBAE59ZVi6TABQ"
|
||||
2) "session:dqpgjo2m7OZVryghhb331A6vzLbZhByHxZkELcItUpg"
|
||||
@@ -0,0 +1,3 @@
|
||||
aof_enabled:1
|
||||
aof_last_bgrewrite_status:ok
|
||||
aof_last_write_status:ok
|
||||
@@ -0,0 +1 @@
|
||||
PASS: lab2 public API scenario; infrastructure and grading evidence remain separate.
|
||||
@@ -0,0 +1,28 @@
|
||||
=== STALE READ EXPERIMENT (трек 5.1) ===
|
||||
|
||||
BUG MODE (invalidation OFF):
|
||||
|
||||
1. Redis cache populated from GET /messages:
|
||||
Key: messages:aa29af3d-b946-4358-b7e6-eb6aedaf1ee0:
|
||||
Value: 50 items (seed 1..50)
|
||||
|
||||
2. POST STALE_1 → 201 Created.
|
||||
DB has STALE_1: 1
|
||||
|
||||
3. Cache still contains OLD page (without STALE_1):
|
||||
items in cache: 50
|
||||
STALE_1 in cache: 0
|
||||
|
||||
CONCLUSION:
|
||||
- DB has STALE_1 = 1
|
||||
- Cache has STALE_1 = 0
|
||||
- Client reads from cache → does NOT see own message
|
||||
- STALE READ CONFIRMED
|
||||
|
||||
FIXED MODE (invalidation ON):
|
||||
|
||||
MessageService.Send вызывает MessageCache.Invalidate(chatID) при флаге invalidate=true.
|
||||
Инвалидация удаляет все ключи messages:{chatID}:* из Redis.
|
||||
Следующий GET /messages идёт в БД и возвращает свежие данные.
|
||||
|
||||
Защита реализована в коде: internal/repository/redis/message_cache.go, метод Invalidate.
|
||||
Reference in New Issue
Block a user