当前位置:网站首页>What is distributed transaction

What is distributed transaction

2022-06-22 07:50:00 Hard working ant [if you]

What is business

​ Database transactions ( abbreviation : Business ,Transaction) A logical unit in the execution of a database , It consists of a limited sequence of database operations [ It consists of multiple different operations of the current business logic ]. Transactions have the following four characteristics , It's used to be called ACID characteristic :1) Atomicity (Atomicity): The transaction is executed as a whole , The operations on the database contained in it are either all performed , Either not .2) Uniformity (Consistency): Transactions should ensure that the state of the database changes from one consistent state to another . Consistent state means that the data in the database should meet the integrity constraints . besides , Consistency has another layer of semantics , The intermediate state of a transaction cannot be observed ( It is also said that this layer of semantics should belong to atomicity ).3) Isolation, (Isolation): When multiple transactions are executed concurrently , The execution of one transaction should not affect the execution of other transactions , As if only this operation is being performed by the database .4) persistence (Durability): Changes made to the database by committed transactions should be persisted in the database . At the end of the transaction , This operation will be irreversible .

What is a local transaction

​ In a traditional single project , Transactions are limited to access control to a single database resource , After the service of Architecture , The concept of transactions extends to services . If we take a single service operation as a transaction , Then the whole service operation can only involve a single database resource , This kind of transaction is based on single service and single database resource access , It's called local affairs (Local Transaction). If the user orders an interface , It will involve inventory reduction 、 Add order .
 Insert picture description here
Operating on the same database , Transaction control is possible , All or nothing , All or nothing .

What is distributed transaction

​ Distributed transaction refers to the participants of transaction 、 Servers that support transactions 、 Resource servers and transaction managers are located on different nodes of different distributed systems , And it's a different application , Distributed transactions need to ensure that either all of these operations succeed , All or nothing .

 Insert picture description here
After distribution , There will be multiple databases , Multiple service communication , Such as : The inventory service was successfully executed , After deducting inventory , But the order service database hung up , The order cannot be added , This will lead to inconsistent data , Things will lose their meaning , Data cannot be rolled back based on other nodes .

 Insert picture description here
And in response to this phenomenon , In essence , Distributed transaction is to ensure the data consistency of different databases .

原网站

版权声明
本文为[Hard working ant [if you]]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/173/202206220737173052.html