]> granicus.if.org Git - icinga2/commitdiff
DB IDO: Improve queue handling on Pause/Shutdown/Reload
authorMichael Friedrich <michael.friedrich@icinga.com>
Wed, 20 Feb 2019 16:10:46 +0000 (17:10 +0100)
committerMichael Friedrich <michael.friedrich@icinga.com>
Wed, 20 Feb 2019 16:10:46 +0000 (17:10 +0100)
lib/db_ido/servicedbobject.cpp
lib/db_ido_mysql/idomysqlconnection.cpp
lib/db_ido_pgsql/idopgsqlconnection.cpp

index 903bba65594c40636429b3375142510ef9ec77a4..fcc294cbc32fd2a05b1b146306eb396f98d509d2 100644 (file)
@@ -200,9 +200,6 @@ void ServiceDbObject::OnConfigUpdateHeavy()
        DbObject::OnMultipleQueries(queries);
 
        /* service dependencies */
-       Log(LogDebug, "ServiceDbObject")
-               << "service dependencies for '" << service->GetName() << "'";
-
        queries.clear();
 
        DbQuery query2;
@@ -250,9 +247,6 @@ void ServiceDbObject::OnConfigUpdateHeavy()
        DbObject::OnMultipleQueries(queries);
 
        /* service contacts, contactgroups */
-       Log(LogDebug, "ServiceDbObject")
-               << "service contacts: " << service->GetName();
-
        queries.clear();
 
        DbQuery query3;
@@ -265,9 +259,6 @@ void ServiceDbObject::OnConfigUpdateHeavy()
        queries.emplace_back(std::move(query3));
 
        for (const User::Ptr& user : CompatUtility::GetCheckableNotificationUsers(service)) {
-               Log(LogDebug, "ServiceDbObject")
-                       << "service contacts: " << user->GetName();
-
                DbQuery query_contact;
                query_contact.Table = GetType()->GetTable() + "_contacts";
                query_contact.Type = DbQueryInsert;
@@ -283,9 +274,6 @@ void ServiceDbObject::OnConfigUpdateHeavy()
 
        DbObject::OnMultipleQueries(queries);
 
-       Log(LogDebug, "ServiceDbObject")
-               << "service contactgroups: " << service->GetName();
-
        queries.clear();
 
        DbQuery query4;
@@ -298,9 +286,6 @@ void ServiceDbObject::OnConfigUpdateHeavy()
        queries.emplace_back(std::move(query4));
 
        for (const UserGroup::Ptr& usergroup : CompatUtility::GetCheckableNotificationUserGroups(service)) {
-               Log(LogDebug, "ServiceDbObject")
-                       << "service contactgroups: " << usergroup->GetName();
-
                DbQuery query_contact;
                query_contact.Table = GetType()->GetTable() + "_contactgroups";
                query_contact.Type = DbQueryInsert;
index 9bbbeb0df42e1bdec7d18826d433fe65d7d3620d..a6323332c74db37f6b92726e4567cadc5ed0e1fe 100644 (file)
@@ -107,9 +107,6 @@ void IdoMysqlConnection::Resume()
 
 void IdoMysqlConnection::Pause()
 {
-       Log(LogInformation, "IdoMysqlConnection")
-               << "'" << GetName() << "' paused.";
-
        m_ReconnectTimer.reset();
 
        DbConnection::Pause();
@@ -119,8 +116,12 @@ void IdoMysqlConnection::Pause()
                << "Rescheduling disconnect task.";
 #endif /* I2_DEBUG */
 
-       m_QueryQueue.Enqueue(std::bind(&IdoMysqlConnection::Disconnect, this), PriorityHigh);
+       m_QueryQueue.Enqueue(std::bind(&IdoMysqlConnection::Disconnect, this), PriorityLow);
        m_QueryQueue.Join();
+
+       Log(LogInformation, "IdoMysqlConnection")
+               << "'" << GetName() << "' paused.";
+
 }
 
 void IdoMysqlConnection::ExceptionHandler(boost::exception_ptr exp)
@@ -192,7 +193,7 @@ void IdoMysqlConnection::ReconnectTimerHandler()
                << "Scheduling reconnect task.";
 #endif /* I2_DEBUG */
 
-       m_QueryQueue.Enqueue(std::bind(&IdoMysqlConnection::Reconnect, this), PriorityLow);
+       m_QueryQueue.Enqueue(std::bind(&IdoMysqlConnection::Reconnect, this), PriorityHigh);
 }
 
 void IdoMysqlConnection::Reconnect()
@@ -451,9 +452,9 @@ void IdoMysqlConnection::Reconnect()
                << "Scheduling session table clear and finish connect task.";
 #endif /* I2_DEBUG */
 
-       m_QueryQueue.Enqueue(std::bind(&IdoMysqlConnection::ClearTablesBySession, this), PriorityLow);
+       m_QueryQueue.Enqueue(std::bind(&IdoMysqlConnection::ClearTablesBySession, this), PriorityHigh);
 
-       m_QueryQueue.Enqueue(std::bind(&IdoMysqlConnection::FinishConnect, this, startTime), PriorityLow);
+       m_QueryQueue.Enqueue(std::bind(&IdoMysqlConnection::FinishConnect, this, startTime), PriorityHigh);
 }
 
 void IdoMysqlConnection::FinishConnect(double startTime)
@@ -726,7 +727,7 @@ void IdoMysqlConnection::ActivateObject(const DbObject::Ptr& dbobj)
                << "Scheduling object activation task for '" << dbobj->GetName1() << "!" << dbobj->GetName2() << "'.";
 #endif /* I2_DEBUG */
 
-       m_QueryQueue.Enqueue(std::bind(&IdoMysqlConnection::InternalActivateObject, this, dbobj), PriorityLow);
+       m_QueryQueue.Enqueue(std::bind(&IdoMysqlConnection::InternalActivateObject, this, dbobj), PriorityHigh);
 }
 
 void IdoMysqlConnection::InternalActivateObject(const DbObject::Ptr& dbobj)
@@ -771,7 +772,7 @@ void IdoMysqlConnection::DeactivateObject(const DbObject::Ptr& dbobj)
                << "Scheduling object deactivation task for '" << dbobj->GetName1() << "!" << dbobj->GetName2() << "'.";
 #endif /* I2_DEBUG */
 
-       m_QueryQueue.Enqueue(std::bind(&IdoMysqlConnection::InternalDeactivateObject, this, dbobj), PriorityLow);
+       m_QueryQueue.Enqueue(std::bind(&IdoMysqlConnection::InternalDeactivateObject, this, dbobj), PriorityHigh);
 }
 
 void IdoMysqlConnection::InternalDeactivateObject(const DbObject::Ptr& dbobj)
index 4724ab707172b778d5f8d544955954b65868d01f..bc791fbd6c183036fed5402de62d8c9c2c987a78 100644 (file)
@@ -114,15 +114,16 @@ void IdoPgsqlConnection::Resume()
 
 void IdoPgsqlConnection::Pause()
 {
-       Log(LogInformation, "IdoPgsqlConnection")
-               << "'" << GetName() << "' paused.";
-
        m_ReconnectTimer.reset();
 
        DbConnection::Pause();
 
-       m_QueryQueue.Enqueue(std::bind(&IdoPgsqlConnection::Disconnect, this), PriorityHigh);
+       m_QueryQueue.Enqueue(std::bind(&IdoPgsqlConnection::Disconnect, this), PriorityLow);
        m_QueryQueue.Join();
+
+       Log(LogInformation, "IdoPgsqlConnection")
+               << "'" << GetName() << "' paused.";
+
 }
 
 void IdoPgsqlConnection::ExceptionHandler(boost::exception_ptr exp)
@@ -182,7 +183,7 @@ void IdoPgsqlConnection::InternalNewTransaction()
 
 void IdoPgsqlConnection::ReconnectTimerHandler()
 {
-       m_QueryQueue.Enqueue(std::bind(&IdoPgsqlConnection::Reconnect, this), PriorityLow);
+       m_QueryQueue.Enqueue(std::bind(&IdoPgsqlConnection::Reconnect, this), PriorityHigh);
 }
 
 void IdoPgsqlConnection::Reconnect()
@@ -425,9 +426,9 @@ void IdoPgsqlConnection::Reconnect()
 
        UpdateAllObjects();
 
-       m_QueryQueue.Enqueue(std::bind(&IdoPgsqlConnection::ClearTablesBySession, this), PriorityLow);
+       m_QueryQueue.Enqueue(std::bind(&IdoPgsqlConnection::ClearTablesBySession, this), PriorityHigh);
 
-       m_QueryQueue.Enqueue(std::bind(&IdoPgsqlConnection::FinishConnect, this, startTime), PriorityLow);
+       m_QueryQueue.Enqueue(std::bind(&IdoPgsqlConnection::FinishConnect, this, startTime), PriorityHigh);
 }
 
 void IdoPgsqlConnection::FinishConnect(double startTime)
@@ -575,7 +576,7 @@ void IdoPgsqlConnection::ActivateObject(const DbObject::Ptr& dbobj)
        if (IsPaused())
                return;
 
-       m_QueryQueue.Enqueue(std::bind(&IdoPgsqlConnection::InternalActivateObject, this, dbobj), PriorityLow);
+       m_QueryQueue.Enqueue(std::bind(&IdoPgsqlConnection::InternalActivateObject, this, dbobj), PriorityHigh);
 }
 
 void IdoPgsqlConnection::InternalActivateObject(const DbObject::Ptr& dbobj)
@@ -612,7 +613,7 @@ void IdoPgsqlConnection::DeactivateObject(const DbObject::Ptr& dbobj)
        if (IsPaused())
                return;
 
-       m_QueryQueue.Enqueue(std::bind(&IdoPgsqlConnection::InternalDeactivateObject, this, dbobj), PriorityLow);
+       m_QueryQueue.Enqueue(std::bind(&IdoPgsqlConnection::InternalDeactivateObject, this, dbobj), PriorityHigh);
 }
 
 void IdoPgsqlConnection::InternalDeactivateObject(const DbObject::Ptr& dbobj)