mirror of https://github.com/Icinga/icinga2.git
IDO MySQL: Don't immediately execute an upsert insert query callback
refs #4603
This commit is contained in:
parent
6f1efff46c
commit
1ad26b8524
|
@ -481,6 +481,9 @@ void IdoMysqlConnection::AsyncQuery(const String& query, const boost::function<v
|
||||||
|
|
||||||
IdoAsyncQuery aq;
|
IdoAsyncQuery aq;
|
||||||
aq.Query = query;
|
aq.Query = query;
|
||||||
|
/* XXX: Important: The callback must not immediately execute a query, but enqueue it!
|
||||||
|
* See https://github.com/Icinga/icinga2/issues/4603 for details.
|
||||||
|
*/
|
||||||
aq.Callback = callback;
|
aq.Callback = callback;
|
||||||
m_AsyncQueries.push_back(aq);
|
m_AsyncQueries.push_back(aq);
|
||||||
|
|
||||||
|
@ -1094,7 +1097,13 @@ void IdoMysqlConnection::InternalExecuteQuery(const DbQuery& query, int typeOver
|
||||||
void IdoMysqlConnection::FinishExecuteQuery(const DbQuery& query, int type, bool upsert)
|
void IdoMysqlConnection::FinishExecuteQuery(const DbQuery& query, int type, bool upsert)
|
||||||
{
|
{
|
||||||
if (upsert && GetAffectedRows() == 0) {
|
if (upsert && GetAffectedRows() == 0) {
|
||||||
InternalExecuteQuery(query, DbQueryDelete | DbQueryInsert);
|
|
||||||
|
#ifdef I2_DEBUG /* I2_DEBUG */
|
||||||
|
Log(LogDebug, "IdoMysqlConnection")
|
||||||
|
<< "Rescheduling DELETE/INSERT query: Upsert UPDATE did not affect rows, type " << type << ", table '" << query.Table << "'.";
|
||||||
|
#endif /* I2_DEBUG */
|
||||||
|
|
||||||
|
m_QueryQueue.Enqueue(boost::bind(&IdoMysqlConnection::InternalExecuteQuery, this, query, DbQueryDelete | DbQueryInsert), query.Priority);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue