2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-09-02 06:55:16 +00:00

[3780] MySQL and Postgres lease managers now exit on fatal error detection

src/lib/dhcpsrv/dhcpsrv_messages.mes
    added messages DHCPSRV_MYSQL_FATAL_ERROR, DHCPSRV_PGSQL_FATAL_ERROR

src/lib/dhcpsrv/mysql_lease_mgr.cc
    added MySQL client error code include

    MySqlLeaseMgr::checkError() - method is no longer inlined in
    the header.  Expanded to detect unrecoverable errors, log
    them and call exit().

src/lib/dhcpsrv/mysql_lease_mgr.h
    Removed inline implemenation of MySqlLeaseMgr::checkError(),
    and expanded commentary

src/lib/dhcpsrv/pgsql_lease_mgr.cc
    PgSqlLeaseMgr::addLeaseCommon() - now uses checkStatementError()

    PgSqlLeaseMgr::checkStatementError() - Expanded to detect
    unrecoverable errors, log them and call exit().

src/lib/dhcpsrv/pgsql_lease_mgr.h
    Expanded commentary for PgSqlLeaseMgr::checkStatementError()
This commit is contained in:
Thomas Markwalder
2015-10-23 16:41:27 -04:00
parent 360b740097
commit be964a2b42
5 changed files with 94 additions and 18 deletions

View File

@@ -669,8 +669,22 @@ private:
/// @brief Check Error and Throw Exception
///
/// Virtually all MySQL functions return a status which, if non-zero,
/// indicates an error. This inline function conceals a lot of error
/// checking/exception-throwing code.
/// indicates an error. This function centralizes the error checking
/// code.
///
/// It is used to determine whether or not the function succeeded, and
/// in the event of failures, decide whether or not those failures are
/// recoverable.
///
/// If the error is recoverable, the method will throw a DbOperationError.
/// In the error is deemed unrecoverable, such as a loss of connectivity
/// with the server, this method will log the error and call exit(-1);
///
/// @todo Calling exit() is viewed as a short term solution for Kea 1.0.
/// Two tickets are likely to alter this behavior, first is #3639, which
/// calls for the ability to attempt to reconnect to the database. The
/// second ticket, #4087 which calls for the implementation of a generic,
/// FatalException class which will propagate outward.
///
/// @param status Status code: non-zero implies an error
/// @param index Index of statement that caused the error
@@ -678,15 +692,8 @@ private:
///
/// @throw isc::dhcp::DbOperationError An operation on the open database has
/// failed.
inline void checkError(int status, StatementIndex index,
const char* what) const {
if (status != 0) {
isc_throw(DbOperationError, what << " for <" <<
conn_.text_statements_[index] << ">, reason: " <<
mysql_error(conn_.mysql_) << " (error code " <<
mysql_errno(conn_.mysql_) << ")");
}
}
void checkError(int status, StatementIndex index,
const char* what) const;
// Members