最近尝试用PostgreSQL写偏序例子,测试opengauss的serializable隔离级别,结果两个事务都成功提交了,opengauss如何解决写偏序问题呢?
create table dots
(
id int not null primary key,
color text not null
);
insert into dots
with x(id) as (select generate_series(1,10))
select id, case when id % 2 = 1 then 'black'
else 'white' end from x;
事务1 : 事务2
start transaction isolation level serializable; start transaction isolation level serializable;
update dots set color = 'black' where color = 'white'; update dots set color = 'white' where color = 'black';
commit;
commit;
如果是PostgreSQL其中有一个事务会失败的,但是opengauss都成功了!
openGauss=# select * from dots;
id | color
----+-------
4 | black
6 | black
8 | black
10 | black
2 | black
3 | white
5 | white
7 | white
9 | white
1 | white
参考:https://wiki.postgresql.org/wiki/SSI#Black_and_White
新大陆软件 秦浩
mobile: 17625988619
e-mail:qinhao@newland.com.cn