fix: wrap updateRecords with bigTransactionTimeout like createRecords#2668
Open
dkindlund wants to merge 1 commit intoteableio:developfrom
Open
fix: wrap updateRecords with bigTransactionTimeout like createRecords#2668dkindlund wants to merge 1 commit intoteableio:developfrom
dkindlund wants to merge 1 commit intoteableio:developfrom
Conversation
The `updateRecords` method in RecordOpenApiService calls
`recordModifyService.updateRecords` directly without wrapping it in a
`$tx` block with an explicit timeout. This means it falls back to the
Prisma default transaction timeout (5 seconds or PRISMA_TRANSACTION_TIMEOUT
env var), rather than using the application's configured
`bigTransactionTimeout` (10 minutes by default).
In contrast, both `multipleCreateRecords` and `createRecords` already
wrap their calls with `{ timeout: this.thresholdConfig.bigTransactionTimeout }`.
This inconsistency causes update operations on records with large link
fields (e.g., thousands of many-to-many links) to fail with Prisma error
P2028 (transaction timeout) even though the operation would complete
within the application's intended timeout window.
This fix wraps `updateRecords` in `this.prismaService.$tx()` with the
same `bigTransactionTimeout` option used by the create methods, ensuring
consistent timeout behavior across all record mutation operations.
Note: `updateRecord` (singular) delegates to `updateRecords` (plural),
so this fix covers both single and batch update operations.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Bug Description
RecordOpenApiService.updateRecordscallsrecordModifyService.updateRecordsdirectly without wrapping it in aprismaService.$tx()block with an explicit timeout. This means update operations fall back to the Prisma default transaction timeout (5 seconds, or thePRISMA_TRANSACTION_TIMEOUTenv var), rather than using the application-configuredbigTransactionTimeout(10 minutes by default viaBIG_TRANSACTION_TIMEOUT).In contrast, both
multipleCreateRecords(line 58) andcreateRecords(line 117) already wrap their calls with{ timeout: this.thresholdConfig.bigTransactionTimeout }.This inconsistency causes update operations on records with large link fields (e.g., hundreds or thousands of many-to-many links) to time out, even though the same operation volume succeeds for create operations.
Steps to Reproduce
PRISMA_TRANSACTION_TIMEOUT=5000(default) or leave unsetExpected Behavior
Update operations should use the same
bigTransactionTimeoutas create operations, ensuring consistent timeout behavior across all record mutation operations.What This Fix Does
Wraps
updateRecordsinthis.prismaService.$tx()with{ timeout: this.thresholdConfig.bigTransactionTimeout }, matching the pattern already used bymultipleCreateRecordsandcreateRecords.updateRecord(singular) delegates toupdateRecords(plural), so this fix covers both single and batch update operations.Client Information
Platform
Docker standalone (Google Cloud Run)
Additional Context
This was discovered while investigating a JSONB/junction desync issue in a production deployment. A record with 602 many-to-many links could not be updated because the junction table operations exceeded the default 5-second transaction timeout, even though the deployment had set PRISMA_TRANSACTION_TIMEOUT=60000. The bigTransactionTimeout (configured at 10 minutes) would have been more than sufficient.