[PK-62] BE: WAL + busy_timeout + 20s tx timeout pre súbežný checkout #21
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feature/pk-62-checkout-tx-timeout-sqlite-busy"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fix Prisma
$transaction5s default timeout pri 8 súbežných checkout requestoch (vitesttests/checkout.test.ts:378). WAL mode + busy_timeout + zvýšený tx timeout na 20s.Closes PK-62.
SQLite serializuje zápisy, takže 8 paralelných POST /api/checkout zhltlo default 5 s Prisma transaction timeout (P2028 → HTTP 500). Riešime: - lib/db.ts: pri inicializácii PrismaClienta aplikujeme PRAGMA journal_mode=WAL a PRAGMA busy_timeout=15000. WAL zlepšuje súbežný reader/writer, busy_timeout núti SQLite čakať v drivere namiesto okamžitého SQLITE_BUSY. Export prismaReady umožní routám počkať na pragma init. - app/api/checkout/route.ts: $transaction { timeout: 20000, maxWait: 15000 } spolu s await prismaReady pred otvorením transakcie. - tests/helpers/db.ts: rovnaké PRAGMA aplikované na test klient cez resetCatalog. API kontrakt sa nemení (checkout response shape, status kódy, errory zostávajú). Verifikácia: tests/checkout.test.ts 13/13 zelených, celá vitest suite 198/198. Co-authored-by: multica-agent <github@multica.ai>