Repository navigation
fix(client-engine-runtime): abort transaction on maxWait timeout - #28723
Merged
Merged
Conversation
Contributor
size-limit report 📦
|
aqrln
force-pushed
the
aqrln-zlzqrrouklym
branch
from
November 26, 2025 13:06
43311b9 to
46a0c27
Compare
When exceeding the `maxWait` time when trying to start a new transaction, we would incorrectly wait until the transaction is started aftera all (potentially hanging infinitely), and only then reject `startTransaction` after the fact if the overall time spent was larger than expected. This is not the intended behavior, `startTransaction` must reject as soon as the `maxWait` time is exceeded.
aqrln
force-pushed
the
aqrln-zlzqrrouklym
branch
from
November 26, 2025 13:09
46a0c27 to
c8c64bd
Compare
aqrln
marked this pull request as ready for review
November 26, 2025 13:52
jacek-prisma
approved these changes
Nov 27, 2025
aqrln
added a commit
that referenced
this pull request
Dec 3, 2025
#28723 fixed some issues in transaction startup but introduced a new bug: if the transaction manages to start in background after we timed out, we would leak a connection in the connection pool. This PR fixes that by waiting until the transaction starts in background and immediately rolling it back if it does, ignoring errors.
aqrln
added a commit
that referenced
this pull request
Dec 3, 2025
#28723 fixed some issues in transaction startup but introduced a new bug: if the transaction manages to start in background after we timed out, we would leak a connection in the connection pool. This PR fixes that by waiting until the transaction starts in background and immediately rolling it back if it does, ignoring errors.
aqrln
added a commit
that referenced
this pull request
Dec 3, 2025
#28723 fixed some issues in transaction startup but introduced a new bug: if the transaction manages to start in background after we timed out, we would leak a connection in the connection pool. This PR fixes that by waiting until the transaction starts in background and immediately rolling it back if it does, ignoring errors.
aqrln
added a commit
that referenced
this pull request
Dec 3, 2025
#28723 fixed some issues in transaction startup but introduced a new bug: if the transaction manages to start in background after we timed out, we would leak a connection in the connection pool. This PR fixes that by waiting until the transaction starts in background and immediately rolling it back if it does, ignoring errors.
aqrln
added a commit
that referenced
this pull request
Dec 3, 2025
#28723 fixed some issues in transaction startup but introduced a new bug: if the transaction manages to start in background after we timed out, we would leak a connection in the connection pool. This PR fixes that by waiting until the transaction starts in background and immediately rolling it back if it does, ignoring errors.
aqrln
added a commit
that referenced
this pull request
Dec 3, 2025
#28723 fixed some issues in transaction startup but introduced a new bug: if the transaction manages to start in background after we timed out, we would leak a connection in the connection pool. This PR fixes that by waiting until the transaction starts in background and immediately rolling it back if it does, ignoring errors.
aqrln
added a commit
that referenced
this pull request
Dec 4, 2025
#28723 fixed some issues in transaction startup but introduced a new bug: if the transaction manages to start in background after we timed out, we would leak a connection in the connection pool. This PR fixes that by waiting until the transaction starts in background and immediately rolling it back if it does, ignoring errors. Likely fixes https://linear.app/prisma-company/issue/TML-1648/investigate-itx-tests-failing-with-timeout <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved transaction startup timeout handling: if a transaction times out but later completes, the system now ensures the transaction is rolled back and connections are released to prevent resource leaks and performance issues. * **Tests** * Added tests covering timeouts during transaction startup and verifying cleanup occurs once the transaction eventually starts. <sub>✏️ Tip: You can customize this high-level summary in your review settings.</sub> <!-- end of auto-generated comment: release notes by coderabbit.ai -->
aqrln
added a commit
that referenced
this pull request
Dec 5, 2025
#28723 fixed some issues in transaction startup but introduced a new bug: if the transaction manages to start in background after we timed out, we would leak a connection in the connection pool. This PR fixes that by waiting until the transaction starts in background and immediately rolling it back if it does, ignoring errors. Likely fixes https://linear.app/prisma-company/issue/TML-1648/investigate-itx-tests-failing-with-timeout <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved transaction startup timeout handling: if a transaction times out but later completes, the system now ensures the transaction is rolled back and connections are released to prevent resource leaks and performance issues. * **Tests** * Added tests covering timeouts during transaction startup and verifying cleanup occurs once the transaction eventually starts. <sub>✏️ Tip: You can customize this high-level summary in your review settings.</sub> <!-- end of auto-generated comment: release notes by coderabbit.ai -->
aqrln
added a commit
that referenced
this pull request
Dec 5, 2025
#28723 fixed some issues in transaction startup but introduced a new bug: if the transaction manages to start in background after we timed out, we would leak a connection in the connection pool. This PR fixes that by waiting until the transaction starts in background and immediately rolling it back if it does, ignoring errors. Likely fixes https://linear.app/prisma-company/issue/TML-1648/investigate-itx-tests-failing-with-timeout <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved transaction startup timeout handling: if a transaction times out but later completes, the system now ensures the transaction is rolled back and connections are released to prevent resource leaks and performance issues. * **Tests** * Added tests covering timeouts during transaction startup and verifying cleanup occurs once the transaction eventually starts. <sub>✏️ Tip: You can customize this high-level summary in your review settings.</sub> <!-- end of auto-generated comment: release notes by coderabbit.ai -->
nams1570
added a commit
to hexclave/hexclave
that referenced
this pull request
Oct 13, 2026
) 7.1.0 has a race where the connection slot can be lost if a p2028 is encountered. This version is the first to truly fix it. [Here's a PR from prisma](prisma/orm#28723) which acknowledges the issue, which was shipped as part of 7.1.0. <!-- Make sure you've read the CONTRIBUTING.md guidelines: https://github.com/hexclave/hexclave/blob/dev/CONTRIBUTING.md --> <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Upgrades Prisma from 7.1.0 to 7.10.0 to fix a race condition where a P2028 error could permanently drop a connection pool slot; 7.10.0 is the first release with a proper fix. **Dependencies** - Bumps `@prisma/adapter-pg`, `@prisma/client`, `@prisma/instrumentation`, and `prisma` to 7.10.0. - Refreshes `pnpm-lock.yaml` with the updated transitive deps pulled in by the Prisma upgrade. <sup>Written for commit c41439f. Summary will update on new commits.</sup> <a href="https://cubic.dev/pr/hexclave/hexclave/pull/2110?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="View guided diff" src="https://www.cubic.dev/buttons/review-in-cubic-light.svg"></picture></a> <a href="https://www.cubic.dev/action/auto-fix/pr/hexclave/hexclave/2110?returnTo=https%3A%2F%2Fgithub.com%2Fhexclave%2Fhexclave%2Fpull%2F2110&source=description" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"><img alt="Turn on auto-fix" src="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"></picture></a> <!-- End of auto-generated description by cubic. --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Chores** * Updated backend platform components to newer versions. No changes to user-facing features or behavior are included in this release. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When exceeding the
maxWaittime when trying to start a new transaction, we would incorrectly wait until the transaction is started after all (potentially hanging infinitely), and only then rejectstartTransactionafter the fact if the overall time spent was larger than expected. This is not the intended behavior,startTransactionmust reject as soon as themaxWaittime is exceeded.Additionally, we were potentially leaking the transaction timer and transaction object if starting the transaction timed out, and incorrectly issuing rollbacks on transactions that failed to start (and therefore cannot execute any commands including rollback).
This PR only implements what's necessary to fix the test, but there's a few more issues around that area I discovered during investigation that I'd like to fix in follow up PRs:
startTransactionin driver adapter interface would accept an optionalAbortSignaland abort starting the transaction on the driver level if it supports it.AbortSignals for the transactions currently starting, and abort them incancelAllTransactions.TransactionExecutionTimeoutErroris incorrect, it must only include the time since the actual start of the transaction.switch (transaction.status)in#startTransactionImpl, TypeScript incorrectly narrows the type oftransactionand the switch is missing theclosingstate (which should throwTransactionInternalConsistencyErrorif detected), see https://prisma-company.slack.com/archives/C058VM009HT/p1764084522869619this.transactions, remove thewaitingstate and makeTransactionWrapper#transactiona non-optional field.Closes: https://linear.app/prisma-company/issue/ORM-1408/failing-issues9678-test-with-qcaccelerate