Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.4-1.6 select for update 未锁定链接 #1261

Closed
Duntian opened this issue Dec 5, 2016 · 4 comments
Closed

1.4-1.6 select for update 未锁定链接 #1261

Duntian opened this issue Dec 5, 2016 · 4 comments

Comments

@Duntian
Copy link

Duntian commented Dec 5, 2016

版本1.4-1.6
Mycat-server-1.4-release-20151019230038-linux.tar

Mycat-server-1.6-RELEASE-20161012170031-linux.tar

在一个事务中
begin
select * from a where id=1 for update ;
update b set col=1 ;
select * from c;
commit;

其中第二个语句不会锁定连接,导致for update锁不上表。

改成:
begin
update b set col=1 ;
select * from a where id=1 for update ;
select * from c;
commit;

可以正常锁表

是因为mycat在这些版本中做了优化,开启事务后,直到碰到真正的事务操作才会锁定链接,而不是只要开启事务,就一定锁定链接并走向主库。

但是在select for update 时未能处理。

相同的问题,还有Oracle的序列,在开启事务后,取序列,由于不是强制走主库,会走到从库取,结果就报错了
例:
begin
select seq_a.nextval from dual ;
insert into xxxx
commit;

建议,是否可以增加一个配置,开启事务后,是强制锁定链接并走主库,还是直到碰到事务语句后才锁定的选择项。

@HashJang
Copy link
Contributor

HashJang commented Dec 8, 2016

能不能这样,只对for update语句进行锁表

@magicdoom
Copy link
Contributor

magicdoom commented Dec 8, 2016 via email

@HashJang
Copy link
Contributor

HashJang commented Dec 9, 2016

已提PR

magicdoom added a commit that referenced this issue Dec 9, 2016
[需求](Issues #1261) 解析select for update时当做是更新语句
@magicdoom
Copy link
Contributor

楼主可以测试验证下看看

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants