MongoDB 的两阶段提交 [英] Two Phase Commit with MongoDB

查看:50
本文介绍了MongoDB 的两阶段提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这就是我的想法.当使用 MongoDB 之类的每个操作都是原子操作并且不支持除此之外的事务时,您是否发现这种模拟 2 阶段提交的解决方法有任何问题?

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 或任何从命令处理程序基础结构管理外部事务范围的东西.从我看来,我们应该具有与 2pc 几乎相同的语义 - 但我觉得我错过了一些东西.

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.

推荐答案

A 二-phase commit wiki 页面 最近已添加到 mongodb 网站.它描述了 2-PC 算法并讨论了一些失败场景.

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.

这篇关于MongoDB 的两阶段提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆