Skip to content

feat: allow specifying expected PG error codes in txRunner to reduce log volume#4885

Open
huahuayu wants to merge 2 commits into
towns-protocol:mainfrom
huahuayu:fix/reduce-tx-log-volume
Open

feat: allow specifying expected PG error codes in txRunner to reduce log volume#4885
huahuayu wants to merge 2 commits into
towns-protocol:mainfrom
huahuayu:fix/reduce-tx-log-volume

Conversation

@huahuayu

Copy link
Copy Markdown

This PR addresses issue #3864 by allowing callers to specify a list of 'expected' PostgreSQL error codes.

Errors matching these codes will be logged at the DEBUG level instead of the WARN level, reducing log volume in distributed scenarios where certain database failures (e.g., unique violations or foreign key constraints during races) are anticipated.

Changes:

  • Added to .
  • Updated to check against and adjust log level accordingly.

Fixes #3864

@vercel

vercel Bot commented Feb 12, 2026

Copy link
Copy Markdown

@huahuayu is attempting to deploy a commit to the River Build Team Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Feb 12, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Added an option to txRunner to recognize expected PostgreSQL error codes. When a transaction error matches one of these codes, logging is downgraded to Debug and a pass flag is set; otherwise it logs at Warn. Existing retry/backoff and not-found handling remain unchanged.

Changes

Cohort / File(s) Summary
PostgreSQL Error Handling
core/node/storage/pg_storage.go
Imported slices; added expectedPgErrorCodes []string to txRunnerOpts; adjusted transaction error path to mark pass and log at Debug when error code is in expectedPgErrorCodes, otherwise log at Warn. Retry/backoff and serialization/deadlock handling unchanged.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: adding support for specifying expected PG error codes to reduce log volume in txRunner.
Description check ✅ Passed The description clearly relates to the changeset, explaining the motivation (reducing log volume) and the implementation approach (checking error codes against expected list).
Linked Issues check ✅ Passed The PR directly addresses issue #3864 by implementing the requested feature: allowing expected PG error codes to be specified and logged at DEBUG instead of WARN level.
Out of Scope Changes check ✅ Passed All changes are in-scope: the addition of expectedPgErrorCodes field, the slices import, and enhanced error handling logic directly implement the feature requested in #3864.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

No actionable comments were generated in the recent review. 🎉

Tip

Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Redue pgx transaction failure log volume

1 participant