mirror of https://github.com/Icinga/icinga2.git
Merge pull request #8363 from Icinga/bugfix/ido-commit-25000-213
IDO MySQL: actually COMMIT after 25000 async queries
This commit is contained in:
commit
e8316952f8
|
@ -513,11 +513,6 @@ void IdoMysqlConnection::AsyncQuery(const String& query, const std::function<voi
|
|||
*/
|
||||
aq.Callback = callback;
|
||||
m_AsyncQueries.emplace_back(std::move(aq));
|
||||
|
||||
if (m_AsyncQueries.size() > 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<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)
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "base/timer.hpp"
|
||||
#include "base/workqueue.hpp"
|
||||
#include "base/library.hpp"
|
||||
#include <cstdint>
|
||||
|
||||
namespace icinga
|
||||
{
|
||||
|
@ -64,6 +65,7 @@ private:
|
|||
unsigned int m_MaxPacketSize;
|
||||
|
||||
std::vector<IdoAsyncQuery> m_AsyncQueries;
|
||||
uint_fast32_t m_UncommittedAsyncQueries = 0;
|
||||
|
||||
Timer::Ptr m_ReconnectTimer;
|
||||
Timer::Ptr m_TxTimer;
|
||||
|
|
Loading…
Reference in New Issue