Bug #108643 Commit statement not effect when two params turns on
Submitted: 29 Sep 2022 9:05 Modified: 23 Mar 2023 15:33
Reporter: Qizhi Wang (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / J Severity:S1 (Critical)
Version:all, 8.0.30 OS:Any
Assigned to: CPU Architecture:Any

[29 Sep 2022 9:05] Qizhi Wang
Description:
1. This bug will emerge when `useLocalTransactionState` and `rewriteBatchedStatements` both are `true`.
2. The transaction will not commit.

How to repeat:
Just run the unit test `testBug89948` of `mysql-connector-j`.

Or if you want a code to prove it, you can follow by:

1. Install MySQL
2. Clone this code: https://github.com/Icemap/tidb-java-gitpod/tree/reproduction-local-transaction-state-txn-e...
4. Point JDBC URL: https://github.com/Icemap/tidb-java-gitpod/blob/reproduction-local-transaction-state-txn-e... to MySQL host.
5. Run `mvn clean package && java -jar target/tidb-java-gitpod-0.0.1-jar-with-dependencies.jar`.
6. Check the data of the `testBug89948` table, the data has gone.
[29 Sep 2022 9:18] MySQL Verification Team
Hello Qizhi Wang,

Thank you for the report and test case.

regards,
Umesh
[10 Jan 2023 0:06] Filipe Silva
Possible duplicate Bug#109013.
[23 Mar 2023 15:33] Daniel So
Posted by developer:
 
Added the following entry to the C/J 8.0.33 changelog: 

"When both the connection properties useLocalTransactionState and rewriteBatchedStatements were set to true, prepared statements could not be committed. It was because Connector/J lost check of the transaction statuses of the internal statements in the case, and this patch corrects the problem."
[4 Apr 2023 17:29] Daniel So
Posted by developer:
 
Updated the changelog entry to the following: 

"When both the connection properties useLocalTransactionState and rewriteBatchedStatements were set to true, prepared statements could not be committed. It was because Connector/J lost track of the transaction statuses of the statements created internally to run the rewritten queries, and this patch corrects the problem. "