-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Mon 153321 mariadb connection with errno0 24.10 (#1884)
* fix(broker/sql): two issues in the mysql object * A possible segfault fixed. * An issue on errors raised by mariadb that can have errno=0 now. * enh(tests): new tests on database connection * enh(tests): new test that can lead to a segfault with the mysql object * fix(cmake): missing dependency on pb_neb_lib REFS: MON-153321
- Loading branch information
Showing
7 changed files
with
355 additions
and
32 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 |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
* For more information : [email protected] | ||
*/ | ||
#include <errmsg.h> | ||
#include <mysqld_error.h> | ||
|
||
#include "com/centreon/broker/config/applier/init.hh" | ||
#include "com/centreon/broker/misc/misc.hh" | ||
|
@@ -460,18 +461,26 @@ void mysql_connection::_statement(mysql_task* t) { | |
"mysql_connection {:p}: execute statement {:x} attempt {}: {}", | ||
static_cast<const void*>(this), task->statement_id, attempts, query); | ||
if (mysql_stmt_execute(stmt)) { | ||
std::string err_msg( | ||
fmt::format("{} errno={} {}", mysql_error::msg[task->error_code], | ||
::mysql_errno(_conn), ::mysql_stmt_error(stmt))); | ||
SPDLOG_LOGGER_ERROR(_logger, | ||
"connection fail to execute statement {:p}: {}", | ||
static_cast<const void*>(this), err_msg); | ||
if (_server_error(::mysql_stmt_errno(stmt))) { | ||
int32_t err_code = ::mysql_stmt_errno(stmt); | ||
std::string err_msg(fmt::format("{} errno={} {}", | ||
mysql_error::msg[task->error_code], | ||
err_code, ::mysql_stmt_error(stmt))); | ||
if (err_code == 0) { | ||
SPDLOG_LOGGER_ERROR(_logger, | ||
"mysql_connection: errno=0, so we simulate a " | ||
"server error CR_SERVER_LOST"); | ||
err_code = CR_SERVER_LOST; | ||
} else { | ||
SPDLOG_LOGGER_ERROR(_logger, | ||
"connection fail to execute statement {:p}: {}", | ||
static_cast<const void*>(this), err_msg); | ||
} | ||
if (_server_error(err_code)) { | ||
set_error_message(err_msg); | ||
break; | ||
} | ||
if (mysql_stmt_errno(stmt) != 1213 && | ||
mysql_stmt_errno(stmt) != 1205) // Dead Lock error | ||
if (err_code != ER_LOCK_DEADLOCK && | ||
err_code != ER_LOCK_WAIT_TIMEOUT) // Dead Lock error | ||
attempts = MAX_ATTEMPTS; | ||
|
||
if (mysql_commit(_conn)) { | ||
|
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
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
Oops, something went wrong.
b7df296
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Robot Results
Failed Tests
Bench