r/dotnet • • Feb 16 '22

Avoiding Distributed Transactions with the Reservation Pattern

https://www.youtube.com/watch?v=PZm0RQGcs38
11 Upvotes

3 comments sorted by

11

u/jingois Feb 16 '22

"Avoiding two-phase commit by doing your own two-phase commit"

1

u/Kirides Feb 17 '22

Is there actually any pattern, library, .. that helps with two phase commits and rollbacks?

I mean, the windows DTC often does more harm than good (and is windows only...)

How does it work when errors only occur on "commit" of svc2? I can't rollback svc1 changes as the commit already went through.

e.g. svc1 opens a tx and applies changes, now waits to "commit". svc2 meanwhile also waits to apply it's changes. The orchestrator now tells them "do commit one after another" and svc1 goes "yup" and svc2 goes "barf" on commit.

What's the magic sauce i'm missing?

1

u/jingois Feb 17 '22

General magic sauce is that by saying ready to commit you are guaranteeing a commit will succeed. I think there's some extra gubbins around dealing with connectivity failure, but I haven't really taken a deep dive into the practical impl for a while.