fields->Set("varvalue", value);
fields->Set("is_json", is_json);
fields->Set("config_type", 1);
+ fields->Set("session_token", 0); /* DbConnection class fills in real ID */
fields->Set("object_id", obj);
fields->Set("instance_id", 0); /* DbConnection class fills in real ID */
fields->Set("varvalue", value);
fields->Set("is_json", is_json);
fields->Set("status_update_time", DbValue::FromTimestamp(Utility::GetTime()));
+ fields->Set("session_token", 0); /* DbConnection class fills in real ID */
fields->Set("object_id", obj);
fields->Set("instance_id", 0); /* DbConnection class fills in real ID */
CONTEXT("Reconnecting to MySQL IDO database '" + GetName() + "'");
+ m_SessionToken = Utility::NewUniqueID();
+
SetShouldConnect(true);
std::vector<DbObject::Ptr> active_dbobjs;
DeactivateObject(dbobj);
}
}
+
+ /* delete all customvariables without current session token */
+ ClearCustomVarTable("customvariables");
+ ClearCustomVarTable("customvariablestatus");
+
+ Query("COMMIT");
+ Query("BEGIN");
+}
+
+void IdoMysqlConnection::ClearCustomVarTable(const String& table)
+{
+ Query("DELETE FROM " + GetTablePrefix() + table + " WHERE session_token <> '" + Escape(m_SessionToken) + "'");
}
void IdoMysqlConnection::ClearConfigTable(const String& table)
*result = static_cast<long>(m_InstanceID);
return true;
}
+ if (key == "session_token") {
+ *result = "'" + Escape(m_SessionToken) + "'";
+ return true;
+ }
if (key == "notification_id") {
*result = static_cast<long>(GetNotificationInsertID(value));
return true;
private:
DbReference m_InstanceID;
+ String m_SessionToken;
WorkQueue m_QueryQueue;
void InternalNewTransaction(void);
virtual void ClearConfigTable(const String& table) override;
+ void ClearCustomVarTable(const String& table);
void ExceptionHandler(boost::exception_ptr exp);
};
varname varchar(255) character set latin1 collate latin1_general_cs default NULL,
varvalue TEXT character set latin1 default '',
is_json smallint default 0,
+ session_token varchar(512) character set latin1 default NULL,
PRIMARY KEY (customvariable_id),
UNIQUE KEY object_id_2 (object_id,config_type,varname),
KEY varname (varname)
varname varchar(255) character set latin1 collate latin1_general_cs default NULL,
varvalue TEXT character set latin1 default '',
is_json smallint default 0,
+ session_token varchar(512) character set latin1 default NULL,
PRIMARY KEY (customvariablestatus_id),
UNIQUE KEY object_id_2 (object_id,varname),
KEY varname (varname)
ALTER TABLE icinga_servicestatus ADD COLUMN original_attributes TEXT character set latin1 default NULL;
ALTER TABLE icinga_hoststatus ADD COLUMN original_attributes TEXT character set latin1 default NULL;
+-- -----------------------------------------
+-- #10436 deleted custom vars
+-- -----------------------------------------
+
+ALTER TABLE icinga_customvariables ADD COLUMN session_token varchar(512) character set latin1 default NULL;
+ALTER TABLE icinga_customvariablestatus ADD COLUMN session_token varchar(512) character set latin1 default NULL;
+
-- -----------------------------------------
-- update dbversion
-- -----------------------------------------
CONTEXT("Reconnecting to PostgreSQL IDO database '" + GetName() + "'");
+ m_SessionToken = Utility::NewUniqueID();
+
SetShouldConnect(true);
std::vector<DbObject::Ptr> active_dbobjs;
{
-
bool reconnect = false;
if (GetConnected()) {
DeactivateObject(dbobj);
}
}
+
+ /* delete all customvariables without current session token */
+ ClearCustomVarTable("customvariables");
+ ClearCustomVarTable("customvariablestatus");
+
+ Query("COMMIT");
+ Query("BEGIN");
+}
+
+void IdoPgsqlConnection::ClearCustomVarTable(const String& table)
+{
+ Query("DELETE FROM " + GetTablePrefix() + table + " WHERE session_token <> '" + Escape(m_SessionToken) + "'");
}
void IdoPgsqlConnection::ClearConfigTable(const String& table)
private:
DbReference m_InstanceID;
+ String m_SessionToken;
WorkQueue m_QueryQueue;
void InternalCleanUpExecuteQuery(const String& table, const String& time_key, double time_value);
virtual void ClearConfigTable(const String& table) override;
+ void ClearCustomVarTable(const String& table);
void ExceptionHandler(boost::exception_ptr exp);
};
varname TEXT default '',
varvalue TEXT default '',
is_json INTEGER default 0,
+ session_token TEXT default NULL,
CONSTRAINT PK_customvariable_id PRIMARY KEY (customvariable_id) ,
CONSTRAINT UQ_customvariables UNIQUE (object_id,config_type,varname)
) ;
varname TEXT default '',
varvalue TEXT default '',
is_json INTEGER default 0,
+ session_token TEXT default NULL,
CONSTRAINT PK_customvariablestatus_id PRIMARY KEY (customvariablestatus_id) ,
CONSTRAINT UQ_customvariablestatus UNIQUE (object_id,varname)
) ;
ALTER TABLE icinga_servicestatus ADD COLUMN original_attributes TEXT default NULL;
ALTER TABLE icinga_hoststatus ADD COLUMN original_attributes TEXT default NULL;
+-- -----------------------------------------
+-- #10436 deleted custom vars
+-- -----------------------------------------
+ALTER TABLE icinga_customvariables ADD COLUMN session_token TEXT default NULL;
+ALTER TABLE icinga_customvariablestatus ADD COLUMN session_token TEXT default NULL;
+
-- -----------------------------------------
-- update dbversion
-- -----------------------------------------