-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Comments
能不能这样,只对for update语句进行锁表 |
应该解析select for update时当做是更新语句就可以了
2016-12-08 18:45 GMT+08:00 张哈希 <notifications@github.com>:
… 能不能这样,只对for update语句开始锁表
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#1261 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAcmsbRD3mrmvon8tEa1h6xpSd2DGMZ-ks5rF9_CgaJpZM4LD4u5>
.
|
HashJang
added a commit
to HashJang/Mycat-Server
that referenced
this issue
Dec 9, 2016
已提PR |
magicdoom
added a commit
that referenced
this issue
Dec 9, 2016
[需求](Issues #1261) 解析select for update时当做是更新语句
楼主可以测试验证下看看 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
版本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;
建议,是否可以增加一个配置,开启事务后,是强制锁定链接并走主库,还是直到碰到事务语句后才锁定的选择项。
The text was updated successfully, but these errors were encountered: