mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-22 21:24:41 +02:00
IDO MySQL: actually COMMIT after 25000 async queries
This commit is contained in:
parent
5ead5b1f67
commit
cd72eaf2b9
@ -513,11 +513,6 @@ void IdoMysqlConnection::AsyncQuery(const String& query, const std::function<voi
|
|||||||
*/
|
*/
|
||||||
aq.Callback = callback;
|
aq.Callback = callback;
|
||||||
m_AsyncQueries.emplace_back(std::move(aq));
|
m_AsyncQueries.emplace_back(std::move(aq));
|
||||||
|
|
||||||
if (m_AsyncQueries.size() > 25000) {
|
|
||||||
FinishAsyncQueries();
|
|
||||||
InternalNewTransaction();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void IdoMysqlConnection::FinishAsyncQueries()
|
void IdoMysqlConnection::FinishAsyncQueries()
|
||||||
@ -547,6 +542,7 @@ void IdoMysqlConnection::FinishAsyncQueries()
|
|||||||
Defer decreaseQueries ([this, &offset, &count]() {
|
Defer decreaseQueries ([this, &offset, &count]() {
|
||||||
offset += count;
|
offset += count;
|
||||||
DecreasePendingQueries(count);
|
DecreasePendingQueries(count);
|
||||||
|
m_UncommittedAsyncQueries += count;
|
||||||
});
|
});
|
||||||
|
|
||||||
for (std::vector<IdoAsyncQuery>::size_type i = offset; i < queries.size(); i++) {
|
for (std::vector<IdoAsyncQuery>::size_type i = offset; i < queries.size(); i++) {
|
||||||
@ -628,6 +624,13 @@ void IdoMysqlConnection::FinishAsyncQueries()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_UncommittedAsyncQueries > 25000) {
|
||||||
|
m_UncommittedAsyncQueries = 0;
|
||||||
|
|
||||||
|
Query("COMMIT");
|
||||||
|
Query("BEGIN");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IdoMysqlResult IdoMysqlConnection::Query(const String& query)
|
IdoMysqlResult IdoMysqlConnection::Query(const String& query)
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#include "base/timer.hpp"
|
#include "base/timer.hpp"
|
||||||
#include "base/workqueue.hpp"
|
#include "base/workqueue.hpp"
|
||||||
#include "base/library.hpp"
|
#include "base/library.hpp"
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
namespace icinga
|
namespace icinga
|
||||||
{
|
{
|
||||||
@ -64,6 +65,7 @@ private:
|
|||||||
unsigned int m_MaxPacketSize;
|
unsigned int m_MaxPacketSize;
|
||||||
|
|
||||||
std::vector<IdoAsyncQuery> m_AsyncQueries;
|
std::vector<IdoAsyncQuery> m_AsyncQueries;
|
||||||
|
uint_fast32_t m_UncommittedAsyncQueries = 0;
|
||||||
|
|
||||||
Timer::Ptr m_ReconnectTimer;
|
Timer::Ptr m_ReconnectTimer;
|
||||||
Timer::Ptr m_TxTimer;
|
Timer::Ptr m_TxTimer;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user