From: Kees Monshouwer Date: Fri, 12 Jul 2013 10:26:09 +0000 (+0200) Subject: add innodb-read-committed option X-Git-Tag: rec-3.6.0-rc1~554^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f2343e915d62b5219ef72653575bc967632b8d1c;p=thirdparty%2Fpdns.git add innodb-read-committed option --- diff --git a/.gitignore b/.gitignore index fe9f536591..2eaebc25c8 100644 --- a/.gitignore +++ b/.gitignore @@ -38,3 +38,4 @@ lt~obsolete.m4 pdns-*.tar.gz .*DS_Store *~ +pdns.pid \ No newline at end of file diff --git a/modules/gmysqlbackend/gmysqlbackend.cc b/modules/gmysqlbackend/gmysqlbackend.cc index f223e86681..a79ac5256b 100644 --- a/modules/gmysqlbackend/gmysqlbackend.cc +++ b/modules/gmysqlbackend/gmysqlbackend.cc @@ -17,15 +17,15 @@ gMySQLBackend::gMySQLBackend(const string &mode, const string &suffix) : GSQLBa { try { setDB(new SMySQL(getArg("dbname"), - getArg("host"), - getArgAsNum("port"), - getArg("socket"), - getArg("user"), - getArg("password"), - getArg("group"))); - + getArg("host"), + getArgAsNum("port"), + getArg("socket"), + getArg("user"), + getArg("password"), + getArg("group"), + mustDo("innodb-read-committed"))); } - + catch(SSqlException &e) { L<= 50013 my_bool reconnect = 1; @@ -31,21 +33,32 @@ SMySQL::SMySQL(const string &database, const string &host, uint16_t port, const mysql_options(&d_db, MYSQL_OPT_WRITE_TIMEOUT, &timeout); #endif + if (setIsolation && (retry == 1)) + mysql_options(&d_db, MYSQL_INIT_COMMAND,"SET SESSION tx_isolation='READ-COMMITTED'"); + mysql_options(&d_db, MYSQL_READ_DEFAULT_GROUP, group.c_str()); - - if (!mysql_real_connect(&d_db, host.empty() ? NULL : host.c_str(), - user.empty() ? NULL : user.c_str(), - password.empty() ? NULL : password.c_str(), - database.empty() ? NULL : database.c_str(), - port, - msocket.empty() ? NULL : msocket.c_str(), - CLIENT_MULTI_RESULTS)) { - - throw sPerrorException("Unable to connect to database"); + + if (!mysql_real_connect(&d_db, host.empty() ? NULL : host.c_str(), + user.empty() ? NULL : user.c_str(), + password.empty() ? NULL : password.c_str(), + database.empty() ? NULL : database.c_str(), + port, + msocket.empty() ? NULL : msocket.c_str(), + CLIENT_MULTI_RESULTS)) { + + if (retry == 0) + throw sPerrorException("Unable to connect to database"); + --retry; + } else { + if (retry == 0) { + mysql_close(&d_db); + throw sPerrorException("Please add 'innodb-read-committed=no' to your configuration, and reconsider your storage engine if it does not support transactions."); + } + retry=-1; } + } while (retry >= 0); - d_rres=0; - } + d_rres=0; } void SMySQL::setLog(bool state) diff --git a/modules/gmysqlbackend/smysql.hh b/modules/gmysqlbackend/smysql.hh index 4be990c123..24b69b31dc 100644 --- a/modules/gmysqlbackend/smysql.hh +++ b/modules/gmysqlbackend/smysql.hh @@ -13,7 +13,8 @@ class SMySQL : public SSql public: SMySQL(const string &database, const string &host="", uint16_t port=0, const string &msocket="",const string &user="", - const string &password="", const string &group=""); + const string &password="", const string &group="", + bool setIsolation=false); ~SMySQL();