diff --git a/lib/db_ido_mysql/idomysqlconnection.cpp b/lib/db_ido_mysql/idomysqlconnection.cpp index 915a7b3b8..f4fa465e9 100644 --- a/lib/db_ido_mysql/idomysqlconnection.cpp +++ b/lib/db_ido_mysql/idomysqlconnection.cpp @@ -513,11 +513,6 @@ void IdoMysqlConnection::AsyncQuery(const String& query, const std::function 25000) { - FinishAsyncQueries(); - InternalNewTransaction(); - } } void IdoMysqlConnection::FinishAsyncQueries() @@ -547,6 +542,7 @@ void IdoMysqlConnection::FinishAsyncQueries() Defer decreaseQueries ([this, &offset, &count]() { offset += count; DecreasePendingQueries(count); + m_UncommittedAsyncQueries += count; }); for (std::vector::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) diff --git a/lib/db_ido_mysql/idomysqlconnection.hpp b/lib/db_ido_mysql/idomysqlconnection.hpp index 3c1bf916b..d1003c286 100644 --- a/lib/db_ido_mysql/idomysqlconnection.hpp +++ b/lib/db_ido_mysql/idomysqlconnection.hpp @@ -9,6 +9,7 @@ #include "base/timer.hpp" #include "base/workqueue.hpp" #include "base/library.hpp" +#include namespace icinga { @@ -64,6 +65,7 @@ private: unsigned int m_MaxPacketSize; std::vector m_AsyncQueries; + uint_fast32_t m_UncommittedAsyncQueries = 0; Timer::Ptr m_ReconnectTimer; Timer::Ptr m_TxTimer;