debezium / debezium/dbz

Close Mysql connection failed on stopping snapshot [DBZ-7911]

Open
#987 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

component/mysql-connector migrated-from-jira type/enhancement
Dominant language
HTML
Stars
6
Forks
9
Avg merge
2d 19h
Merged PRs (30d)
1

Description

Migrated from [DBZ-7911](https://issues.redhat.com/browse/DBZ-7911)

Hi,

 

I use debezium with embeded mode. And recently I found that the Mysql connection failed to close gracefully when I stop the engine which is in snapshot progress.

 

It seems the close connection operation failed on connection rollback stage. But I think there is no need to do rollback operation as the snapshot stage only read data from db.

 

So IMHO we can set the Mysql Connection autoCommit flag to true, so as to skip the rollback operation on close the connection for snapshot.

 

Here is the current code setting the autoCommit flag for snapshot below:
{code:java}
public Connection createSnapshotConnection() throws SQLException {
Connection connection = jdbcConnection.connection();
connection.setAutoCommit(false);
return connection;
} {code}
 

The error log is as shown below.
{code:java}
2024-05-31 11:00:02.211 ERROR,Exception while closing JDBC connection                                                                                                                                                                                              
java.sql.SQLNonTransientConnectionException: Communications link failure during rollback(). Transaction resolution unknown.                                                                                                                                        
        at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:111)                                                                                                                                                                             
        at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:98)                                                                                                                                                                              
        at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:90)                                                                                                                                                                              
        at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:64)                                                                                                                                                                              
        at com.mysql.cj.jdbc.ConnectionImpl.rollback$original$6grSIZml(ConnectionImpl.java:1807)                                                                                                                                                                   
        at com.mysql.cj.jdbc.ConnectionImpl.rollback$original$6grSIZml$accessor$37h7qWO5(ConnectionImpl.java)                                                                                                                                                      
        at com.mysql.cj.jdbc.ConnectionImpl$auxiliary$MwBUxxO7.call(Unknown Source)                                                                                                                                                                                
        at org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstMethodsInter.intercept(InstMethodsInter.java:86)                                                                                                                                    
        at com.mysql.cj.jdbc.ConnectionImpl.rollback(ConnectionImpl.java)                                                                                                                                                                                          
        at com.mysql.cj.jdbc.ConnectionImpl.realClose(ConnectionImpl.java:1667)                                                                                                                                                                                    
        at com.mysql.cj.jdbc.ConnectionImpl.close$original$6grSIZml(ConnectionImpl.java:710)                                                                                                                                                                       
        at com.mysql.cj.jdbc.ConnectionImpl.close$original$6grSIZml$accessor$37h7qWO5(ConnectionImpl.java)                             
        at com.mysql.cj.jdbc.ConnectionImpl$auxiliary$EUx697Cz.call(Unknown Source)                                                                                                                                                                                
        at org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstMethodsInter.intercept(InstMethodsInter.java:86)                                                                                                                                    
        at com.mysql.cj.jdbc.ConnectionImpl.close(ConnectionImpl.java)                                                                                                                                                                                             
        at io.debezium.jdbc.JdbcConnection.lambda$doClose$4(JdbcConnection.java:946)                                                                                                                                                                               
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)                                                                                                                                                                                      
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)                                                                                                                                                               
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)                                                                                                                                                               
        at java.base/java.lang.Thread.run(Thread.java:829)  {code}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating createSnapshotConnection and the JdbcConnection close path referenced at JdbcConnection.java:946. Reproduce stopping an embedded engine during snapshot progress and verify how the MySQL connection handles rollback on close; done means the connection closes without the reported rollback failure and the behavior is covered by an appropriate test.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, mysql
Domain
databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.