Merge branch '2.3' into 2.4

This commit is contained in:
Markus Mäkelä
2019-06-28 09:31:14 +03:00
2 changed files with 16 additions and 1 deletions

View File

@ -13,6 +13,8 @@
#include <maxsql/mariadb.hh>
#include <string.h>
#include <errmsg.h>
#include <thread>
#include <chrono>
#include <maxbase/alloc.h>
#include <maxbase/assert.h>
#include <maxbase/format.hh>
@ -44,6 +46,14 @@ int mysql_query_ex(MYSQL* conn, const std::string& query, int query_retries, tim
for (int n = 0; rc != 0 && n < query_retries && mysql_is_net_error(mysql_errno(conn))
&& time(NULL) - start < query_retry_timeout; n++)
{
if (n > 0)
{
// The first reconnection didn't work, wait for one second before attempting again. This
// should reduce the likelihood of transient problems causing state changes due to too many
// reconnection attemps in a short period of time.
std::this_thread::sleep_for(std::chrono::seconds(1));
}
rc = mysql_query(conn, query_cstr);
}