What is a “distributed transaction”?

后端 未结 5 2046
孤独总比滥情好
孤独总比滥情好 2020-12-24 07:19

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

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

相关标签:
5条回答
  • 2020-12-24 07:31

    I have tried to show the distributed transactions details in this post Performance tuning of Distributed ( XA ) transaction - How?

    The good data for distributed transaction is the data that has very high requirement for Consistency. Usually this is money or something else that we can never have stale data. I usually define two categories Live data and data that there is no immediate need for correctness/consistency.

    Now the second part of the question about Dynamo, Bigtable, HBase, or Cassandra.

    You can not draw a paralel in between NOSQL databases and distributed transactions. The very existance of this class of databases is justified as a means of avoiding distributed transactions. Distributed transaction is centered all around consistency. That is quite the opposite with the NOSQL storage which is centered around Availability and Partitioning.

    The usual transactional model used in such databases is Eventual Consistency.

    0 讨论(0)
  • 2020-12-24 07:41

    A distributed transaction is a transaction that works across several computers. Say you start a transaction in some method in a program on computer A. You then make some changes to data in the method on computer A, and afterwords the method calls a web service on computer B. The web service method on computer B fails and rolls the transaction back. Since the transaction is distributed, this means that any changes made on computer A also need to be rolled back. The combination of the distributed transaction coordinator on windows and the .net framework facilitate this functionality.

    0 讨论(0)
  • 2020-12-24 07:48

    Usually, transactions occur on one database server:

    BEGIN TRANSACTION
    SELECT something FROM myTable
    UPDATE something IN myTable
    COMMIT
    

    A distributed transaction involves multiple servers:

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

    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.

    0 讨论(0)
  • 2020-12-24 07:49

    Distributed transactions span multiple physical systems, whereas standard transactions do not. Synchronization amongst the systems becomes a need which traditionally would not exist in a standard transaction.

    From your Wikipedia reference...

    ...a distributed transaction can be seen as a database transaction that must be synchronized (or provide ACID properties) among multiple participating databases which are distributed among different physical locations...

    0 讨论(0)
  • A distributed transaction is a transaction on a distributed database (i.e., one where the data is stored on a number of physically separate systems). It's noteworthy because there's a fair amount of complexity involved (especially in the communications) to assure that all the machines remain in agreement, so either the whole transaction succeeds, or else it appears that nothing happened at all.

    0 讨论(0)
提交回复
热议问题