From: Michael Friedrich Date: Wed, 20 Feb 2019 16:10:46 +0000 (+0100) Subject: DB IDO: Improve queue handling on Pause/Shutdown/Reload X-Git-Tag: v2.11.0-rc1~212^2~6 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1bfe756cb14bd23d53f1e39f76e53e3f302428d7;p=icinga2 DB IDO: Improve queue handling on Pause/Shutdown/Reload --- diff --git a/lib/db_ido/servicedbobject.cpp b/lib/db_ido/servicedbobject.cpp index 903bba655..fcc294cbc 100644 --- a/lib/db_ido/servicedbobject.cpp +++ b/lib/db_ido/servicedbobject.cpp @@ -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; diff --git a/lib/db_ido_mysql/idomysqlconnection.cpp b/lib/db_ido_mysql/idomysqlconnection.cpp index 9bbbeb0df..a6323332c 100644 --- a/lib/db_ido_mysql/idomysqlconnection.cpp +++ b/lib/db_ido_mysql/idomysqlconnection.cpp @@ -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) diff --git a/lib/db_ido_pgsql/idopgsqlconnection.cpp b/lib/db_ido_pgsql/idopgsqlconnection.cpp index 4724ab707..bc791fbd6 100644 --- a/lib/db_ido_pgsql/idopgsqlconnection.cpp +++ b/lib/db_ido_pgsql/idopgsqlconnection.cpp @@ -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)