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

Add missing tx.Rollback in case of errors #160

Merged
merged 2 commits into from
Jul 31, 2024
Merged

Conversation

majst01
Copy link
Contributor

@majst01 majst01 commented Jul 25, 2024

According to: https://go.dev/doc/database/execute-transactions

Defer the transaction’s rollback. If the transaction succeeds, it will be committed before the function exits, making the deferred rollback call a no-op. If the transaction fails it won’t be committed, meaning that the rollback will be called as the function exits.

With this we can ensure we do not leak transactions which will eventually leak memory

@majst01 majst01 requested a review from a team as a code owner July 25, 2024 07:55
@majst01 majst01 merged commit ae42869 into master Jul 31, 2024
3 checks passed
@majst01 majst01 deleted the ensure-tx-is-closed branch July 31, 2024 08:01
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.

2 participants