MXS-1924: Enable WAL mode for sqlite

The mysqlauth SQLite database is now opened in WAL mode if possible. This
should prevent lockups of the database when the list of users is updated.

Also moved the starting of the SQLite transaction one level up to also
include the delete part in it. This should further reduce the effects of
updating users.
This commit is contained in:
Markus Mäkelä
2018-06-15 01:12:24 +03:00
parent 53177c30de
commit 856d513040
3 changed files with 33 additions and 17 deletions

View File

@ -776,8 +776,6 @@ int get_users_from_server(MYSQL *con, SERVER_REF *server, SERVICE *service, SERV
if (result)
{
start_sqlite_transaction(instance->handle);
MYSQL_ROW row;
while ((row = mysql_fetch_row(result)))
@ -804,8 +802,6 @@ int get_users_from_server(MYSQL *con, SERVER_REF *server, SERVICE *service, SERV
}
}
commit_sqlite_transaction(instance->handle);
mysql_free_result(result);
}
}
@ -874,6 +870,7 @@ static int get_users(SERV_LISTENER *listener, bool skip_local)
/** Delete the old users */
MYSQL_AUTH *instance = (MYSQL_AUTH*)listener->auth_instance;
start_sqlite_transaction(instance->handle);
delete_mysql_users(instance->handle);
SERVER_REF *server = service->dbref;
@ -921,6 +918,8 @@ static int get_users(SERV_LISTENER *listener, bool skip_local)
}
}
commit_sqlite_transaction(instance->handle);
MXS_FREE(dpwd);
if (no_active_servers)