MongoDB 中的两阶段提交 [英] Two phase commit in MongoDB

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

问题描述

仔细阅读在线文档,我仍然有很多关于MongoDB中两阶段提交的问题.

Having carefully reading the online documentation, I still have a lot of questions about two phase commit in MongoDB.

从故障场景中恢复部分,为什么只有两类故障?在我看来,这些步骤中的任何一步都可能发生失败,因此这里应该有两个以上的类.例如,如果(在将交易应用到两个帐户部分),在更新帐户 A 后,数据库服务器失败了.这意味着账户 A 损失了一些钱,而账户 B 没有发生任何事情.我们会出现不一致的交易吗?

In the section Recovering from Failure Scenarios, why are there only two classes of failures? In my thinking failure can happen in any of these step so there should be a lot more than two classes here. For example what if, (in Apply Transaction to Both Accounts section), after updating account A the database server failed. That means account A lost some money without anything happen on account B. And we would have inconsistent transaction?

推荐答案

在我看来,这些步骤中的任何一步都可能发生失败,因此这里应该有两个以上的类.

In my thinking failure can happen in any of these step so there should be a lot more than two classes here.

这里要记住的关键是该文档不是关于两阶段提交的权威指南,实际上两阶段提交在 MongoDB 中在技术上是不可能的,如果你想执行它们,我强烈建议你获得 ACID 技术.

The key thing to remember here is that the documentation is NOT a definitive guide on two phase commits, in reality two phase commits are technically impossible in MongoDB and I would strongly recommend you get an ACID tech if you want to perform them.

您必须记住,由于不在服务器本身内,您无法应对某些失败情况.相反,两阶段提交的整个存在只是客户端,因此与 TTL 监控相比,它非常脆弱.

You must remember that there are certain fail scenarios that you cannot counter due to this not being within the server itself. Instead the whole existance of two phase commits is only client side as such it is quite flimsy compared to say TTL monitoring.

更新帐户 A 后,数据库服务器出现故障.这意味着账户 A 损失了一些钱,而账户 B 没有发生任何事情.我们会出现不一致的交易吗?

after updating account A the database server failed. That means account A lost some money without anything happen on account B. And we would have inconsistent transaction?

为了支持 Philipps 回答,在这种情况下,帐户 A 和 B 之间的原始交易仍将处于待处理状态,只有在帐户 B 更新后才会将其移至完成/完成.

In support of Philipps answer the original transaction between account A and B would still be pending in this case, it will only be moved to finished/completed once account B has been updated.

这意味着事务在完成之前不能被标记为完成.

This means the transaction cannot be marked as completed until it is.

我建议使用专为您的场景设计的东西,而不是将 MongoDB 用于它不是真正设计的场景.

Instead of using MongoDB for a scenario that it isn't really designed for I would recommend using something that is designed for your scenario.

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

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