What is Distributed Transaction

There is such a demand:

Jamie has two accounts, which are located A, B two databases, Xiao Ming will need funds to B of A in.

How do we achieve?

See if there is a problem to achieve the following manner.

  1. Database connection A, acquires connection connA
  2. connA open transactions
  3. A library funds decreased by 100
  4. Link Library B, acquire connB connection
  5. connB open transactions
  6. B 100 increase library funding
  7. connA.commit()
  8. connB.commit()

The above operation, normally there is no problem.

After step 7 is successful, network problems, step 8 fails to submit the results at this time are: A library funds decreased 100, B library funding has not increased; it is a network problem led to the failure of our business , network factors are uncontrollable factors program, as well as others such as running after to 7, system suddenly loses power, the same result may occur. Resulting in data errors on the business impact is relatively large.

 Distributed transactions can be understood: a business operation, will contain many sub-operations, each sub-business is a separate transaction, we need to consider is how to ensure that these operations are successful child, or have failed.

 

What is the ultimate consistency?

Take the above transfer, a capital A library is reduced, due to network problems, Procedure B connB disconnect the library, resulting in no increase in capital library B; network problem can be restored, if the network is restored, the system can B plus to the capital, so the final data is correct; this time the middle section of the library funds is inconsistent AB ( a decrease of 100 libraries, 100 B library should be increased without increasing the data is inconsistent ), but in the end some point in time the data becomes consistent. Be able to minimize the time inconsistency problem is the system needs to be considered .

Distributed transaction, we can accept inconsistent data within a certain time period, but at some point the final data is consistent.

 

https://www.cnblogs.com/itsoku123/p/10875203.html

 

Guess you like

Origin www.cnblogs.com/ywsheng/p/11262102.html