Skip to content

Conversation

@kevincox
Copy link
Contributor

@kevincox kevincox commented Aug 18, 2025

Previously if the transaction was dropped while the transaction was being set up it was possible that the transaction was successfully opened but not closed. In common usage this would result in returning an open transaction to the connection pool which would have unexpected effects ranging from errors due to trying to nest transaction or serious bugs such as intended changes not occurring as they were unexpectedly inside a transaction that would never commit.

This resolves the issue by constructing the Transaction object (which activates the drop handler) before starting to open the transaction. In the worst case this could result in trying to ROLLBACK a transaction that was never started but this just results in a harmless error which is much better than leaving an unexpected open transaction active on the connection.

Fixes: #3932

Is this a breaking change?

No. While the changed behaviour is observable it relies on exact future poll timing and would almost certainly be undesirable to trigger intentionally.

Previously if the transaction was dropped while the transaction was being set up it was possible that the transaction was successfully opened but not closed. In common usage this would result in returning an open transaction to the connection pool which would have unexpected effects ranging from errors due to trying to nest transaction or serious bugs such as intended changes not occurring as they were unexpectedly inside a transaction that would never commit.

This resolves the issue by constructing the `Transaction` object (which activates the drop handler) before starting to open the transaction. In the worst case this could result in trying to `ROLLBACK` a transaction that was never started but this just results in a harmless error which is much better than leaving an unexpected open transaction active on the connection.

Fixes: launchbadge#3932
@kevincox kevincox marked this pull request as ready for review August 18, 2025 16:46
@abonander abonander merged commit ce878ce into launchbadge:main Aug 18, 2025
92 checks passed
@kevincox kevincox deleted the tx-drop branch August 18, 2025 23:20
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.

sqlite transaction creation is not error or drop-safe.

2 participants