事务的理解

2018-05-21 11:39:26 +08:00
 helloworld12

下面这条要怎么理解:

• 隔离性 (Isolation):一个事务的执行不能被其他事务干扰。

假设有一个事务是: A 账号向 B 账号汇钱

然后另一个事务是: A 账号向 C 账号汇钱

但是 A 的钱只够给一个人汇款, 这样,不是相互干扰了?

1280 次点击
所在节点    问与答
4 条回复
hubqin
2018-05-21 12:52:15 +08:00
看事务的原子性,并不干扰,这里`A 的余额减少,B 的余额增加`为一个`原子`,要么整个成功,要么整个失败滚回。A 向 C 转账,余额不足,这个事务滚回不进行任何操作。
MiffyLiye
2018-05-21 13:30:42 +08:00
"Isolation in the sense of ACID means that concurrently executing transactions are isolated from each other: they cannot step on each other ’ s toes. The classic database textbooks formalize isolation as serializability, which means that each transaction can pretend that it is the only transaction running on the entire database. "
当然现实世界大部分数据库默认的隔离级别并不保证可序列化。
f2f2f
2018-05-21 13:32:08 +08:00
所以事务有优先级啊,也有加锁啊。
helloworld12
2018-05-21 13:47:06 +08:00
@f2f2f 加锁了, 不就意味着干扰了?

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/456452

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX