These are chat archives for petabridge/akka-bootcamp

27th
Jul 2015
Suhas Chatekar
@schatekar
Jul 27 2015 15:59 UTC
I have a question on two phased commit and Akka, is this the right place to ask the question?
Aaron Stannard
@Aaronontheweb
Jul 27 2015 17:05 UTC
@schatekar yep, you can ask here or in the akka.net gitter chat room
Suhas Chatekar
@schatekar
Jul 27 2015 20:48 UTC
@Aaronontheweb How would actor system handle two phase commit situation. For example, lets assume that I am building an order fulfilment back-end for retail system. When an order is placed, I would need to do two things, one is to enter the order details into the orders table(s). Second, update the inventory. Now if I go by actor principle, then I would model these two operations as two different actors. When the first actor succeeds and updates the database but second actor fails, how do I go back and rollback the changes done by the first actor. I understand that you make the second actor retry but for the sake of argument lets say that the error is non-recoverable and our only option is to rollback the changes made by the first actor. I am not sure if this even a valid scenario in the context of actor model
Bartosz Sypytkowski
@Horusiath
Jul 27 2015 21:04 UTC
@schatekar in general transactions in distributed system are hard to achieve and often cripple performance. Therefore things such as Event Sourcing and patterns like Saga and Compensating Action have been made. Microsoft has a quick lecture on Sagas.
Suhas Chatekar
@schatekar
Jul 27 2015 21:38 UTC
@Horusiath I understand event sourcing but have never used it myself and hence not fully convinced that event sourcing is the solution. I would read the saga lecture from Microsoft
Aaron Stannard
@Aaronontheweb
Jul 27 2015 23:11 UTC
@schatekar yeah, @Horusiath has the right idea. Distributed transactions are evil.
many developers jump right to that as the solution to their consistency problems (hey, it worked on one server, why wouldn't it work on two?)
but it's ultimately not a scalable or cost-feasible approach to achieving satisfactory consistency in most areas
that's why Microsoft still spends millions of dollars each year researching how to do them :p
you're better off using an eventually consistent mechanism like eventsourcing or sagas
there's other tools out there too, beyond just those two
CRDTs are my personal favorite
they turn this problem into a datastructure problem and not an algorithm problem
but they don't work for every possible situation