From 9e2f58ea9f7571ec6af26536daf464289a751892 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Wed, 30 Jun 2021 18:07:58 +0200 Subject: [PATCH] IdoCheckTask: de-couple MySQL and Postgres schema versions --- lib/db_ido/dbconnection.hpp | 3 ++- lib/db_ido/idochecktask.cpp | 4 ++-- lib/db_ido_mysql/idomysqlconnection.cpp | 5 +++++ lib/db_ido_mysql/idomysqlconnection.hpp | 2 ++ lib/db_ido_pgsql/idopgsqlconnection.cpp | 5 +++++ lib/db_ido_pgsql/idopgsqlconnection.hpp | 2 ++ 6 files changed, 18 insertions(+), 3 deletions(-) diff --git a/lib/db_ido/dbconnection.hpp b/lib/db_ido/dbconnection.hpp index b0c04bd73..f8221e9d2 100644 --- a/lib/db_ido/dbconnection.hpp +++ b/lib/db_ido/dbconnection.hpp @@ -12,7 +12,6 @@ #include #include -#define IDO_CURRENT_SCHEMA_VERSION "1.14.3" #define IDO_COMPAT_SCHEMA_VERSION "1.14.3" namespace icinga @@ -30,6 +29,8 @@ public: static void InitializeDbTimer(); + virtual const char * GetLatestSchemaVersion() const noexcept = 0; + void SetConfigHash(const DbObject::Ptr& dbobj, const String& hash); void SetConfigHash(const DbType::Ptr& type, const DbReference& objid, const String& hash); String GetConfigHash(const DbObject::Ptr& dbobj) const; diff --git a/lib/db_ido/idochecktask.cpp b/lib/db_ido/idochecktask.cpp index 66c5076c6..6a7f0d363 100644 --- a/lib/db_ido/idochecktask.cpp +++ b/lib/db_ido/idochecktask.cpp @@ -140,9 +140,9 @@ void IdoCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResult String schema_version = conn->GetSchemaVersion(); 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: '" - << IDO_CURRENT_SCHEMA_VERSION << "'." + << conn->GetLatestSchemaVersion() << "'." << " Queries per second: " << std::fixed << std::setprecision(3) << qps << " Pending queries: " << std::fixed << std::setprecision(3) << pendingQueries << "."; diff --git a/lib/db_ido_mysql/idomysqlconnection.cpp b/lib/db_ido_mysql/idomysqlconnection.cpp index 4632f4893..b30705479 100644 --- a/lib/db_ido_mysql/idomysqlconnection.cpp +++ b/lib/db_ido_mysql/idomysqlconnection.cpp @@ -21,6 +21,11 @@ using namespace icinga; REGISTER_TYPE(IdoMysqlConnection); REGISTER_STATSFUNCTION(IdoMysqlConnection, &IdoMysqlConnection::StatsFunc); +const char * IdoMysqlConnection::GetLatestSchemaVersion() const noexcept +{ + return "1.14.3"; +} + void IdoMysqlConnection::OnConfigLoaded() { ObjectImpl::OnConfigLoaded(); diff --git a/lib/db_ido_mysql/idomysqlconnection.hpp b/lib/db_ido_mysql/idomysqlconnection.hpp index 851e29d5a..69f3d6134 100644 --- a/lib/db_ido_mysql/idomysqlconnection.hpp +++ b/lib/db_ido_mysql/idomysqlconnection.hpp @@ -37,6 +37,8 @@ public: static void StatsFunc(const Dictionary::Ptr& status, const Array::Ptr& perfdata); + const char * GetLatestSchemaVersion() const noexcept override; + int GetPendingQueryCount() const override; protected: diff --git a/lib/db_ido_pgsql/idopgsqlconnection.cpp b/lib/db_ido_pgsql/idopgsqlconnection.cpp index 858617ce0..4ffa03399 100644 --- a/lib/db_ido_pgsql/idopgsqlconnection.cpp +++ b/lib/db_ido_pgsql/idopgsqlconnection.cpp @@ -23,6 +23,11 @@ REGISTER_TYPE(IdoPgsqlConnection); REGISTER_STATSFUNCTION(IdoPgsqlConnection, &IdoPgsqlConnection::StatsFunc); +const char * IdoPgsqlConnection::GetLatestSchemaVersion() const noexcept +{ + return "1.14.3"; +} + IdoPgsqlConnection::IdoPgsqlConnection() { m_QueryQueue.SetName("IdoPgsqlConnection, " + GetName()); diff --git a/lib/db_ido_pgsql/idopgsqlconnection.hpp b/lib/db_ido_pgsql/idopgsqlconnection.hpp index 0552f3318..2a978bf3d 100644 --- a/lib/db_ido_pgsql/idopgsqlconnection.hpp +++ b/lib/db_ido_pgsql/idopgsqlconnection.hpp @@ -30,6 +30,8 @@ public: static void StatsFunc(const Dictionary::Ptr& status, const Array::Ptr& perfdata); + const char * GetLatestSchemaVersion() const noexcept override; + int GetPendingQueryCount() const override; protected: