mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-27 07:34:15 +02:00
Merge pull request #8810 from Icinga/bugfix/mysql-one-transaction-for-programstatus-2.11
IDO: Use own transaction for program status and make sure InternalNewTransaction() gets executed
This commit is contained in:
commit
0bf2c78cc4
@ -150,12 +150,17 @@ void DbConnection::UpdateProgramStatus()
|
|||||||
std::vector<DbQuery> queries;
|
std::vector<DbQuery> queries;
|
||||||
|
|
||||||
DbQuery query1;
|
DbQuery query1;
|
||||||
query1.Table = "programstatus";
|
query1.Type = DbQueryNewTransaction;
|
||||||
query1.IdColumn = "programstatus_id";
|
query1.Priority = PriorityImmediate;
|
||||||
query1.Type = DbQueryInsert | DbQueryDelete;
|
queries.emplace_back(std::move(query1));
|
||||||
query1.Category = DbCatProgramStatus;
|
|
||||||
|
|
||||||
query1.Fields = new Dictionary({
|
DbQuery query2;
|
||||||
|
query2.Table = "programstatus";
|
||||||
|
query2.IdColumn = "programstatus_id";
|
||||||
|
query2.Type = DbQueryInsert | DbQueryDelete;
|
||||||
|
query2.Category = DbCatProgramStatus;
|
||||||
|
|
||||||
|
query2.Fields = new Dictionary({
|
||||||
{ "instance_id", 0 }, /* DbConnection class fills in real ID */
|
{ "instance_id", 0 }, /* DbConnection class fills in real ID */
|
||||||
{ "program_version", Application::GetAppVersion() },
|
{ "program_version", Application::GetAppVersion() },
|
||||||
{ "status_update_time", DbValue::FromTimestamp(Utility::GetTime()) },
|
{ "status_update_time", DbValue::FromTimestamp(Utility::GetTime()) },
|
||||||
@ -175,27 +180,26 @@ void DbConnection::UpdateProgramStatus()
|
|||||||
{ "process_performance_data", (icingaApplication->GetEnablePerfdata() ? 1 : 0) }
|
{ "process_performance_data", (icingaApplication->GetEnablePerfdata() ? 1 : 0) }
|
||||||
});
|
});
|
||||||
|
|
||||||
query1.WhereCriteria = new Dictionary({
|
query2.WhereCriteria = new Dictionary({
|
||||||
{ "instance_id", 0 } /* DbConnection class fills in real ID */
|
{ "instance_id", 0 } /* DbConnection class fills in real ID */
|
||||||
});
|
});
|
||||||
|
|
||||||
query1.Priority = PriorityImmediate;
|
|
||||||
queries.emplace_back(std::move(query1));
|
|
||||||
|
|
||||||
DbQuery query2;
|
|
||||||
query2.Type = DbQueryNewTransaction;
|
|
||||||
queries.emplace_back(std::move(query2));
|
queries.emplace_back(std::move(query2));
|
||||||
|
|
||||||
|
DbQuery query3;
|
||||||
|
query3.Type = DbQueryNewTransaction;
|
||||||
|
queries.emplace_back(std::move(query3));
|
||||||
|
|
||||||
DbObject::OnMultipleQueries(queries);
|
DbObject::OnMultipleQueries(queries);
|
||||||
|
|
||||||
DbQuery query3;
|
DbQuery query4;
|
||||||
query3.Table = "runtimevariables";
|
query4.Table = "runtimevariables";
|
||||||
query3.Type = DbQueryDelete;
|
query4.Type = DbQueryDelete;
|
||||||
query3.Category = DbCatProgramStatus;
|
query4.Category = DbCatProgramStatus;
|
||||||
query3.WhereCriteria = new Dictionary({
|
query4.WhereCriteria = new Dictionary({
|
||||||
{ "instance_id", 0 } /* DbConnection class fills in real ID */
|
{ "instance_id", 0 } /* DbConnection class fills in real ID */
|
||||||
});
|
});
|
||||||
DbObject::OnQuery(query3);
|
DbObject::OnQuery(query4);
|
||||||
|
|
||||||
InsertRuntimeVariable("total_services", ConfigType::Get<Service>()->GetObjectCount());
|
InsertRuntimeVariable("total_services", ConfigType::Get<Service>()->GetObjectCount());
|
||||||
InsertRuntimeVariable("total_scheduled_services", ConfigType::Get<Service>()->GetObjectCount());
|
InsertRuntimeVariable("total_scheduled_services", ConfigType::Get<Service>()->GetObjectCount());
|
||||||
|
@ -165,8 +165,7 @@ void IdoMysqlConnection::NewTransaction()
|
|||||||
<< "Scheduling new transaction and finishing async queries.";
|
<< "Scheduling new transaction and finishing async queries.";
|
||||||
#endif /* I2_DEBUG */
|
#endif /* I2_DEBUG */
|
||||||
|
|
||||||
m_QueryQueue.Enqueue(std::bind(&IdoMysqlConnection::InternalNewTransaction, this), PriorityNormal);
|
m_QueryQueue.Enqueue(std::bind(&IdoMysqlConnection::InternalNewTransaction, this), PriorityHigh);
|
||||||
m_QueryQueue.Enqueue(std::bind(&IdoMysqlConnection::FinishAsyncQueries, this), PriorityNormal);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void IdoMysqlConnection::InternalNewTransaction()
|
void IdoMysqlConnection::InternalNewTransaction()
|
||||||
@ -180,6 +179,8 @@ void IdoMysqlConnection::InternalNewTransaction()
|
|||||||
|
|
||||||
AsyncQuery("COMMIT");
|
AsyncQuery("COMMIT");
|
||||||
AsyncQuery("BEGIN");
|
AsyncQuery("BEGIN");
|
||||||
|
|
||||||
|
FinishAsyncQueries();
|
||||||
}
|
}
|
||||||
|
|
||||||
void IdoMysqlConnection::ReconnectTimerHandler()
|
void IdoMysqlConnection::ReconnectTimerHandler()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user