Added reconnect support for ER_CLIENT_INTERACTION_TIMEOUT

This commit is contained in:
Fredy 2022-05-22 16:37:17 +02:00
parent 1152181b20
commit 91f546a8d7
3 changed files with 3 additions and 0 deletions

View File

@ -1080,6 +1080,7 @@
#define ER_EXPRESSION_REFERS_TO_UNINIT_FIELD 4029
#define ER_PARTITION_DEFAULT_ERROR 4030
#define ER_REFERENCED_TRG_DOES_NOT_EXIST 4031
#define ER_CLIENT_INTERACTION_TIMEOUT 4031 //Since MySQL 8.0.24
#define ER_INVALID_DEFAULT_PARAM 4032
#define ER_BINLOG_NON_SUPPORTED_BULK 4033
#define ER_BINLOG_UNCOMPRESS_ERROR 4034

View File

@ -414,6 +414,7 @@ void Database::runQuery(const std::shared_ptr<IQuery>& query, const std::shared_
unsigned int errorCode = error.getErrorCode();
bool retryableError = errorCode == CR_SERVER_LOST || errorCode == CR_SERVER_GONE_ERROR ||
errorCode == ER_MAX_PREPARED_STMT_COUNT_REACHED || errorCode == ER_UNKNOWN_STMT_HANDLER ||
errorCode == ER_CLIENT_INTERACTION_TIMEOUT ||
errorCode == CR_NO_PREPARE_STMT;
if (retry && retryableError && attemptReconnect()) {
//Need to free statements before retrying in case the connection was lost

View File

@ -232,6 +232,7 @@ void PreparedQuery::executeStatement(Database &database, MYSQL *connection, cons
unsigned int errorCode = error.getErrorCode();
if (errorCode == CR_SERVER_LOST || errorCode == CR_SERVER_GONE_ERROR ||
errorCode == ER_MAX_PREPARED_STMT_COUNT_REACHED || errorCode == ER_UNKNOWN_STMT_HANDLER ||
errorCode == ER_CLIENT_INTERACTION_TIMEOUT ||
errorCode == CR_NO_PREPARE_STMT) {
//In these cases the statement will no longer be valid, free it.
database.freeStatement(this->cachedStatement);