Commit 2aa47d98 authored by Jan Lindström's avatar Jan Lindström

MDEV-11035: Restore removed disallow-writes for Galera

Galera disallow-writes feature was lost in InnoDB 5.7 merge
to 10.2. This patch restores this feature and fixes test
failure on test galera.galera_var_innodb_disallow_writes.
parent c16c9e8e
...@@ -21585,10 +21585,11 @@ innobase_disallow_writes_update( ...@@ -21585,10 +21585,11 @@ innobase_disallow_writes_update(
{ {
*(my_bool*)var_ptr = *(my_bool*)save; *(my_bool*)var_ptr = *(my_bool*)save;
ut_a(srv_allow_writes_event); ut_a(srv_allow_writes_event);
if (*(my_bool*)var_ptr) if (*(my_bool*)var_ptr) {
os_event_reset(srv_allow_writes_event); os_event_reset(srv_allow_writes_event);
else } else {
os_event_set(srv_allow_writes_event); os_event_set(srv_allow_writes_event);
}
} }
static MYSQL_SYSVAR_BOOL(disallow_writes, innobase_disallow_writes, static MYSQL_SYSVAR_BOOL(disallow_writes, innobase_disallow_writes,
...@@ -21596,6 +21597,7 @@ static MYSQL_SYSVAR_BOOL(disallow_writes, innobase_disallow_writes, ...@@ -21596,6 +21597,7 @@ static MYSQL_SYSVAR_BOOL(disallow_writes, innobase_disallow_writes,
"Tell InnoDB to stop any writes to disk", "Tell InnoDB to stop any writes to disk",
NULL, innobase_disallow_writes_update, FALSE); NULL, innobase_disallow_writes_update, FALSE);
#endif /* WITH_INNODB_DISALLOW_WRITES */ #endif /* WITH_INNODB_DISALLOW_WRITES */
static MYSQL_SYSVAR_BOOL(random_read_ahead, srv_random_read_ahead, static MYSQL_SYSVAR_BOOL(random_read_ahead, srv_random_read_ahead,
PLUGIN_VAR_NOCMDARG, PLUGIN_VAR_NOCMDARG,
"Whether to use read ahead for random access within an extent.", "Whether to use read ahead for random access within an extent.",
......
...@@ -1227,6 +1227,7 @@ os_file_create_tmpfile( ...@@ -1227,6 +1227,7 @@ os_file_create_tmpfile(
const char* path) const char* path)
{ {
FILE* file = NULL; FILE* file = NULL;
WAIT_ALLOW_WRITES();
int fd = innobase_mysql_tmpfile(path); int fd = innobase_mysql_tmpfile(path);
if (fd >= 0) { if (fd >= 0) {
...@@ -2552,6 +2553,7 @@ os_file_flush_func( ...@@ -2552,6 +2553,7 @@ os_file_flush_func(
{ {
int ret; int ret;
WAIT_ALLOW_WRITES();
ret = os_file_fsync_posix(file); ret = os_file_fsync_posix(file);
if (ret == 0) { if (ret == 0) {
...@@ -2603,6 +2605,10 @@ os_file_create_simple_func( ...@@ -2603,6 +2605,10 @@ os_file_create_simple_func(
int create_flag; int create_flag;
const char* mode_str = NULL; const char* mode_str = NULL;
if (create_mode != OS_FILE_OPEN && create_mode != OS_FILE_OPEN_RAW) {
WAIT_ALLOW_WRITES();
}
ut_a(!(create_mode & OS_FILE_ON_ERROR_SILENT)); ut_a(!(create_mode & OS_FILE_ON_ERROR_SILENT));
ut_a(!(create_mode & OS_FILE_ON_ERROR_NO_EXIT)); ut_a(!(create_mode & OS_FILE_ON_ERROR_NO_EXIT));
...@@ -2718,7 +2724,10 @@ os_file_create_directory( ...@@ -2718,7 +2724,10 @@ os_file_create_directory(
const char* pathname, const char* pathname,
bool fail_if_exists) bool fail_if_exists)
{ {
int rcode = mkdir(pathname, 0770); int rcode;
WAIT_ALLOW_WRITES();
rcode = mkdir(pathname, 0770);
if (!(rcode == 0 || (errno == EEXIST && !fail_if_exists))) { if (!(rcode == 0 || (errno == EEXIST && !fail_if_exists))) {
/* failure */ /* failure */
...@@ -3051,6 +3060,10 @@ os_file_create_simple_no_error_handling_func( ...@@ -3051,6 +3060,10 @@ os_file_create_simple_no_error_handling_func(
os_file_t file; os_file_t file;
int create_flag; int create_flag;
if (create_mode != OS_FILE_OPEN && create_mode != OS_FILE_OPEN_RAW) {
WAIT_ALLOW_WRITES();
}
ut_a(!(create_mode & OS_FILE_ON_ERROR_SILENT)); ut_a(!(create_mode & OS_FILE_ON_ERROR_SILENT));
ut_a(!(create_mode & OS_FILE_ON_ERROR_NO_EXIT)); ut_a(!(create_mode & OS_FILE_ON_ERROR_NO_EXIT));
...@@ -3124,7 +3137,10 @@ os_file_delete_if_exists_func( ...@@ -3124,7 +3137,10 @@ os_file_delete_if_exists_func(
*exist = true; *exist = true;
} }
int ret = unlink(name); int ret;
WAIT_ALLOW_WRITES();
ret = unlink(name);
if (ret != 0 && errno == ENOENT) { if (ret != 0 && errno == ENOENT) {
if (exist != NULL) { if (exist != NULL) {
...@@ -3146,7 +3162,10 @@ bool ...@@ -3146,7 +3162,10 @@ bool
os_file_delete_func( os_file_delete_func(
const char* name) const char* name)
{ {
int ret = unlink(name); int ret;
WAIT_ALLOW_WRITES();
ret = unlink(name);
if (ret != 0) { if (ret != 0) {
os_file_handle_error_no_exit(name, "delete", FALSE); os_file_handle_error_no_exit(name, "delete", FALSE);
...@@ -3182,7 +3201,10 @@ os_file_rename_func( ...@@ -3182,7 +3201,10 @@ os_file_rename_func(
ut_ad(exists); ut_ad(exists);
#endif /* UNIV_DEBUG */ #endif /* UNIV_DEBUG */
int ret = rename(oldpath, newpath); int ret;
WAIT_ALLOW_WRITES();
ret = rename(oldpath, newpath);
if (ret != 0) { if (ret != 0) {
os_file_handle_error_no_exit(oldpath, "rename", FALSE); os_file_handle_error_no_exit(oldpath, "rename", FALSE);
...@@ -3367,6 +3389,7 @@ bool ...@@ -3367,6 +3389,7 @@ bool
os_file_set_eof( os_file_set_eof(
FILE* file) /*!< in: file to be truncated */ FILE* file) /*!< in: file to be truncated */
{ {
WAIT_ALLOW_WRITES();
return(!ftruncate(fileno(file), ftell(file))); return(!ftruncate(fileno(file), ftell(file)));
} }
...@@ -4128,6 +4151,10 @@ os_file_create_func( ...@@ -4128,6 +4151,10 @@ os_file_create_func(
DWORD create_flag; DWORD create_flag;
DWORD share_mode = FILE_SHARE_READ; DWORD share_mode = FILE_SHARE_READ;
if (create_mode != OS_FILE_OPEN && create_mode != OS_FILE_OPEN_RAW) {
WAIT_ALLOW_WRITES();
}
on_error_no_exit = create_mode & OS_FILE_ON_ERROR_NO_EXIT on_error_no_exit = create_mode & OS_FILE_ON_ERROR_NO_EXIT
? true : false; ? true : false;
...@@ -4937,6 +4964,8 @@ os_file_write_page( ...@@ -4937,6 +4964,8 @@ os_file_write_page(
ut_ad(type.validate()); ut_ad(type.validate());
ut_ad(n > 0); ut_ad(n > 0);
WAIT_ALLOW_WRITES();
ssize_t n_bytes = os_file_pwrite(type, file, (byte*)buf, n, offset, &err); ssize_t n_bytes = os_file_pwrite(type, file, (byte*)buf, n, offset, &err);
if ((ulint) n_bytes != n && !os_has_said_disk_full) { if ((ulint) n_bytes != n && !os_has_said_disk_full) {
......
...@@ -1942,9 +1942,7 @@ DECLARE_THREAD(srv_error_monitor_thread)(void*) ...@@ -1942,9 +1942,7 @@ DECLARE_THREAD(srv_error_monitor_thread)(void*)
if (sync_array_print_long_waits(&waiter, &sema) if (sync_array_print_long_waits(&waiter, &sema)
&& sema == old_sema && os_thread_eq(waiter, old_waiter)) { && sema == old_sema && os_thread_eq(waiter, old_waiter)) {
#if defined(WITH_WSREP) && defined(WITH_INNODB_DISALLOW_WRITES) #if defined(WITH_WSREP) && defined(WITH_INNODB_DISALLOW_WRITES)
if (true) { if (os_event_is_set(srv_allow_writes_event)) {
// JAN: TODO: MySQL 5.7
//if (srv_allow_writes_event->is_set) {
#endif /* WITH_WSREP */ #endif /* WITH_WSREP */
fatal_cnt++; fatal_cnt++;
#if defined(WITH_WSREP) && defined(WITH_INNODB_DISALLOW_WRITES) #if defined(WITH_WSREP) && defined(WITH_INNODB_DISALLOW_WRITES)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment