Ash*_*win 3 postgresql transaction isolation-level
我有这张桌子
create table testing(
c1 text,
c2 text);
Run Code Online (Sandbox Code Playgroud)
我同时打开两笔交易。t0 t1..表示按递增顺序排列的一系列时间快照 事务 1
BEGIN; -- t0
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE; -- t2
SELECT * FROM testing where c2 = 'rand'; -- t4
INSERT INTO testing VALUES ('rand', 'xyz'); -- t6
COMMIT; -- t8
Run Code Online (Sandbox Code Playgroud)
交易2
BEGIN; -- t1
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE; -- t3
SELECT * FROM testing where c1 = 'rand1'; -- t5
INSERT INTO testing VALUES ('rand1', 'abc'); -- t7
COMMIT; -- t9
Run Code Online (Sandbox Code Playgroud)
t9当我收到这个错误
后ERROR: could not serialize access due to read/write dependencies among transactions
DETAIL: Reason code: Canceled on identification as a pivot, during commit attempt.
HINT: The transaction might succeed if retried.
但如果您看到这些语句,它们会根据不同的值rand和进行操作rand1。抛出这个错误是没有意义的,因为它们永远不会处于糟糕的状态。
我的理解正确吗?
| 归档时间: |
|
| 查看次数: |
4696 次 |
| 最近记录: |