Skip to content

Commit

Permalink
DB IDO: Do not deactivate objects during application reload/restart
Browse files Browse the repository at this point in the history
This follows the same principle as with the shutdown handler,
and was introduced with the changed reload handling with 2.9.
Previously IsShuttingDown() was sufficient which got set at one
location.

SigUsr2 as handler introduced a new location where m_ShuttingDown
is not necessarily set yet. Since this handler gets called when
l_Restarting is enabled, we'll use this flag to avoid config update
events resulting in object deactivation (object->IsActive() always
returns false).

refs #5996
refs #6691
refs #6970

fixes #7125
  • Loading branch information
Michael Friedrich committed May 3, 2019
1 parent 759b090 commit 78e24c5
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
5 changes: 5 additions & 0 deletions lib/base/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,11 @@ bool Application::IsShuttingDown()
return m_ShuttingDown;
}

bool Application::IsRestarting()
{
return l_Restarting;
}

void Application::OnShutdown()
{
/* Nothing to do here. */
Expand Down
1 change: 1 addition & 0 deletions lib/base/application.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class Application : public ObjectImpl<Application> {
static void RequestReopenLogs();

static bool IsShuttingDown();
static bool IsRestarting();

static void SetDebuggingSeverity(LogSeverity severity);
static LogSeverity GetDebuggingSeverity();
Expand Down
26 changes: 24 additions & 2 deletions lib/db_ido/dbconnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,26 @@ bool DbConnection::GetStatusUpdate(const DbObject::Ptr& dbobj) const

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;

DbObject::Ptr dbobj = DbObject::GetOrCreateByObject(object);
Expand All @@ -402,7 +421,10 @@ void DbConnection::UpdateObject(const ConfigObject::Ptr& object)
dbobj->SendConfigUpdateLight();
}
} 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.
*/
DeactivateObject(dbobj);
Expand Down

0 comments on commit 78e24c5

Please sign in to comment.