mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-08-31 22:15:23 +00:00
[#1380] call mysql_autocommit on openDatabase
This commit is contained in:
@@ -58,18 +58,6 @@ MySqlConfigBackendImpl(const DatabaseConnection::ParameterMap& parameters)
|
||||
|
||||
// Open the database.
|
||||
conn_.openDatabase();
|
||||
|
||||
// Enable autocommit. In case transaction is explicitly used, this
|
||||
// setting will be overwritten for the transaction. However, there are
|
||||
// cases when lack of autocommit could cause transactions to hang
|
||||
// until commit or rollback is explicitly called. This already
|
||||
// caused issues for some unit tests which were unable to cleanup
|
||||
// the database after the test because of pending transactions.
|
||||
// Use of autocommit will eliminate this problem.
|
||||
my_bool result = mysql_autocommit(conn_.mysql_, 1);
|
||||
if (result != MLM_FALSE) {
|
||||
isc_throw(DbOperationError, mysql_error(conn_.mysql_));
|
||||
}
|
||||
}
|
||||
|
||||
MySqlConfigBackendImpl::~MySqlConfigBackendImpl() {
|
||||
|
@@ -2634,18 +2634,6 @@ MySqlHostDataSourceImpl::createContext() const {
|
||||
// Open the database.
|
||||
ctx->conn_.openDatabase();
|
||||
|
||||
// Enable autocommit. In case transaction is explicitly used, this
|
||||
// setting will be overwritten for the transaction. However, there are
|
||||
// cases when lack of autocommit could cause transactions to hang
|
||||
// until commit or rollback is explicitly called. This already
|
||||
// caused issues for some unit tests which were unable to cleanup
|
||||
// the database after the test because of pending transactions.
|
||||
// Use of autocommit will eliminate this problem.
|
||||
my_bool result = mysql_autocommit(ctx->conn_.mysql_, 1);
|
||||
if (result != 0) {
|
||||
isc_throw(DbOperationError, mysql_error(ctx->conn_.mysql_));
|
||||
}
|
||||
|
||||
// Prepare query statements. Those are will be only used to retrieve
|
||||
// information from the database, so they can be used even if the
|
||||
// database is read only for the current user.
|
||||
|
@@ -1805,16 +1805,6 @@ MySqlLeaseMgr::createContext() const {
|
||||
// Open the database.
|
||||
ctx->conn_.openDatabase();
|
||||
|
||||
// Enable autocommit. To avoid a flush to disk on every commit, the global
|
||||
// parameter innodb_flush_log_at_trx_commit should be set to 2. This will
|
||||
// cause the changes to be written to the log, but flushed to disk in the
|
||||
// background every second. Setting the parameter to that value will speed
|
||||
// up the system, but at the risk of losing data if the system crashes.
|
||||
my_bool result = mysql_autocommit(ctx->conn_.mysql_, 1);
|
||||
if (result != 0) {
|
||||
isc_throw(DbOperationError, mysql_error(ctx->conn_.mysql_));
|
||||
}
|
||||
|
||||
// Prepare all statements likely to be used.
|
||||
ctx->conn_.prepareStatements(tagged_statements.begin(),
|
||||
tagged_statements.end());
|
||||
|
@@ -210,6 +210,24 @@ MySqlConnection::openDatabase() {
|
||||
if (status != mysql_) {
|
||||
isc_throw(DbOpenError, mysql_error(mysql_));
|
||||
}
|
||||
|
||||
// Enable autocommit. In case transaction is explicitly used, this
|
||||
// setting will be overwritten for the transaction. However, there are
|
||||
// cases when lack of autocommit could cause transactions to hang
|
||||
// until commit or rollback is explicitly called. This already
|
||||
// caused issues for some unit tests which were unable to cleanup
|
||||
// the database after the test because of pending transactions.
|
||||
// Use of autocommit will eliminate this problem.
|
||||
my_bool result = mysql_autocommit(mysql_, 1);
|
||||
if (result != 0) {
|
||||
isc_throw(DbOperationError, mysql_error(ctx->conn_.mysql_));
|
||||
}
|
||||
|
||||
// To avoid a flush to disk on every commit, the global parameter
|
||||
// innodb_flush_log_at_trx_commit should be set to 2. This will cause the
|
||||
// changes to be written to the log, but flushed to disk in the background
|
||||
// every second. Setting the parameter to that value will speed up the
|
||||
// system, but at the risk of losing data if the system crashes.
|
||||
}
|
||||
|
||||
// Get schema version.
|
||||
|
@@ -63,11 +63,6 @@ public:
|
||||
try {
|
||||
// Open new connection.
|
||||
conn_.openDatabase();
|
||||
my_bool result = mysql_autocommit(conn_.mysql_, 1);
|
||||
if (result != 0) {
|
||||
isc_throw(DbOperationError, "failed to set autocommit option "
|
||||
"for test MySQL connection");
|
||||
}
|
||||
|
||||
// Create mysql_connection_test table.
|
||||
createTestTable();
|
||||
|
Reference in New Issue
Block a user