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 savepoint support #20710

Merged
merged 2 commits into from
Apr 24, 2020
Merged

Add savepoint support #20710

merged 2 commits into from
Apr 24, 2020

Conversation

roji
Copy link
Member

@roji roji commented Apr 21, 2020

  • Add APIs for supporting transaction savepoints.
  • Support is implemented at the EF level only, no System.Data support yet (this should come soon).
  • Use savepoints in the update pipeline when a user-managed transaction is used, to roll back to before SaveChanges in case of exception.

Some notes:

  • See SaveChanges_uses_explicit_transaction_with_failure_behavior for how savepoints help with SaveChanges failures.
  • Another good example is Database_concurrency_token_value_is_discarded_for_non_conflicting_entities, which isn't needed anymore because the entire SaveChanges is rolled back if any conflict occurs. I wonder if we should still have a test for this - this may require an escape hatch flag that allows running without savepoints even if the provider supports them (but I'm not sure where someone would use that).
  • This currently implements everything in EF Core, without any System.Data support (Expose transaction savepoints in ADO.NET runtime#33397). When that makes it in, I'll replace the default implementation in RelationalTransaction to delegate to that.
  • We should have logging for savepoints like other things, but we can wait for the System.Data implementation to put them into the default implementation. Same for interceptors.
  • AFAICT ambient transactions (System.Transactions) don't support savepoints. You can have multiple nested scopes, but that's just a vote for committing the top-level scope.

Part of #20176

@roji roji requested a review from AndriySvyryd April 21, 2020 20:12
@roji
Copy link
Member Author

roji commented Apr 21, 2020

/cc @ajcvickers

roji added 2 commits April 24, 2020 17:16
* Add APIs for supporting transaction savepoints.
* Support is implemented at the EF level only, no System.Data support
  yet (this should come soon).
* Use savepoints in the update pipeline when a user-managed transaction
  is used, to roll back to before SaveChanges in case of exception.

Part of #20176
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.

3 participants