Skip to content
New issue

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

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

Already on GitHub? # to your account

柔性事务中autocommit问题及fail重试问题 #122

Closed
flym opened this issue Jul 17, 2016 · 2 comments
Closed

柔性事务中autocommit问题及fail重试问题 #122

flym opened this issue Jul 17, 2016 · 2 comments

Comments

@flym
Copy link

flym commented Jul 17, 2016

我查看到代码

AbstractSoftTransaction#beginInternal中
previousAutoCommit = connection.getAutoCommit();
connection.setAutoCommit(true);

这里的设置为自动提交模式是什么意思?
我查看过SoftTransactionTest#bedSoftTransactionTest
这里的conn对象为实际执行业务语句的对象,这里反而设置为自动提交模式,不就是让业务代码自动提交了.那业务中的事务回滚如何处理?

同时,在best事务实现中,以下代码:

                        conn = bedSoftTransaction.getConnection().getConnection(event.getDataSource(), SQLStatementType.SELECT);
                        if (!isValidConnection(conn)) {
                            conn = bedSoftTransaction.getConnection();
                            isNewConnection = true;
                        }

这里本意是新开连接, 如何体现出来? 由于 ShardingConnection#connectionMap对象的存在,这里将conn回到shardconn并不会导致连接被重建
按照sql标准来说,如果原连接本身不可用(如网络中断),则应该直接中断事务,而不是重试.因为原来的连接中执行的代码本身就被破坏了.

@hanahmily
Copy link
Contributor

这是两个问题:
1.对于autocommit强制设置为true的意思是:柔性事务是一个事务框架,对于bed来说就是重试,所以设置为true是合理的,对于tcc来说,try confirm 和 cancel每一步都是一句sql,且执行完成就需要提交。故这里设置autocommit为true;

2.第二个确实是个bug,感谢!

@bwzhang2011
Copy link

@hanahmily, 这个BUG下个版本(1.3.2)能否修复啊

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

3 participants