✅ Distributed transactions
I'm developing a server + clients suite of applications.
What bothers me is the chance that the client's communication with the server will be interrupted during writes.
Primarily during several interdependent writes, e.g.:
- Create an empty record,
- insert data into the record,
- mark the record as checked-in.
Of course, the simplest thing would be to unify all such processes into one API call, but what if it can be done in smarter way...
I found something about 2PC and SAGA, however, these solutions are tailor-made for microservices, which from my point of view is not quite my case.
I only have client applications that call the server as part of some business process - I can more easily monitor the scope of transactions within the given process.
The goal is that in the event of a technical or business failure, it is possible to:
- Capture, report to the user, and log
- Perform a rollback.
Any suggestions?
9 Replies
"What bothers me is the chance that the client's communication with the server will be interrupted during writes."
Do you mean that the connection times out due to writes?
What exactly is a "write", is it to disk?
without more information or my lack of knowledge I can only suggest (based on several ways of interpreting the issue):
1) kinda like you've already mentioned making the whole thing a single operation
2) introduce a locking mechanism
3) blockchain depending on your system
So are you asking for alternatives to 2pc and saga?
Performing a rollback is more in line with compensating transactions, what is the ecosystem this runs in?
I mean that the server dies, the connection is interrupted physically, or an unexpected exception is thrown
By write I mean any write operation in general, but let's say it's a SQL database supporting transactions
Please clarify what is meant by ecosystem?
The server is an ASP.NET Core application exposing an gRPC API. The clients are whatever connects to said API. However, I think this isn't quite relevant
Is it all corporate environment with AAD or?
The product is installed on prem. It can find itself in a corporate environment or a small business with barely any IT.
Not sure how this is relevant though
You could use something like Orleans
Orleans overview - .NET
An introduction to .NET Orleans.
It's an actor framework, which is in line with what you're describing
I was curious about the operational ecosystem, is this desktop and server apps, like winforms, or a web client.
I've only used orleans inside corporate networks or in web scenarios. I'm always a bit leery of recommending tech without knowing the operational ecosystem.
Thank you for the suggestion! I'll check it out