MyCATApache / Mycat-Server

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

close jdbc connection, found it is in transcation so try to rollback

noaso opened this issue · comments

commented

1、bug描述
总报 "close jdbc connection, found it is in transcation so try to rollback

调用这个的时候 idleCon.close("too many idle con");
看了下源码。在close方法
if (!isAutocommit()) { rollback(); con.setAutoCommit(true); }
@Override public void rollback() { try { con.rollback(); this.respHandler.okResponse(OkPacket.OK, this); } catch (SQLException e) { throw new RuntimeException(e); } }
这里 respHandler 是 null;

idleCon.close("too many idle con");
idleCon是从 ManCommitCons取的,这个队列的offer在release中,这里把ResponseHandler设置成了null.

public void release() { modifiedSQLExecuted = false; setResponseHandler(null); pool.releaseChannel(this); }

2、版本号(非常重要)
v 1.6.7.6/20220524101549

打印了一下 rollback的 JDBCConnection信息,attachement =null,modifiedSQLExecuted=false 没太看懂。
不知道这种链接rollback后 对实际数据有影响没。
JDBCConnection [id=943,autocommit=false,pool=io.mycat.backend.jdbc.JDBCDatasource@76b01630, schema=xxxxx_275, dbType=MYSQL, oldSchema=xxxxx_275, packetId=30, txIsolation=0, running=false, borrowed=false, host=xxxxxxxx, port=3306, con=com.mysql.cj.jdbc.ConnectionImpl@15a4ddb2, respHandler=null, attachement=null, headerOutputed=false, modifiedSQLExecuted=false, startTime=1658410472471, lastTime=1658410518958, isSpark=false, processor=io.mycat.net.NIOProcessor@43e6beff]