mirror of https://github.com/Icinga/icinga2.git
Merge pull request #7157 from Icinga/bugfix/ido-conn-prevent-deactivate-on-reload
DB IDO: Do not deactivate objects during application reload/restart
This commit is contained in:
commit
7dfd3535e5
|
@ -353,6 +353,11 @@ bool Application::IsShuttingDown()
|
||||||
return m_ShuttingDown;
|
return m_ShuttingDown;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Application::IsRestarting()
|
||||||
|
{
|
||||||
|
return l_Restarting;
|
||||||
|
}
|
||||||
|
|
||||||
void Application::OnShutdown()
|
void Application::OnShutdown()
|
||||||
{
|
{
|
||||||
/* Nothing to do here. */
|
/* Nothing to do here. */
|
||||||
|
|
|
@ -58,6 +58,7 @@ public:
|
||||||
static void RequestReopenLogs();
|
static void RequestReopenLogs();
|
||||||
|
|
||||||
static bool IsShuttingDown();
|
static bool IsShuttingDown();
|
||||||
|
static bool IsRestarting();
|
||||||
|
|
||||||
static void SetDebuggingSeverity(LogSeverity severity);
|
static void SetDebuggingSeverity(LogSeverity severity);
|
||||||
static LogSeverity GetDebuggingSeverity();
|
static LogSeverity GetDebuggingSeverity();
|
||||||
|
|
|
@ -375,7 +375,26 @@ bool DbConnection::GetStatusUpdate(const DbObject::Ptr& dbobj) const
|
||||||
|
|
||||||
void DbConnection::UpdateObject(const ConfigObject::Ptr& object)
|
void DbConnection::UpdateObject(const ConfigObject::Ptr& object)
|
||||||
{
|
{
|
||||||
if (!GetConnected() || Application::IsShuttingDown())
|
bool isShuttingDown = Application::IsShuttingDown();
|
||||||
|
bool isRestarting = Application::IsRestarting();
|
||||||
|
|
||||||
|
#ifdef I2_DEBUG
|
||||||
|
if (isShuttingDown || isRestarting) {
|
||||||
|
//Log(LogDebug, "DbConnection")
|
||||||
|
// << "Updating object '" << object->GetName() << "' \t\t active '" << Convert::ToLong(object->IsActive())
|
||||||
|
// << "' shutting down '" << Convert::ToLong(isShuttingDown) << "' restarting '" << Convert::ToLong(isRestarting) << "'.";
|
||||||
|
}
|
||||||
|
#endif /* I2_DEBUG */
|
||||||
|
|
||||||
|
/* Wait until a database connection is established on reconnect. */
|
||||||
|
if (!GetConnected())
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* Don't update inactive objects during shutdown/reload/restart.
|
||||||
|
* They would be marked as deleted. This gets triggered with ConfigObject::StopObjects().
|
||||||
|
* During startup/reconnect this is fine, the handler is not active there.
|
||||||
|
*/
|
||||||
|
if (isShuttingDown || isRestarting)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
DbObject::Ptr dbobj = DbObject::GetOrCreateByObject(object);
|
DbObject::Ptr dbobj = DbObject::GetOrCreateByObject(object);
|
||||||
|
@ -402,7 +421,10 @@ void DbConnection::UpdateObject(const ConfigObject::Ptr& object)
|
||||||
dbobj->SendConfigUpdateLight();
|
dbobj->SendConfigUpdateLight();
|
||||||
}
|
}
|
||||||
} else if (!active) {
|
} else if (!active) {
|
||||||
/* Deactivate the deleted object no matter
|
/* This may happen on reload/restart actions too
|
||||||
|
* and is blocked above already.
|
||||||
|
*
|
||||||
|
* Deactivate the deleted object no matter
|
||||||
* which state it had in the database.
|
* which state it had in the database.
|
||||||
*/
|
*/
|
||||||
DeactivateObject(dbobj);
|
DeactivateObject(dbobj);
|
||||||
|
|
Loading…
Reference in New Issue