DB IDO: Fix deleted config objects not marked is_active=0.

Fixes #5643
This commit is contained in:
Michael Friedrich 2014-02-12 14:49:39 +01:00
parent 25dc86881a
commit 2be318b93a
2 changed files with 28 additions and 0 deletions

View File

@ -124,6 +124,8 @@ void IdoMysqlConnection::Reconnect(void)
CONTEXT("Reconnecting to MySQL IDO database '" + GetName() + "'");
std::vector<DbObject::Ptr> active_dbobjs;
{
boost::mutex::scoped_lock lock(m_ConnectionMutex);
@ -225,12 +227,24 @@ void IdoMysqlConnection::Reconnect(void)
DbObject::Ptr dbobj = dbtype->GetOrCreateObjectByName(row->Get("name1"), row->Get("name2"));
SetObjectID(dbobj, DbReference(row->Get("object_id")));
SetObjectActive(dbobj, row->Get("is_active"));
if (GetObjectActive(dbobj))
active_dbobjs.push_back(dbobj);
}
Query("BEGIN");
}
UpdateAllObjects();
/* deactivate all deleted configuration objects */
BOOST_FOREACH(const DbObject::Ptr& dbobj, active_dbobjs) {
if (dbobj->GetObject() == NULL) {
Log(LogDebug, "db_ido", "Deactivate deleted object name1: '" + Convert::ToString(dbobj->GetName1() +
"' name2: '" + Convert::ToString(dbobj->GetName2() + "'.")));
DeactivateObject(dbobj);
}
}
}
void IdoMysqlConnection::ClearConfigTable(const String& table)

View File

@ -124,6 +124,8 @@ void IdoPgsqlConnection::Reconnect(void)
CONTEXT("Reconnecting to PostgreSQL IDO database '" + GetName() + "'");
std::vector<DbObject::Ptr> active_dbobjs;
{
boost::mutex::scoped_lock lock(m_ConnectionMutex);
@ -228,12 +230,24 @@ void IdoPgsqlConnection::Reconnect(void)
DbObject::Ptr dbobj = dbtype->GetOrCreateObjectByName(row->Get("name1"), row->Get("name2"));
SetObjectID(dbobj, DbReference(row->Get("object_id")));
SetObjectActive(dbobj, row->Get("is_active"));
if (GetObjectActive(dbobj))
active_dbobjs.push_back(dbobj);
}
Query("BEGIN");
}
UpdateAllObjects();
/* deactivate all deleted configuration objects */
BOOST_FOREACH(const DbObject::Ptr& dbobj, active_dbobjs) {
if (dbobj->GetObject() == NULL) {
Log(LogDebug, "db_ido", "Deactivate deleted object name1: '" + Convert::ToString(dbobj->GetName1() +
"' name2: '" + Convert::ToString(dbobj->GetName2() + "'.")));
DeactivateObject(dbobj);
}
}
}
void IdoPgsqlConnection::ClearConfigTable(const String& table)