事务可串行化隔离级别说明
我下面的说法对吗?
Serialized IsolationLevel 中的事务为 select 语句设置读锁。有两笔交易选择了某个范围。两者都获得读锁。但随后第一个事务会在选定范围内更新或添加新值并提交。第二笔交易会发生什么?如果在第一个事务提交后尝试在选定范围内更新或添加值会失败吗?
Am I right in the following?
Transaction in Serializable IsolationLevel sets read locks for select statements. There are two transactions selecting some range. Both get read locks. But then first transaction updates or adds new value inside the selected range and commits. What will happen with the second transaction? Will it fail if tries to update or add value inside selected range after first transaction has commited?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你没有说 RDBMS,所以我假设一个带有
S
和X
锁的简单锁定方案。你说。如果第二个事务已经对该范围具有读锁,则这是不可能的。它必须等到第二个事务释放其锁。如果第二个事务也尝试更新范围,则会导致死锁。
You don't say RDBMS so I am assuming a simple locking scheme with
S
andX
locks. You say.This wouldn't be possible if the second transaction already has a read lock on the range. It would have to wait until the second transaction released its lock. If the second transaction also attempted to update the range then deadlock would result.
是的,第二个事务将会失败,因为第二个事务只会看到事务开始之前提交的数据。
yes, the second transaction will fail because the second transaction will only see datas commited before the begin of the transaction.