]> granicus.if.org Git - icinga2/commitdiff
DB IDO: Don't enqueue queries when the feature is paused (HA)
authorMichael Friedrich <michael.friedrich@icinga.com>
Tue, 30 Oct 2018 12:17:28 +0000 (13:17 +0100)
committerMichael Friedrich <michael.friedrich@icinga.com>
Tue, 13 Nov 2018 11:01:50 +0000 (12:01 +0100)
fixes #5876
refs #6739

lib/db_ido_mysql/idomysqlconnection.cpp
lib/db_ido_pgsql/idopgsqlconnection.cpp

index 1a13b89cc28843b95af81ed633c2213604b6454b..9bbbeb0df42e1bdec7d18826d433fe65d7d3620d 100644 (file)
@@ -162,6 +162,9 @@ void IdoMysqlConnection::TxTimerHandler()
 
 void IdoMysqlConnection::NewTransaction()
 {
+       if (IsPaused())
+               return;
+
 #ifdef I2_DEBUG /* I2_DEBUG */
        Log(LogDebug, "IdoMysqlConnection")
                << "Scheduling new transaction and finishing async queries.";
@@ -715,6 +718,9 @@ void IdoMysqlConnection::DiscardRows(const IdoMysqlResult& result)
 
 void IdoMysqlConnection::ActivateObject(const DbObject::Ptr& dbobj)
 {
+       if (IsPaused())
+               return;
+
 #ifdef I2_DEBUG /* I2_DEBUG */
        Log(LogDebug, "IdoMysqlConnection")
                << "Scheduling object activation task for '" << dbobj->GetName1() << "!" << dbobj->GetName2() << "'.";
@@ -727,6 +733,9 @@ void IdoMysqlConnection::InternalActivateObject(const DbObject::Ptr& dbobj)
 {
        AssertOnWorkQueue();
 
+       if (IsPaused())
+               return;
+
        if (!GetConnected())
                return;
 
@@ -754,6 +763,9 @@ void IdoMysqlConnection::InternalActivateObject(const DbObject::Ptr& dbobj)
 
 void IdoMysqlConnection::DeactivateObject(const DbObject::Ptr& dbobj)
 {
+       if (IsPaused())
+               return;
+
 #ifdef I2_DEBUG /* I2_DEBUG */
        Log(LogDebug, "IdoMysqlConnection")
                << "Scheduling object deactivation task for '" << dbobj->GetName1() << "!" << dbobj->GetName2() << "'.";
@@ -766,6 +778,9 @@ void IdoMysqlConnection::InternalDeactivateObject(const DbObject::Ptr& dbobj)
 {
        AssertOnWorkQueue();
 
+       if (IsPaused())
+               return;
+
        if (!GetConnected())
                return;
 
@@ -855,6 +870,9 @@ bool IdoMysqlConnection::FieldToEscapedString(const String& key, const Value& va
 
 void IdoMysqlConnection::ExecuteQuery(const DbQuery& query)
 {
+       if (IsPaused())
+               return;
+
        ASSERT(query.Category != DbCatInvalid);
 
 #ifdef I2_DEBUG /* I2_DEBUG */
@@ -867,6 +885,9 @@ void IdoMysqlConnection::ExecuteQuery(const DbQuery& query)
 
 void IdoMysqlConnection::ExecuteMultipleQueries(const std::vector<DbQuery>& queries)
 {
+       if (IsPaused())
+               return;
+
        if (queries.empty())
                return;
 
@@ -914,6 +935,9 @@ void IdoMysqlConnection::InternalExecuteMultipleQueries(const std::vector<DbQuer
 {
        AssertOnWorkQueue();
 
+       if (IsPaused())
+               return;
+
        if (!GetConnected())
                return;
 
@@ -942,6 +966,9 @@ void IdoMysqlConnection::InternalExecuteQuery(const DbQuery& query, int typeOver
 {
        AssertOnWorkQueue();
 
+       if (IsPaused())
+               return;
+
        if (!GetConnected())
                return;
 
@@ -1129,6 +1156,9 @@ void IdoMysqlConnection::FinishExecuteQuery(const DbQuery& query, int type, bool
 
 void IdoMysqlConnection::CleanUpExecuteQuery(const String& table, const String& time_column, double max_age)
 {
+       if (IsPaused())
+               return;
+
 #ifdef I2_DEBUG /* I2_DEBUG */
                Log(LogDebug, "IdoMysqlConnection")
                        << "Rescheduling cleanup query for table '" << table << "' and column '"
@@ -1142,6 +1172,9 @@ void IdoMysqlConnection::InternalCleanUpExecuteQuery(const String& table, const
 {
        AssertOnWorkQueue();
 
+       if (IsPaused())
+               return;
+
        if (!GetConnected())
                return;
 
index 96cf08c1399a7806fe8ece24228f7b572aad6b8d..4724ab707172b778d5f8d544955954b65868d01f 100644 (file)
@@ -163,6 +163,9 @@ void IdoPgsqlConnection::TxTimerHandler()
 
 void IdoPgsqlConnection::NewTransaction()
 {
+       if (IsPaused())
+               return;
+
        m_QueryQueue.Enqueue(std::bind(&IdoPgsqlConnection::InternalNewTransaction, this), PriorityHigh, true);
 }
 
@@ -569,6 +572,9 @@ Dictionary::Ptr IdoPgsqlConnection::FetchRow(const IdoPgsqlResult& result, int r
 
 void IdoPgsqlConnection::ActivateObject(const DbObject::Ptr& dbobj)
 {
+       if (IsPaused())
+               return;
+
        m_QueryQueue.Enqueue(std::bind(&IdoPgsqlConnection::InternalActivateObject, this, dbobj), PriorityLow);
 }
 
@@ -603,6 +609,9 @@ void IdoPgsqlConnection::InternalActivateObject(const DbObject::Ptr& dbobj)
 
 void IdoPgsqlConnection::DeactivateObject(const DbObject::Ptr& dbobj)
 {
+       if (IsPaused())
+               return;
+
        m_QueryQueue.Enqueue(std::bind(&IdoPgsqlConnection::InternalDeactivateObject, this, dbobj), PriorityLow);
 }
 
@@ -699,6 +708,9 @@ bool IdoPgsqlConnection::FieldToEscapedString(const String& key, const Value& va
 
 void IdoPgsqlConnection::ExecuteQuery(const DbQuery& query)
 {
+       if (IsPaused())
+               return;
+
        ASSERT(query.Category != DbCatInvalid);
 
        m_QueryQueue.Enqueue(std::bind(&IdoPgsqlConnection::InternalExecuteQuery, this, query, -1), query.Priority, true);
@@ -706,6 +718,9 @@ void IdoPgsqlConnection::ExecuteQuery(const DbQuery& query)
 
 void IdoPgsqlConnection::ExecuteMultipleQueries(const std::vector<DbQuery>& queries)
 {
+       if (IsPaused())
+               return;
+
        if (queries.empty())
                return;
 
@@ -748,6 +763,9 @@ void IdoPgsqlConnection::InternalExecuteMultipleQueries(const std::vector<DbQuer
 {
        AssertOnWorkQueue();
 
+       if (IsPaused())
+               return;
+
        if (!GetConnected())
                return;
 
@@ -769,6 +787,9 @@ void IdoPgsqlConnection::InternalExecuteQuery(const DbQuery& query, int typeOver
 {
        AssertOnWorkQueue();
 
+       if (IsPaused())
+               return;
+
        if (!GetConnected())
                return;
 
@@ -933,6 +954,9 @@ void IdoPgsqlConnection::InternalExecuteQuery(const DbQuery& query, int typeOver
 
 void IdoPgsqlConnection::CleanUpExecuteQuery(const String& table, const String& time_column, double max_age)
 {
+       if (IsPaused())
+               return;
+
        m_QueryQueue.Enqueue(std::bind(&IdoPgsqlConnection::InternalCleanUpExecuteQuery, this, table, time_column, max_age), PriorityLow, true);
 }