-// File created from ../../../src/lib/dhcpsrv/dhcpsrv_messages.mes on Thu Dec 05 2019 16:13
+// File created from ../../../src/lib/dhcpsrv/dhcpsrv_messages.mes on Tue May 19 2020 19:04
#include <cstddef>
#include <log/message_types.h>
extern const isc::log::MessageID DHCPSRV_MYSQL_HOST_DB = "DHCPSRV_MYSQL_HOST_DB";
extern const isc::log::MessageID DHCPSRV_MYSQL_HOST_DB_GET_VERSION = "DHCPSRV_MYSQL_HOST_DB_GET_VERSION";
extern const isc::log::MessageID DHCPSRV_MYSQL_HOST_DB_READONLY = "DHCPSRV_MYSQL_HOST_DB_READONLY";
+extern const isc::log::MessageID DHCPSRV_MYSQL_NEGATIVE_LEASES_STAT = "DHCPSRV_MYSQL_NEGATIVE_LEASES_STAT";
extern const isc::log::MessageID DHCPSRV_MYSQL_ROLLBACK = "DHCPSRV_MYSQL_ROLLBACK";
extern const isc::log::MessageID DHCPSRV_MYSQL_START_TRANSACTION = "DHCPSRV_MYSQL_START_TRANSACTION";
extern const isc::log::MessageID DHCPSRV_MYSQL_UPDATE_ADDR4 = "DHCPSRV_MYSQL_UPDATE_ADDR4";
extern const isc::log::MessageID DHCPSRV_PGSQL_HOST_DB = "DHCPSRV_PGSQL_HOST_DB";
extern const isc::log::MessageID DHCPSRV_PGSQL_HOST_DB_GET_VERSION = "DHCPSRV_PGSQL_HOST_DB_GET_VERSION";
extern const isc::log::MessageID DHCPSRV_PGSQL_HOST_DB_READONLY = "DHCPSRV_PGSQL_HOST_DB_READONLY";
+extern const isc::log::MessageID DHCPSRV_PGSQL_NEGATIVE_LEASES_STAT = "DHCPSRV_PGSQL_NEGATIVE_LEASES_STAT";
extern const isc::log::MessageID DHCPSRV_PGSQL_ROLLBACK = "DHCPSRV_PGSQL_ROLLBACK";
extern const isc::log::MessageID DHCPSRV_PGSQL_START_TRANSACTION = "DHCPSRV_PGSQL_START_TRANSACTION";
extern const isc::log::MessageID DHCPSRV_PGSQL_UPDATE_ADDR4 = "DHCPSRV_PGSQL_UPDATE_ADDR4";
"DHCPSRV_MYSQL_HOST_DB", "opening MySQL hosts database: %1",
"DHCPSRV_MYSQL_HOST_DB_GET_VERSION", "obtaining schema version information for the MySQL hosts database",
"DHCPSRV_MYSQL_HOST_DB_READONLY", "MySQL host database opened for read access only",
+ "DHCPSRV_MYSQL_NEGATIVE_LEASES_STAT", "recount of leases returned a negative value",
"DHCPSRV_MYSQL_ROLLBACK", "rolling back MySQL database",
"DHCPSRV_MYSQL_START_TRANSACTION", "starting new MySQL transaction",
"DHCPSRV_MYSQL_UPDATE_ADDR4", "updating IPv4 lease for address %1",
"DHCPSRV_PGSQL_HOST_DB", "opening PostgreSQL hosts database: %1",
"DHCPSRV_PGSQL_HOST_DB_GET_VERSION", "obtaining schema version information for the PostgreSQL hosts database",
"DHCPSRV_PGSQL_HOST_DB_READONLY", "PostgreSQL host database opened for read access only",
+ "DHCPSRV_PGSQL_NEGATIVE_LEASES_STAT", "recount of leases returned a negative value",
"DHCPSRV_PGSQL_ROLLBACK", "rolling back PostgreSQL database",
"DHCPSRV_PGSQL_START_TRANSACTION", "starting a new PostgreSQL transaction",
"DHCPSRV_PGSQL_UPDATE_ADDR4", "updating IPv4 lease for address %1",
-// File created from ../../../src/lib/dhcpsrv/dhcpsrv_messages.mes on Thu Dec 05 2019 16:13
+// File created from ../../../src/lib/dhcpsrv/dhcpsrv_messages.mes on Tue May 19 2020 19:04
#ifndef DHCPSRV_MESSAGES_H
#define DHCPSRV_MESSAGES_H
extern const isc::log::MessageID DHCPSRV_MYSQL_HOST_DB;
extern const isc::log::MessageID DHCPSRV_MYSQL_HOST_DB_GET_VERSION;
extern const isc::log::MessageID DHCPSRV_MYSQL_HOST_DB_READONLY;
+extern const isc::log::MessageID DHCPSRV_MYSQL_NEGATIVE_LEASES_STAT;
extern const isc::log::MessageID DHCPSRV_MYSQL_ROLLBACK;
extern const isc::log::MessageID DHCPSRV_MYSQL_START_TRANSACTION;
extern const isc::log::MessageID DHCPSRV_MYSQL_UPDATE_ADDR4;
extern const isc::log::MessageID DHCPSRV_PGSQL_HOST_DB;
extern const isc::log::MessageID DHCPSRV_PGSQL_HOST_DB_GET_VERSION;
extern const isc::log::MessageID DHCPSRV_PGSQL_HOST_DB_READONLY;
+extern const isc::log::MessageID DHCPSRV_PGSQL_NEGATIVE_LEASES_STAT;
extern const isc::log::MessageID DHCPSRV_PGSQL_ROLLBACK;
extern const isc::log::MessageID DHCPSRV_PGSQL_START_TRANSACTION;
extern const isc::log::MessageID DHCPSRV_PGSQL_UPDATE_ADDR4;
host reservations but will be able to retrieve existing ones and
assign them to the clients communicating with the server.
+% DHCPSRV_MYSQL_NEGATIVE_LEASES_STAT recount of leases returned a negative value
+This warning message is issued when the recount of leases using counters
+in the MySQL database returned a negative value. This shows a problem
+which can be fixed only by an offline direct recount on the database.
+This message is issued only once.
+
% DHCPSRV_MYSQL_ROLLBACK rolling back MySQL database
The code has issued a rollback call. All outstanding transaction will
be rolled back and not committed to the database.
host reservations but will be able to retrieve existing ones and
assign them to the clients communicating with the server.
+% DHCPSRV_PGSQL_NEGATIVE_LEASES_STAT recount of leases returned a negative value
+This warning message is issued when the recount of leases using counters
+in the PostgreSQL database returned a negative value. This shows a problem
+which can be fixed only by an offline direct recount on the database.
+This message is issued only once.
+
% DHCPSRV_PGSQL_ROLLBACK rolling back PostgreSQL database
The code has issued a rollback call. All outstanding transaction will
be rolled back and not committed to the database.
bind_[col].is_unsigned = MLM_TRUE;
++col;
- // state_count_: uint32_t
+ // state_count_: int64_t
bind_[col].buffer_type = MYSQL_TYPE_LONGLONG;
bind_[col].buffer = reinterpret_cast<char*>(&state_count_);
- bind_[col].is_unsigned = MLM_TRUE;
+ //bind_[col].is_unsigned = MLM_FALSE;
// Set up the MYSQL_BIND array for the data being returned
// and bind it to the statement.
/// result set rows. Once the last row has been fetched, subsequent
/// calls will return false.
///
+ /// Checks against negative values for the state count and logs once
+ /// a warning message. Unfortunately not getting the message is not
+ /// a proof that detailed counters are correct.
+ ///
/// @param row Storage for the fetched row
///
/// @return True if the fetch succeeded, false if there are no more
row.subnet_id_ = static_cast<SubnetID>(subnet_id_);
row.lease_type_ = static_cast<Lease::Type>(lease_type_);
row.lease_state_ = state_;
- row.state_count_ = state_count_;
+ if (state_count_ >= 0) {
+ row.state_count_ = state_count_;
+ } else {
+ row.state_count_ = 0;
+ if (!negative_count_) {
+ negative_count_ = true;
+ LOG_WARN(dhcpsrv_logger, DHCPSRV_MYSQL_NEGATIVE_LEASES_STAT);
+ }
+ }
have_row = true;
} else if (status != MYSQL_NO_DATA) {
conn_.checkError(status, statement_index_, "getNextRow failed");
/// @brief Receives the state count when fetching a row
int64_t state_count_;
+
+ /// @brief Received negative state count showing a problem
+ static bool negative_count_;
};
+// Initialize negative state count flag to false.
+bool MySqlLeaseStatsQuery::negative_count_ = false;
+
// MySqlLeaseContext Constructor
MySqlLeaseContext::MySqlLeaseContext(const DatabaseConnection::ParameterMap& parameters)
/// result set rows. Once the last row has been fetched, subsequent
/// calls will return false.
///
+ /// Checks against negative values for the state count and logs once
+ /// a warning message. Unfortunately not getting the message is not
+ /// a proof that detailed counters are correct.
+ ///
/// @param row Storage for the fetched row
///
/// @return True if the fetch succeeded, false if there are no more
PgSqlExchange::getColumnValue(*result_set_, next_row_, col,
row.state_count_);
+ // Protect against negative state count.a
+ if (row.state_count_ < 0) {
+ row.state_count_ = 0;
+ if (!negative_count_) {
+ negative_count_ = true;
+ LOG_WARN(dhcpsrv_logger, DHCPSRV_PGSQL_NEGATIVE_LEASES_STAT);
+ }
+ }
+
// Point to the next row.
++next_row_;
return (true);
/// @brief Indicates if query supplies lease type
bool fetch_type_;
+
+ /// @brief Received negative state count showing a problem
+ static bool negative_count_;
};
+// Initialize negative state count flag to false.
+bool PgSqlLeaseStatsQuery::negative_count_ = false;
+
// PgSqlLeaseContext Constructor
PgSqlLeaseContext::PgSqlLeaseContext(const DatabaseConnection::ParameterMap& parameters)