- 论坛徽章:
- 0
|
这个要使用RS的隔离级别(中间件服务器默认隔离级别是RS,需要检查一下),并且用select for update。
Read Stability
Read Stability (RS) locks only those rows that an application retrieves within a unit of work. It ensures that any qualifying row read during a unit of work is not changed by other application processes until the unit of work completes, and that any row changed by another application process is not read until the change is committed by that process.
场景1:
session1:
db2 +c "select * from table where id=3 with rs for update"; --如果默认是RS,则不用加 with rs
session2:
db2 +c "select * from table where id=3 with rs for update";
这个时候如果我们用db2pd -wlocks可以看到,session2正在等待session1的行级U锁。
|
|