-
Notifications
You must be signed in to change notification settings - Fork 590
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix for Bug#104067 (33054827), No reset autoCommit after unknown issu…
…e occurs.
- Loading branch information
Showing
3 changed files
with
78 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,6 +70,7 @@ | |
import com.mysql.cj.conf.PropertyDefinitions.DatabaseTerm; | ||
import com.mysql.cj.conf.PropertyKey; | ||
import com.mysql.cj.conf.RuntimeProperty; | ||
import com.mysql.cj.exceptions.CJCommunicationsException; | ||
import com.mysql.cj.exceptions.CJException; | ||
import com.mysql.cj.exceptions.ExceptionFactory; | ||
import com.mysql.cj.exceptions.ExceptionInterceptor; | ||
|
@@ -2017,10 +2018,10 @@ void forEach(ConnectionLifecycleInterceptor each) throws SQLException { | |
this.autoReconnect.setValue(true); | ||
} | ||
|
||
boolean isAutocommit = this.session.getServerSession().isAutocommit(); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
fjssilva
Author
Contributor
|
||
try { | ||
boolean needsSetOnServer = true; | ||
|
||
if (this.useLocalSessionState.getValue() && this.session.getServerSession().isAutoCommit() == autoCommitFlag) { | ||
if (this.useLocalSessionState.getValue() && isAutocommit == autoCommitFlag) { | ||
needsSetOnServer = false; | ||
} else if (!this.autoReconnect.getValue()) { | ||
needsSetOnServer = getSession().isSetNeededForAutoCommitMode(autoCommitFlag); | ||
|
@@ -2035,6 +2036,13 @@ void forEach(ConnectionLifecycleInterceptor each) throws SQLException { | |
this.session.execSQL(null, autoCommitFlag ? "SET autocommit=1" : "SET autocommit=0", -1, null, false, this.nullStatementResultSetFactory, | ||
null, false); | ||
} | ||
} catch (CJCommunicationsException e) { | ||
throw e; | ||
} catch (CJException e) { | ||
// Reset to current autocommit value in case of an exception different than a communication exception occurs. | ||
this.session.getServerSession().setAutoCommit(isAutocommit); | ||
// Update the stacktrace. | ||
throw SQLError.createSQLException(e.getMessage(), e.getSQLState(), e.getVendorCode(), e.isTransient(), e, getExceptionInterceptor()); | ||
} finally { | ||
if (this.autoReconnectForPools.getValue()) { | ||
this.autoReconnect.setValue(false); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
possible mistype. should have been isAutoCommit() not isAutocommit(). would be nice if methods were named differently.