mirror of https://github.com/Icinga/icinga2.git
Merge pull request #8855 from Icinga/bugfix/inconsistent-ido-schema-versions-8852
Fix IDO MySQL schema version (as in v2.11 upgrade)
This commit is contained in:
commit
b63eb2aa3d
|
@ -12,9 +12,6 @@
|
||||||
#include <boost/thread/once.hpp>
|
#include <boost/thread/once.hpp>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
|
||||||
#define IDO_CURRENT_SCHEMA_VERSION "1.14.3"
|
|
||||||
#define IDO_COMPAT_SCHEMA_VERSION "1.14.3"
|
|
||||||
|
|
||||||
namespace icinga
|
namespace icinga
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -30,6 +27,9 @@ public:
|
||||||
|
|
||||||
static void InitializeDbTimer();
|
static void InitializeDbTimer();
|
||||||
|
|
||||||
|
virtual const char * GetLatestSchemaVersion() const noexcept = 0;
|
||||||
|
virtual const char * GetCompatSchemaVersion() const noexcept = 0;
|
||||||
|
|
||||||
void SetConfigHash(const DbObject::Ptr& dbobj, const String& hash);
|
void SetConfigHash(const DbObject::Ptr& dbobj, const String& hash);
|
||||||
void SetConfigHash(const DbType::Ptr& type, const DbReference& objid, const String& hash);
|
void SetConfigHash(const DbType::Ptr& type, const DbReference& objid, const String& hash);
|
||||||
String GetConfigHash(const DbObject::Ptr& dbobj) const;
|
String GetConfigHash(const DbObject::Ptr& dbobj) const;
|
||||||
|
|
|
@ -140,9 +140,9 @@ void IdoCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResult
|
||||||
String schema_version = conn->GetSchemaVersion();
|
String schema_version = conn->GetSchemaVersion();
|
||||||
std::ostringstream msgbuf;
|
std::ostringstream msgbuf;
|
||||||
|
|
||||||
if (Utility::CompareVersion(IDO_CURRENT_SCHEMA_VERSION, schema_version) < 0) {
|
if (Utility::CompareVersion(conn->GetLatestSchemaVersion(), schema_version) < 0) {
|
||||||
msgbuf << "Outdated schema version: '" << schema_version << "'. Latest version: '"
|
msgbuf << "Outdated schema version: '" << schema_version << "'. Latest version: '"
|
||||||
<< IDO_CURRENT_SCHEMA_VERSION << "'."
|
<< conn->GetLatestSchemaVersion() << "'."
|
||||||
<< " Queries per second: " << std::fixed << std::setprecision(3) << qps
|
<< " Queries per second: " << std::fixed << std::setprecision(3) << qps
|
||||||
<< " Pending queries: " << std::fixed << std::setprecision(3) << pendingQueries << ".";
|
<< " Pending queries: " << std::fixed << std::setprecision(3) << pendingQueries << ".";
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,16 @@ using namespace icinga;
|
||||||
REGISTER_TYPE(IdoMysqlConnection);
|
REGISTER_TYPE(IdoMysqlConnection);
|
||||||
REGISTER_STATSFUNCTION(IdoMysqlConnection, &IdoMysqlConnection::StatsFunc);
|
REGISTER_STATSFUNCTION(IdoMysqlConnection, &IdoMysqlConnection::StatsFunc);
|
||||||
|
|
||||||
|
const char * IdoMysqlConnection::GetLatestSchemaVersion() const noexcept
|
||||||
|
{
|
||||||
|
return "1.15.0";
|
||||||
|
}
|
||||||
|
|
||||||
|
const char * IdoMysqlConnection::GetCompatSchemaVersion() const noexcept
|
||||||
|
{
|
||||||
|
return "1.14.3";
|
||||||
|
}
|
||||||
|
|
||||||
void IdoMysqlConnection::OnConfigLoaded()
|
void IdoMysqlConnection::OnConfigLoaded()
|
||||||
{
|
{
|
||||||
ObjectImpl<IdoMysqlConnection>::OnConfigLoaded();
|
ObjectImpl<IdoMysqlConnection>::OnConfigLoaded();
|
||||||
|
@ -303,13 +313,13 @@ void IdoMysqlConnection::Reconnect()
|
||||||
|
|
||||||
SetSchemaVersion(version);
|
SetSchemaVersion(version);
|
||||||
|
|
||||||
if (Utility::CompareVersion(IDO_COMPAT_SCHEMA_VERSION, version) < 0) {
|
if (Utility::CompareVersion(GetCompatSchemaVersion(), version) < 0) {
|
||||||
m_Mysql->close(&m_Connection);
|
m_Mysql->close(&m_Connection);
|
||||||
SetConnected(false);
|
SetConnected(false);
|
||||||
|
|
||||||
Log(LogCritical, "IdoMysqlConnection")
|
Log(LogCritical, "IdoMysqlConnection")
|
||||||
<< "Schema version '" << version << "' does not match the required version '"
|
<< "Schema version '" << version << "' does not match the required version '"
|
||||||
<< IDO_COMPAT_SCHEMA_VERSION << "' (or newer)! Please check the upgrade documentation at "
|
<< GetCompatSchemaVersion() << "' (or newer)! Please check the upgrade documentation at "
|
||||||
<< "https://icinga.com/docs/icinga2/latest/doc/16-upgrading-icinga-2/#upgrading-mysql-db";
|
<< "https://icinga.com/docs/icinga2/latest/doc/16-upgrading-icinga-2/#upgrading-mysql-db";
|
||||||
|
|
||||||
BOOST_THROW_EXCEPTION(std::runtime_error("Schema version mismatch."));
|
BOOST_THROW_EXCEPTION(std::runtime_error("Schema version mismatch."));
|
||||||
|
|
|
@ -37,6 +37,9 @@ public:
|
||||||
|
|
||||||
static void StatsFunc(const Dictionary::Ptr& status, const Array::Ptr& perfdata);
|
static void StatsFunc(const Dictionary::Ptr& status, const Array::Ptr& perfdata);
|
||||||
|
|
||||||
|
const char * GetLatestSchemaVersion() const noexcept override;
|
||||||
|
const char * GetCompatSchemaVersion() const noexcept override;
|
||||||
|
|
||||||
int GetPendingQueryCount() const override;
|
int GetPendingQueryCount() const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -1660,7 +1660,7 @@ CREATE INDEX idx_comments_remove ON icinga_comments (object_id, entry_time);
|
||||||
-- -----------------------------------------
|
-- -----------------------------------------
|
||||||
-- set dbversion
|
-- set dbversion
|
||||||
-- -----------------------------------------
|
-- -----------------------------------------
|
||||||
INSERT INTO icinga_dbversion (name, version, create_time, modify_time) VALUES ('idoutils', '1.14.3', NOW(), NOW())
|
INSERT INTO icinga_dbversion (name, version, create_time, modify_time) VALUES ('idoutils', '1.15.0', NOW(), NOW())
|
||||||
ON DUPLICATE KEY UPDATE version='1.14.3', modify_time=NOW();
|
ON DUPLICATE KEY UPDATE version='1.15.0', modify_time=NOW();
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,16 @@ REGISTER_TYPE(IdoPgsqlConnection);
|
||||||
|
|
||||||
REGISTER_STATSFUNCTION(IdoPgsqlConnection, &IdoPgsqlConnection::StatsFunc);
|
REGISTER_STATSFUNCTION(IdoPgsqlConnection, &IdoPgsqlConnection::StatsFunc);
|
||||||
|
|
||||||
|
const char * IdoPgsqlConnection::GetLatestSchemaVersion() const noexcept
|
||||||
|
{
|
||||||
|
return "1.14.3";
|
||||||
|
}
|
||||||
|
|
||||||
|
const char * IdoPgsqlConnection::GetCompatSchemaVersion() const noexcept
|
||||||
|
{
|
||||||
|
return "1.14.3";
|
||||||
|
}
|
||||||
|
|
||||||
IdoPgsqlConnection::IdoPgsqlConnection()
|
IdoPgsqlConnection::IdoPgsqlConnection()
|
||||||
{
|
{
|
||||||
m_QueryQueue.SetName("IdoPgsqlConnection, " + GetName());
|
m_QueryQueue.SetName("IdoPgsqlConnection, " + GetName());
|
||||||
|
@ -270,13 +280,13 @@ void IdoPgsqlConnection::Reconnect()
|
||||||
|
|
||||||
SetSchemaVersion(version);
|
SetSchemaVersion(version);
|
||||||
|
|
||||||
if (Utility::CompareVersion(IDO_COMPAT_SCHEMA_VERSION, version) < 0) {
|
if (Utility::CompareVersion(GetCompatSchemaVersion(), version) < 0) {
|
||||||
m_Pgsql->finish(m_Connection);
|
m_Pgsql->finish(m_Connection);
|
||||||
SetConnected(false);
|
SetConnected(false);
|
||||||
|
|
||||||
Log(LogCritical, "IdoPgsqlConnection")
|
Log(LogCritical, "IdoPgsqlConnection")
|
||||||
<< "Schema version '" << version << "' does not match the required version '"
|
<< "Schema version '" << version << "' does not match the required version '"
|
||||||
<< IDO_COMPAT_SCHEMA_VERSION << "' (or newer)! Please check the upgrade documentation at "
|
<< GetCompatSchemaVersion() << "' (or newer)! Please check the upgrade documentation at "
|
||||||
<< "https://icinga.com/docs/icinga2/latest/doc/16-upgrading-icinga-2/#upgrading-postgresql-db";
|
<< "https://icinga.com/docs/icinga2/latest/doc/16-upgrading-icinga-2/#upgrading-postgresql-db";
|
||||||
|
|
||||||
BOOST_THROW_EXCEPTION(std::runtime_error("Schema version mismatch."));
|
BOOST_THROW_EXCEPTION(std::runtime_error("Schema version mismatch."));
|
||||||
|
|
|
@ -30,6 +30,9 @@ public:
|
||||||
|
|
||||||
static void StatsFunc(const Dictionary::Ptr& status, const Array::Ptr& perfdata);
|
static void StatsFunc(const Dictionary::Ptr& status, const Array::Ptr& perfdata);
|
||||||
|
|
||||||
|
const char * GetLatestSchemaVersion() const noexcept override;
|
||||||
|
const char * GetCompatSchemaVersion() const noexcept override;
|
||||||
|
|
||||||
int GetPendingQueryCount() const override;
|
int GetPendingQueryCount() const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
Loading…
Reference in New Issue