feat(database): add an infrastructure-error classifier and read-retry helper - #4863
Conversation
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (4)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📜 Recent review details⏰ Context from checks skipped due to timeout. (1)
🧰 Additional context used📓 Path-based instructions (9)We use vitest exclusively.📄 CodeRabbit inference engine (AGENTS.md) Files:
**Prefer static imports over dynamic imports.**📄 CodeRabbit inference engine (AGENTS.md) Files:
Add crumbs as you write code — not just when debugging.📄 CodeRabbit inference engine (AGENTS.md) Files:
Use `$replica` from `~/db.server` for read-heavy queries in the webapp.📄 CodeRabbit inference engine (internal-packages/database/CLAUDE.md) Files:
Use Prisma for database interactions in internal-packages/database with PostgreSQL📄 CodeRabbit inference engine (.github/copilot-instructions.md) Files:
Use vitest for all tests in the Trigger.dev repository📄 CodeRabbit inference engine (.github/copilot-instructions.md) Files:
Use function declarations instead of default exports📄 CodeRabbit inference engine (.github/copilot-instructions.md) Files:
Use types over interfaces for TypeScript Avoid using enums; prefer string unions or const objects instead📄 CodeRabbit inference engine (.github/copilot-instructions.md) Files:
When creating or editing OTEL metrics (counters, histograms, gauges), ensure metric attributes have low cardinality by using only enums, booleans, bounded error codes, or bounded shard IDs Do not use high-cardinality attributes in OTEL metr...📄 CodeRabbit inference engine (.cursor/rules/otel-metrics.mdc) Files:
🧠 Learnings (4)📚 Learning: 2026-06-04T18:16:35.386ZApplied to files:
📚 Learning: 2026-05-18T08:21:27.694ZApplied to files:
📚 Learning: 2026-05-18T08:21:27.694ZApplied to files:
📚 Learning: 2026-06-16T09:19:47.637ZApplied to files:
WalkthroughThe database package adds Prisma and connectivity-error classification. It adds Merge Risk: ⚪ Minimal · up to This localized change adds database error classification and an opt-in retry helper; no actionable merge-blocking risk remains beyond normal checks and review. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Full details: Description checkExplanation The description is on-topic and clearly explains the classifier, retry behavior, safety constraints, kill-switch, backoff, and shared retry budget. It omits the template sections for issue closure, checklist, explicit testing steps, changelog, and screenshots, but the core change description is complete. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
e35afcf to
f4f22da
Compare
f4f22da to
0436e22
Compare
0436e22 to
e77d850
Compare
e77d850 to
8dbc68b
Compare
8dbc68b to
0e36f7c
Compare
Adds a shared classifier (isInfrastructureError / looksLikeConnectivityError) recognising connection-blip failures (P1001/P1002/P1008/P1017, ECONNRESET, "connection terminated", "server has closed the connection"), and withInfraRetry — a retry helper gated by an enabled kill-switch (default off) and the existing TokenBucketRetryBudget. Only for operations safe to run more than once (reads, or writes made idempotent); it never authorises retrying a bare non-idempotent write. TRI-13553
0e36f7c to
d85831a
Compare
Summary
Adds two shared primitives to
@internal/databasefor surviving brief database connection blips: a classifier that recognises connectivity/infrastructure failures (as opposed to real query errors), andwithInfraRetry, a helper that retries an operation on those failures.Details
isInfrastructureError/looksLikeConnectivityErrorrecognise connection-level failures (unreachable server, closed connection, connection reset, connect timeouts) and deliberately do not match query or validation errors, so retries never mask a real bug.withInfraRetry(run, config)retriesrunon a classified infrastructure error with jittered backoff, gated by a shared token-bucket budget so a mass freeze cannot amplify into a retry storm. It has anenabledkill-switch (off by default) and reuses the existing retry-budget primitive.It must only wrap operations that are safe to run more than once (reads, or writes made idempotent); it deliberately provides no path that silently retries a non-idempotent write.