DB IDO: Improve queue handling on Pause/Shutdown/Reload

This commit is contained in:
Michael Friedrich 2019-02-20 17:10:46 +01:00
parent d4bdebc795
commit 1bfe756cb1
3 changed files with 20 additions and 33 deletions

View File

@ -200,9 +200,6 @@ void ServiceDbObject::OnConfigUpdateHeavy()
DbObject::OnMultipleQueries(queries); DbObject::OnMultipleQueries(queries);
/* service dependencies */ /* service dependencies */
Log(LogDebug, "ServiceDbObject")
<< "service dependencies for '" << service->GetName() << "'";
queries.clear(); queries.clear();
DbQuery query2; DbQuery query2;
@ -250,9 +247,6 @@ void ServiceDbObject::OnConfigUpdateHeavy()
DbObject::OnMultipleQueries(queries); DbObject::OnMultipleQueries(queries);
/* service contacts, contactgroups */ /* service contacts, contactgroups */
Log(LogDebug, "ServiceDbObject")
<< "service contacts: " << service->GetName();
queries.clear(); queries.clear();
DbQuery query3; DbQuery query3;
@ -265,9 +259,6 @@ void ServiceDbObject::OnConfigUpdateHeavy()
queries.emplace_back(std::move(query3)); queries.emplace_back(std::move(query3));
for (const User::Ptr& user : CompatUtility::GetCheckableNotificationUsers(service)) { for (const User::Ptr& user : CompatUtility::GetCheckableNotificationUsers(service)) {
Log(LogDebug, "ServiceDbObject")
<< "service contacts: " << user->GetName();
DbQuery query_contact; DbQuery query_contact;
query_contact.Table = GetType()->GetTable() + "_contacts"; query_contact.Table = GetType()->GetTable() + "_contacts";
query_contact.Type = DbQueryInsert; query_contact.Type = DbQueryInsert;
@ -283,9 +274,6 @@ void ServiceDbObject::OnConfigUpdateHeavy()
DbObject::OnMultipleQueries(queries); DbObject::OnMultipleQueries(queries);
Log(LogDebug, "ServiceDbObject")
<< "service contactgroups: " << service->GetName();
queries.clear(); queries.clear();
DbQuery query4; DbQuery query4;
@ -298,9 +286,6 @@ void ServiceDbObject::OnConfigUpdateHeavy()
queries.emplace_back(std::move(query4)); queries.emplace_back(std::move(query4));
for (const UserGroup::Ptr& usergroup : CompatUtility::GetCheckableNotificationUserGroups(service)) { for (const UserGroup::Ptr& usergroup : CompatUtility::GetCheckableNotificationUserGroups(service)) {
Log(LogDebug, "ServiceDbObject")
<< "service contactgroups: " << usergroup->GetName();
DbQuery query_contact; DbQuery query_contact;
query_contact.Table = GetType()->GetTable() + "_contactgroups"; query_contact.Table = GetType()->GetTable() + "_contactgroups";
query_contact.Type = DbQueryInsert; query_contact.Type = DbQueryInsert;

View File

@ -107,9 +107,6 @@ void IdoMysqlConnection::Resume()
void IdoMysqlConnection::Pause() void IdoMysqlConnection::Pause()
{ {
Log(LogInformation, "IdoMysqlConnection")
<< "'" << GetName() << "' paused.";
m_ReconnectTimer.reset(); m_ReconnectTimer.reset();
DbConnection::Pause(); DbConnection::Pause();
@ -119,8 +116,12 @@ void IdoMysqlConnection::Pause()
<< "Rescheduling disconnect task."; << "Rescheduling disconnect task.";
#endif /* I2_DEBUG */ #endif /* I2_DEBUG */
m_QueryQueue.Enqueue(std::bind(&IdoMysqlConnection::Disconnect, this), PriorityHigh); m_QueryQueue.Enqueue(std::bind(&IdoMysqlConnection::Disconnect, this), PriorityLow);
m_QueryQueue.Join(); m_QueryQueue.Join();
Log(LogInformation, "IdoMysqlConnection")
<< "'" << GetName() << "' paused.";
} }
void IdoMysqlConnection::ExceptionHandler(boost::exception_ptr exp) void IdoMysqlConnection::ExceptionHandler(boost::exception_ptr exp)
@ -192,7 +193,7 @@ void IdoMysqlConnection::ReconnectTimerHandler()
<< "Scheduling reconnect task."; << "Scheduling reconnect task.";
#endif /* I2_DEBUG */ #endif /* I2_DEBUG */
m_QueryQueue.Enqueue(std::bind(&IdoMysqlConnection::Reconnect, this), PriorityLow); m_QueryQueue.Enqueue(std::bind(&IdoMysqlConnection::Reconnect, this), PriorityHigh);
} }
void IdoMysqlConnection::Reconnect() void IdoMysqlConnection::Reconnect()
@ -451,9 +452,9 @@ void IdoMysqlConnection::Reconnect()
<< "Scheduling session table clear and finish connect task."; << "Scheduling session table clear and finish connect task.";
#endif /* I2_DEBUG */ #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) 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() << "'."; << "Scheduling object activation task for '" << dbobj->GetName1() << "!" << dbobj->GetName2() << "'.";
#endif /* I2_DEBUG */ #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) 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() << "'."; << "Scheduling object deactivation task for '" << dbobj->GetName1() << "!" << dbobj->GetName2() << "'.";
#endif /* I2_DEBUG */ #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) void IdoMysqlConnection::InternalDeactivateObject(const DbObject::Ptr& dbobj)

View File

@ -114,15 +114,16 @@ void IdoPgsqlConnection::Resume()
void IdoPgsqlConnection::Pause() void IdoPgsqlConnection::Pause()
{ {
Log(LogInformation, "IdoPgsqlConnection")
<< "'" << GetName() << "' paused.";
m_ReconnectTimer.reset(); m_ReconnectTimer.reset();
DbConnection::Pause(); DbConnection::Pause();
m_QueryQueue.Enqueue(std::bind(&IdoPgsqlConnection::Disconnect, this), PriorityHigh); m_QueryQueue.Enqueue(std::bind(&IdoPgsqlConnection::Disconnect, this), PriorityLow);
m_QueryQueue.Join(); m_QueryQueue.Join();
Log(LogInformation, "IdoPgsqlConnection")
<< "'" << GetName() << "' paused.";
} }
void IdoPgsqlConnection::ExceptionHandler(boost::exception_ptr exp) void IdoPgsqlConnection::ExceptionHandler(boost::exception_ptr exp)
@ -182,7 +183,7 @@ void IdoPgsqlConnection::InternalNewTransaction()
void IdoPgsqlConnection::ReconnectTimerHandler() void IdoPgsqlConnection::ReconnectTimerHandler()
{ {
m_QueryQueue.Enqueue(std::bind(&IdoPgsqlConnection::Reconnect, this), PriorityLow); m_QueryQueue.Enqueue(std::bind(&IdoPgsqlConnection::Reconnect, this), PriorityHigh);
} }
void IdoPgsqlConnection::Reconnect() void IdoPgsqlConnection::Reconnect()
@ -425,9 +426,9 @@ void IdoPgsqlConnection::Reconnect()
UpdateAllObjects(); 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) void IdoPgsqlConnection::FinishConnect(double startTime)
@ -575,7 +576,7 @@ void IdoPgsqlConnection::ActivateObject(const DbObject::Ptr& dbobj)
if (IsPaused()) if (IsPaused())
return; 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) void IdoPgsqlConnection::InternalActivateObject(const DbObject::Ptr& dbobj)
@ -612,7 +613,7 @@ void IdoPgsqlConnection::DeactivateObject(const DbObject::Ptr& dbobj)
if (IsPaused()) if (IsPaused())
return; 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) void IdoPgsqlConnection::InternalDeactivateObject(const DbObject::Ptr& dbobj)