sql: transactions that enter the "aborted" state due to SQL-level errors should relinquish locks #140234
Labels
branch-release-20.1
Used to mark GA and release blockers, technical advisories, and bugs for 20.1
branch-release-20.2
Used to mark GA and release blockers, technical advisories, and bugs for 20.2
branch-release-21.1
Used to mark GA and release blockers, technical advisories, and bugs for 21.1
branch-release-21.2
Used to mark GA and release blockers, technical advisories, and bugs for 21.2
branch-release-22.1
Used to mark GA and release blockers, technical advisories, and bugs for 22.1
branch-release-22.2
Used to mark GA and release blockers, technical advisories, and bugs for 22.2
branch-release-23.1
Used to mark GA and release blockers, technical advisories, and bugs for 23.1
branch-release-23.2
Used to mark GA and release blockers, technical advisories, and bugs for 23.2
branch-release-24.1
Used to mark GA and release blockers, technical advisories, and bugs for 24.1
branch-release-24.2
Used to mark GA and release blockers, technical advisories, and bugs for 24.2
branch-release-24.3
Used to mark GA and release blockers, technical advisories, and bugs for 24.3
branch-release-25.1
C-enhancement
Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)
T-sql-foundations
SQL Foundations Team (formerly SQL Schema + SQL Sessions)
Since 719b702, which added support for savepoints, SQL-level errors that cause a transaction to enter the "aborted" state do not cause the transaction to end or rollback. As a result, any locks acquired in the transaction prior to the error remain held, blocking concurrent queries.
Here's an example:
Once the transaction enters the "aborted" state, I believe it can never successfully commit, so holding the locks has no benefit and increases the chance of contention. This may only be true for transactions without savepoints—we should think through all possible cases here.
This creates some major rough edges with the
transaction_timeout
session setting. The docs state about this setting:The name of the setting and this description make it sound like
transaction_timeout
is the perfect safeguard against a misbehaving application that fails to commit or rollback a transaction. However, due to the behavior described above, it actually provides no additional safety—while the transaction will be automatically aborted, any locks acquired will remain held and will not be released until the connection is closed.Here's an example:
Jira issue: CRDB-47066
The text was updated successfully, but these errors were encountered: