mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-27 07:34:15 +02:00
Ido*sqlConnection::Reconnect(): de-couple MySQL and Postgres schema versions
This commit is contained in:
parent
9e2f58ea9f
commit
4373acf8ed
@ -12,8 +12,6 @@
|
|||||||
#include <boost/thread/once.hpp>
|
#include <boost/thread/once.hpp>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
|
||||||
#define IDO_COMPAT_SCHEMA_VERSION "1.14.3"
|
|
||||||
|
|
||||||
namespace icinga
|
namespace icinga
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -30,6 +28,7 @@ public:
|
|||||||
static void InitializeDbTimer();
|
static void InitializeDbTimer();
|
||||||
|
|
||||||
virtual const char * GetLatestSchemaVersion() const noexcept = 0;
|
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);
|
||||||
|
@ -26,6 +26,11 @@ const char * IdoMysqlConnection::GetLatestSchemaVersion() const noexcept
|
|||||||
return "1.14.3";
|
return "1.14.3";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char * IdoMysqlConnection::GetCompatSchemaVersion() const noexcept
|
||||||
|
{
|
||||||
|
return "1.14.3";
|
||||||
|
}
|
||||||
|
|
||||||
void IdoMysqlConnection::OnConfigLoaded()
|
void IdoMysqlConnection::OnConfigLoaded()
|
||||||
{
|
{
|
||||||
ObjectImpl<IdoMysqlConnection>::OnConfigLoaded();
|
ObjectImpl<IdoMysqlConnection>::OnConfigLoaded();
|
||||||
@ -313,13 +318,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."));
|
||||||
|
@ -38,6 +38,7 @@ 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 * GetLatestSchemaVersion() const noexcept override;
|
||||||
|
const char * GetCompatSchemaVersion() const noexcept override;
|
||||||
|
|
||||||
int GetPendingQueryCount() const override;
|
int GetPendingQueryCount() const override;
|
||||||
|
|
||||||
|
@ -28,6 +28,11 @@ const char * IdoPgsqlConnection::GetLatestSchemaVersion() const noexcept
|
|||||||
return "1.14.3";
|
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());
|
||||||
@ -280,13 +285,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."));
|
||||||
|
@ -31,6 +31,7 @@ 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 * GetLatestSchemaVersion() const noexcept override;
|
||||||
|
const char * GetCompatSchemaVersion() const noexcept override;
|
||||||
|
|
||||||
int GetPendingQueryCount() const override;
|
int GetPendingQueryCount() const override;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user