什么是“分布式交易"? [英] What is a "distributed transaction"?

查看:377
本文介绍了什么是“分布式交易"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有关 分布式事务 的Wikipedia文章不是很有帮助

The Wikipedia article for Distributed transaction isn't very helpful.

您能对什么是分布式事务进行高级描述吗?

Can you give a high-level description of what a distributed transaction is?

还可以举例说明为什么应用程序或数据库应该执行更新两台或更多台联网计算机上的数据的事务吗?我了解经典的银行例子;我更关心Web规模的数据库(如Dynamo,Bigtable,HBase或Cassandra)中的分布式事务.

Also, can you give an example of why an application or database should perform a transaction that updates data on two or more networked computers? I understood the classic bank example; I care more about distributed transactions in Web-scale databases like Dynamo, Bigtable, HBase, or Cassandra.

推荐答案

通常,事务在一个数据库服务器上发生:

Usually, transactions occur on one database server:

BEGIN TRANSACTION
SELECT something FROM myTable
UPDATE something IN myTable
COMMIT

分布式事务涉及多个服务器:

BEGIN TRANSACTION
UPDATE amount = amount - 100 IN bankAccounts WHERE accountNr = 1
UPDATE amount = amount + 100 IN someRemoteDatabaseAtSomeOtherBank.bankAccounts WHERE accountNr = 2
COMMIT

困难来自以下事实:服务器必须进行通信,以确保两个服务器上都满足诸如 atomicity 之类的事务属性:如果事务成功,则值必须在两台服务器上进行更新.如果事务失败,则必须在两个服务器上回滚事务.永远不要发生这样的情况:在一台服务器上更新值,而在另一台服务器上不更新.

The difficulty comes from the fact that the servers must communicate to ensure that transactional properties such as atomicity are satisfied on both servers: If the transaction succeeds, the values must be updated on both servers. If the transaction fails, the transaction must be rollbacked on both servers. It must never happen that the values are updated on one server but not updated on the other.

这篇关于什么是“分布式交易"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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