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

Handle.afterCommit: if callback throws after we've already committed, don't rollback #2479

Merged
merged 2 commits into from
Aug 31, 2023

Conversation

stevenschlansker
Copy link
Member

Fixes #2478

@stevenschlansker stevenschlansker requested a review from a team August 28, 2023 22:55
@stevenschlansker stevenschlansker changed the title Handle.afterCommit: if callback throws after we've already committed, don't rollback Draft: Handle.afterCommit: if callback throws after we've already committed, don't rollback Aug 28, 2023
@stevenschlansker stevenschlansker removed the request for review from a team August 28, 2023 23:40
@stevenschlansker stevenschlansker marked this pull request as draft August 28, 2023 23:40
replace the three booleans with a simple state machine:

1) "OUTSIDE_TRANSACTION" -- begin(Handle) --> "AFTER_BEGIN".
   Idempotent operation, can be called many times.

2) "AFTER_BEGIN" -- inTransaction(Handle) --> "OUTSIDE_TRANSACTION".
    Wraps the SQL operation, executes it and then commits or rolls back.
    Goes through an intermediate state "IN_TRANSACTION" that only exists
    between the begin of the SQL operation and commit/rollback

3) "AFTER_BEGIN" | "IN_TRANSACTION" -- commit(Handle) | rollback(Handle) --> "OUTSIDE_TRANSACTION".
   Either operation move the state back to the initial state and restore the auto commit state.
   Calling rollback() after commit() has no effect.
@sonarcloud
Copy link

sonarcloud bot commented Aug 29, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

Copy link
Member Author

@stevenschlansker stevenschlansker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I cannot approve my own MR, but this looks good to go to me. Thanks.

@stevenschlansker stevenschlansker marked this pull request as ready for review August 31, 2023 18:09
@stevenschlansker stevenschlansker changed the title Draft: Handle.afterCommit: if callback throws after we've already committed, don't rollback Handle.afterCommit: if callback throws after we've already committed, don't rollback Aug 31, 2023
@stevenschlansker stevenschlansker merged commit 6b79aad into master Aug 31, 2023
37 checks passed
@stevenschlansker stevenschlansker deleted the handle-afterCommit-throws branch August 31, 2023 18:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants