Skip to content

Commit e9735a8

Browse files
committed
MDEV-25975 innodb_disallow_writes causes shutdown to hang
We will remove the parameter innodb_disallow_writes because it is badly designed and implemented. The parameter was never allowed at startup. It was only internally used by Galera snapshot transfer. If a user executed SET GLOBAL innodb_disallow_writes=ON; the server could hang even on subsequent read operations. During Galera snapshot transfer, we will block writes to implement an rsync friendly snapshot, as follows: sst_flush_tables() will acquire a global lock by executing FLUSH TABLES WITH READ LOCK, which will block any writes at the high level. sst_disable_innodb_writes(), invoked via ha_disable_internal_writes(true), will suspend or disable InnoDB background tasks or threads that could initiate writes. As part of this, log_make_checkpoint() will be invoked to ensure that anything in the InnoDB buf_pool.flush_list will be written to the data files. This has the nice side effect that the Galera joiner will avoid crash recovery. The changes to sql/wsrep.cc and to the tests are based on a prototype that was developed by Jan Lindström. Reviewed by: Jan Lindström
1 parent 7c584d8 commit e9735a8

30 files changed

+229
-398
lines changed

extra/mariabackup/xtrabackup.cc

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4372,11 +4372,6 @@ static bool xtrabackup_backup_func()
43724372
crc_init();
43734373
recv_sys_init();
43744374

4375-
#ifdef WITH_INNODB_DISALLOW_WRITES
4376-
srv_allow_writes_event = os_event_create(0);
4377-
os_event_set(srv_allow_writes_event);
4378-
#endif
4379-
43804375
xb_filters_init();
43814376

43824377
xb_fil_io_init();
@@ -5837,10 +5832,6 @@ static bool xtrabackup_prepare_func(char** argv)
58375832
log_sys.create();
58385833
recv_recovery_on = true;
58395834

5840-
#ifdef WITH_INNODB_DISALLOW_WRITES
5841-
srv_allow_writes_event = os_event_create(0);
5842-
os_event_set(srv_allow_writes_event);
5843-
#endif
58445835
dberr_t err = xb_data_files_init();
58455836
if (err != DB_SUCCESS) {
58465837
msg("mariabackup: error: xb_data_files_init() failed "
@@ -5862,9 +5853,6 @@ static bool xtrabackup_prepare_func(char** argv)
58625853
xb_filter_hash_free(inc_dir_tables_hash);
58635854

58645855
fil_system.close();
5865-
#ifdef WITH_INNODB_DISALLOW_WRITES
5866-
os_event_destroy(srv_allow_writes_event);
5867-
#endif
58685856
innodb_free_param();
58695857
log_sys.close();
58705858
sync_check_close();

mysql-test/include/have_innodb_disallow_writes.inc

Lines changed: 0 additions & 6 deletions
This file was deleted.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
connection node_1;
2+
connection node_2;
3+
connection node_1;
4+
CREATE TABLE t1 (f1 INT PRIMARY KEY);
5+
connection node_2;
6+
call mtr.add_suppression("WSREP: Failed to scan the last segment to the end. Last events may be missing. Last recovered event:.*");
7+
SET DEBUG_SYNC = 'wsrep_before_certification WAIT_FOR continue';
8+
INSERT INTO t1 VALUES (1);
9+
connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2;
10+
connection node_1;
11+
DROP TABLE t1;

mysql-test/suite/galera/r/galera_drop_database.result

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,6 @@ SHOW TABLES;
4646
Tables_in_fts
4747
DROP DATABASE fts;
4848
connection node_2;
49+
call mtr.add_suppression("WSREP: Failed to scan the last segment to the end. Last events may be missing. Last recovered event:");
50+
Warnings:
51+
Note 1049 Unknown database 'fts'

mysql-test/suite/galera/r/galera_events2.result

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ f1 f2
109109
SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_DEFINITION, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_NAME='one_event';
110110
EVENT_CATALOG EVENT_SCHEMA EVENT_NAME DEFINER EVENT_BODY EVENT_DEFINITION EVENT_TYPE EXECUTE_AT INTERVAL_VALUE INTERVAL_FIELD STATUS ON_COMPLETION EVENT_COMMENT
111111
def test one_event root@localhost SQL SELECT 123 RECURRING NULL 10 SECOND SLAVESIDE_DISABLED NOT PRESERVE
112+
call mtr.add_suppression("WSREP: Failed to scan the last segment to the end. Last events may be missing. Last recovered event:.*");
112113
connection node_1;
113114
SELECT * FROM t1;
114115
f1 f2

mysql-test/suite/galera/r/galera_restart_on_unknown_option.result

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ f1 f2
3939
connection node_2;
4040
Starting server ...
4141
Starting server ...
42+
call mtr.add_suppression("WSREP: Failed to scan the last segment to the end. Last events may be missing. Last recovered event:");
4243
SELECT * FROM t1;
4344
f1 f2
4445
1 a

mysql-test/suite/galera/r/galera_var_innodb_disallow_writes.result

Lines changed: 0 additions & 28 deletions
This file was deleted.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#
2+
# This test verifies that the server can be shut down even if
3+
# some of the wsrep transactions are in QUERY_COMMITTING state.
4+
# In this case the shutdown sequence may do a BF abort for the
5+
# connection.
6+
#
7+
8+
--source include/have_innodb.inc
9+
--source include/galera_cluster.inc
10+
--source include/have_debug_sync.inc
11+
12+
# Save original auto_increment_offset values.
13+
--let $node_1=node_1
14+
--let $node_2=node_2
15+
--source include/auto_increment_offset_save.inc
16+
17+
--connection node_1
18+
CREATE TABLE t1 (f1 INT PRIMARY KEY);
19+
20+
--connection node_2
21+
call mtr.add_suppression("WSREP: Failed to scan the last segment to the end. Last events may be missing. Last recovered event:.*");
22+
SET DEBUG_SYNC = 'wsrep_before_certification WAIT_FOR continue';
23+
--send INSERT INTO t1 VALUES (1)
24+
25+
--connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2
26+
--source include/restart_mysqld.inc
27+
28+
# Restore original auto_increment_offset values.
29+
--let $node_2=node_2a
30+
--source include/auto_increment_offset_restore.inc
31+
32+
--connection node_1
33+
34+
DROP TABLE t1;

mysql-test/suite/galera/t/galera_drop_database.test

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ SHOW TABLES;
5656
DROP DATABASE fts;
5757

5858
--connection node_2
59+
call mtr.add_suppression("WSREP: Failed to scan the last segment to the end. Last events may be missing. Last recovered event:");
5960
--let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'fts_t1';
6061
--source include/wait_condition.inc
6162
--let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'fts_t2';

mysql-test/suite/galera/t/galera_events2.test

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ SELECT * FROM t1;
137137
--echo # node_2 Event should be SERVERSIDE_DISABLED
138138
SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_DEFINITION, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_NAME='one_event';
139139

140+
call mtr.add_suppression("WSREP: Failed to scan the last segment to the end. Last events may be missing. Last recovered event:.*");
141+
140142
--connection node_1
141143
SELECT * FROM t1;
142144
--echo # node_1 Event should be ENABLED

0 commit comments

Comments
 (0)