From 91f546a8d7bb20f4624a28195de97edc06dc9ae3 Mon Sep 17 00:00:00 2001 From: Fredy Date: Sun, 22 May 2022 16:37:17 +0200 Subject: [PATCH] Added reconnect support for ER_CLIENT_INTERACTION_TIMEOUT --- MySQL/include/mysqld_error.h | 1 + src/mysql/Database.cpp | 1 + src/mysql/PreparedQuery.cpp | 1 + 3 files changed, 3 insertions(+) diff --git a/MySQL/include/mysqld_error.h b/MySQL/include/mysqld_error.h index 6a42ffc..4d8b8a4 100644 --- a/MySQL/include/mysqld_error.h +++ b/MySQL/include/mysqld_error.h @@ -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 diff --git a/src/mysql/Database.cpp b/src/mysql/Database.cpp index 4a1e529..d6c5a1f 100644 --- a/src/mysql/Database.cpp +++ b/src/mysql/Database.cpp @@ -414,6 +414,7 @@ void Database::runQuery(const std::shared_ptr& 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 diff --git a/src/mysql/PreparedQuery.cpp b/src/mysql/PreparedQuery.cpp index 9772ff8..4ac82b2 100644 --- a/src/mysql/PreparedQuery.cpp +++ b/src/mysql/PreparedQuery.cpp @@ -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);