mirror of https://github.com/Icinga/icinga2.git
DB IDO: Improve queue handling on Pause/Shutdown/Reload
This commit is contained in:
parent
d4bdebc795
commit
1bfe756cb1
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue