Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollback nested transactions by restarting the parent where possible #44526

Merged
merged 3 commits into from
Feb 28, 2022

Conversation

matthewd
Copy link
Member

This allows us to simulate an immediately-nested transaction without ever needing to begin or commit the child: those operations are no-ops, and we need only run a command if the child rolls back.

Further, we can use a single query to implement that rollback: where the parent is a savepoint, the standard behaviour is to roll back to immediately after the savepoint was set. Where the parent is a top-level transaction, most databases support ROLLBACK AND CHAIN.

It's not a common operation, but still, no point running two queries
when one will do.
This allows us to simulate an immediately-nested transaction without
ever needing to begin or commit the child: those operations are no-ops,
and we need only run a command if the child rolls back.

Further, we can use a single query to implement that rollback: where the
parent is a savepoint, the standard behaviour is to roll back to
immediately _after_ the savepoint was set. Where the parent is a
top-level transaction, most databases support ROLLBACK AND CHAIN.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant