first of all, what’s transaction?
it a set of SQL statements that follows ACID principles.
ACID is the principle of transaction, like SQL.
atomic: do it or don‘t do at all
consistency: data needs to be consistent after we did the transaction
isolation: when one transaction is working, no other transaction can bother it.
durability: the committed data never gets lost even the system failure or needs to start…
what’s distributed transactions?
it’s an idea with the development of microservice
分布式事务使得实现ACID变得更难了。但是不代表不可以,还记得之前的two phrase吗?preparing phrasing and commit phrase.我们需要一个distributed transaction coordinator.
我们有CAP理论 主要用于NoSQL 分别是consistency, avalibliity, partition tolerance.这个理论说三者不能共存。既然我们是distrubited了已经 说明我们在CA之间只能娶一个。所以分布式事务只能折中。
而且 这种折中还不是简单的折中 说只取一个。因为当分区故障的时候 我们还要保证CA。
解决方案:
BASE:
Basic Availbility,(系统故障 可以损失部分可用性)’
Soft state.(不要求atom了 可以有中间状态)
Eventually consistency(all data needs to be eventually consistence, don’t have to be instantly)
总结一下:
ACID for normal transaction
CAP is meant for distribute transaction but can’t, so use BASE.