]> granicus.if.org Git - icinga2/commitdiff
Clear ID cache when (re-)connecting.
authorGunnar Beutner <gunnar.beutner@netways.de>
Wed, 20 Nov 2013 08:32:30 +0000 (09:32 +0100)
committerGunnar Beutner <gunnar.beutner@netways.de>
Wed, 20 Nov 2013 08:32:30 +0000 (09:32 +0100)
Fixes #5108

components/db_ido_mysql/idomysqlconnection.cpp
components/db_ido_pgsql/idopgsqlconnection.cpp
lib/db_ido/dbconnection.cpp
lib/db_ido/dbconnection.h

index f1fe929d8db6b21bd497a01ca5722ca5af2f5940..f42b9fa6870bee392480f4f88ace8c44e0278ea0 100644 (file)
@@ -138,6 +138,8 @@ void IdoMysqlConnection::Reconnect(void)
                        reconnect = true;
                }
 
+               ClearIDCache();
+
                String ihost, iuser, ipasswd, idb;
                const char *host, *user , *passwd, *db;
                long port;
@@ -587,6 +589,7 @@ void IdoMysqlConnection::InternalExecuteQuery(const DbQuery& query)
                if (type == DbQueryInsert && query.ConfigUpdate)
                        SetInsertID(query.Object, GetLastInsertID());
        }
+
        if (type == DbQueryInsert && query.Table == "notifications") { // FIXME remove hardcoded table name
                m_LastNotificationID = GetLastInsertID();
                Log(LogDebug, "db_ido", "saving contactnotification notification_id=" + Convert::ToString(static_cast<long>(m_LastNotificationID)));
index 609275b1fd21a542c3dc6a943edb34317b5ba069..c731bffb7261773fb2eeb5aa0e2a144f8d8c0832 100644 (file)
@@ -139,6 +139,8 @@ void IdoPgsqlConnection::Reconnect(void)
                        }
                }
 
+               ClearIDCache();
+
                String ihost, iport, iuser, ipasswd, idb;
                const char *host, *port, *user , *passwd, *db;
 
index b20c6b27e28d0e05f7bc67f8080e375f190a7068..e325ea59f094d88a9d22a7849137f4110dec1780 100644 (file)
@@ -201,6 +201,12 @@ DbReference DbConnection::GetInsertID(const DbObject::Ptr& dbobj) const
        return it->second;
 }
 
+void DbConnection::ClearIDCache(void)
+{
+       m_ObjectIDs.clear();
+       m_InsertIDs.clear();
+}
+
 void DbConnection::SetConfigUpdate(const DbObject::Ptr& dbobj, bool hasupdate)
 {
        if (hasupdate)
index b52b12f11e26be2ead7cc367cfddab005af29452..1e5decac5e6819e3c04f40b54ed33d2937ea6e30 100644 (file)
@@ -47,6 +47,8 @@ public:
        void SetInsertID(const DbObject::Ptr& dbobj, const DbReference& dbref);
        DbReference GetInsertID(const DbObject::Ptr& dbobj) const;
 
+       void ClearIDCache(void);
+
        void SetConfigUpdate(const DbObject::Ptr& dbobj, bool hasupdate);
        bool GetConfigUpdate(const DbObject::Ptr& dbobj) const;