Skip to content

fix: remove non-deterministic 25P02 pool ROLLBACK - #1260

Merged
kalbasit merged 1 commit into
mainfrom
user/wnasreddine/fix-remove-25p02-rollback
May 25, 2026
Merged

kalbasit merged 1 commit into
mainfrom
user/wnasreddine/fix-remove-25p02-rollback

Conversation

@kalbasit

Copy link
Copy Markdown
Owner

Summary

  • Remove the best-effort bare ROLLBACK that was added in the
    previous commit to recover aborted-transaction connections.
  • The root cause (duplicate chunk conflicts) is eliminated by the
    DO NOTHING fix, so the ROLLBACK is no longer needed.
  • A meaningful integration test for this behaviour is non-deterministic
    without connection-level control over database/sql, so the code
    was removed rather than left in with a misleading comment.

Why

The bare ROLLBACK was a defensive measure for connections already
in the aborted state. Now that no statement ever aborts the transaction,
the fallback is dead code that adds complexity without benefit.

🤖 Generated with Claude Code

@dosubot dosubot Bot added the size:S This PR changes 10-29 lines, ignoring generated files. label May 25, 2026
@coderabbitai

coderabbitai Bot commented May 25, 2026 •

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@kalbasit, we couldn't start this review because you've used your available PR reviews for now.

Your plan includes 5 reviews of capacity. Refill in 6 minutes.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more review capacity refills, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than trial, open-source, and free plans. In all cases, review capacity refills continuously over time.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a03b1386-ac1b-4ab1-acc1-3c24353fe03c

📥 Commits

Reviewing files that changed from the base of the PR and between 3d60e11 and ece75d8.

📒 Files selected for processing (1)
  • pkg/database/client.go
📝 Walkthrough

Walkthrough

This PR removes an explicit ROLLBACK statement from Client.WithTransaction's error handling path. When fn returns an IsAbortedTransactionError, the transaction now skips the best-effort explicit cleanup and instead relies solely on the standard Ent transaction rollback before returning the original error.

Changes

Transaction error handling cleanup

Layer / File(s) Summary
WithTransaction error handling simplification
pkg/database/client.go
Explicit best-effort ROLLBACK against the connection pool is removed from the IsAbortedTransactionError error path; the method now only performs standard Ent transaction rollback and returns the original error.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A rollback once rolled, now rolls no more,
The error path clears—less to restore!
Trust the transaction to find its own way,
Simpler and cleaner, the rabbit's hallway! 🌲

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: removing a non-deterministic ROLLBACK related to PostgreSQL 25P02 (aborted transaction) state handling.
Description check ✅ Passed The description is directly related to the changeset, explaining why the ROLLBACK code was removed and its connection to the DO NOTHING fix.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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


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

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request removes a manual ROLLBACK operation from the WithTransaction function in pkg/database/client.go, as the previous implementation was non-deterministic. The reviewer recommends removing the IsAbortedTransactionError function if it has become dead code as a result of these changes.

I am having trouble creating individual review comments. Click here to see my feedback.

pkg/database/client.go (150-152)

medium

The removal of this block is appropriate as the manual ROLLBACK on the pool was non-deterministic (it could execute on any connection in the pool, not necessarily the one that failed). However, since IsAbortedTransactionError is no longer used in this file, and it appears to have been specifically added for this logic, please verify if it is still used elsewhere in the codebase. If it is now unused, it should be removed from pkg/database/errors.go to avoid leaving dead code.

@kalbasit
kalbasit force-pushed the user/wnasreddine/fix-remove-25p02-rollback branch from 3d60e11 to ece75d8 Compare May 25, 2026 00:25
Base automatically changed from user/wnasreddine/fix-chunk-do-nothing to main May 25, 2026 01:02
@kalbasit
kalbasit enabled auto-merge (squash) May 25, 2026 01:02
@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:S This PR changes 10-29 lines, ignoring generated files. labels May 25, 2026
The pool-level c.sdb.ExecContext("ROLLBACK") added for 25P02 recovery
can run on a different connection than the one with the aborted state
(database/sql ExecContext picks any idle pooled connection). Since the
DO NOTHING chunk-insert fix eliminates the root cause of 25P02, remove
the flawed recovery. IsAbortedTransactionError is kept as an exported
helper for future use.
@kalbasit
kalbasit force-pushed the user/wnasreddine/fix-remove-25p02-rollback branch from ece75d8 to 4ccda55 Compare May 25, 2026 01:02
@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels May 25, 2026
@kalbasit
kalbasit merged commit 7d718cd into main May 25, 2026
21 checks passed
@kalbasit
kalbasit deleted the user/wnasreddine/fix-remove-25p02-rollback branch May 25, 2026 01:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-stack size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant