[英]Serializable isolation level - does it block read?
I have read that serializable isolation level blocks only: insert, update, delete but NOT read.我只读过可序列化的隔离级别块:插入、更新、删除但不读。
I have run in one window:我已经运行了一个 window:
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;
BEGIN TRANSACTION;
UPDATE [dbo].[Categories]
SET name = 'aaa'
WHERE categoryid = 4;
-- without commit
And in the second window:而在第二个 window 中:
SELECT TOP (1000) [CategoryId]
,[Name]
FROM [dbo].[Categories]
And the above query is waiting for the end of the first query.上面的查询正在等待第一个查询的结束。 So does serialization isolation level block also read?
那么序列化隔离级别块也读吗?
Yes it blocks reads.是的,它会阻止读取。 Your transaction is not committed, so you can still do a rollback.
您的事务未提交,因此您仍然可以进行回滚。 That means the data you have updated should not be read by any other process before you commit.
这意味着在您提交之前,任何其他进程都不应读取您更新的数据。
"does serialization isolation level block also read": No. Serializable acquires some lock (in Ms Sql its shared lock + range lock) which prevents writes from other transactions. “是否还读取序列化隔离级别块”:否。Serializable 获取了一些锁(在 Sql 女士中,它的共享锁 + 范围锁)阻止了其他事务的写入。 Its the UPDATE statement's exclusive lock (the above shared lock now converts to exclusive lock) that prevents second transaction's SELECT (Read Commited or Repeatable Read by deafult depending on db) to wait.
它的 UPDATE 语句的排他锁(上面的共享锁现在转换为排他锁)防止第二个事务的 SELECT (Read Commited or Repeatable Read by deafult 取决于 db)等待。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.