Two Phase Commit with MongoDB

那年仲夏 提交于 2021-02-08 05:01:15

问题


Heres what Im thinking. Do you see any issues with this workaround to emulate 2 phase commit when using something like MongoDB where each operation is atomic and there is no support for transactions outside of that?

transaction_scope:
     read message from servicebus - UpdateCustomerAddress

     get customer aggregate from docdb, replay events where commited =1

     call customer.updateAddress
         validates
         creates customer address updated event
         apply event
         event store as uncommitted events

     do optimistic concurrency update against docdb pushing uncommitted events (single op                  to ensure consistency)

     publish event to service bus 

     update docdb set events just published to commited = 1 (again one 1 op - at least in    mongodb)

transaction_complete

NServiceBus or whatever manages outer transaction scope from the command handler infrastucture. From what I see we should have near same semantics of 2pc - but I feel Im missing something.


回答1:


A two-phase commit wiki page has recently been added to the mongodb website. It describes the 2-PC algorithm and discusses a few failure scenarios.



来源:https://stackoverflow.com/questions/2716582/two-phase-commit-with-mongodb

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!