Debian Codegraph @

mysql-test/suite/rpl/t/rpl_parallel_alter_db_table.test

raw
1 #
2 # BUG#27165446 PARALLEL REPLICATION OF CREATE/ALTER/DROP DATABASE DEADLOCK,
3 # EARLY MDL RELEASE
4 #
5 # The test verifies ALTER TABLE and ALTER DATABASE should not be executed in
6 # parallel on slave.
7 # Last_committed is always equal to the sequence_number of previous statement.
8 #
9
10 --source include/have_debug.inc
11 --source include/master-slave.inc
12
13 # Setup to run ALTER TABLE and ALTER DATABASE in parallel.
14 CREATE DATABASE d1 CHARACTER SET UTF8MB4;
15 CREATE TABLE d1.t1 (a INT NOT NULL, b VARCHAR(10));
16
17 --source include/sync_slave_sql_with_master.inc
18 --source include/stop_slave.inc
19
20 SET @save_replica_parallel_type = @@GLOBAL.replica_parallel_type;
21 SET @save_replica_parallel_workers = @@GLOBAL.replica_parallel_workers;
22 SET @saved_replica_preserve_commit_order = @@GLOBAL.replica_preserve_commit_order;
23 SET @saved_debug= @@GLOBAL.debug;
24
25 SET GLOBAL replica_parallel_type = LOGICAL_CLOCK;
26 SET GLOBAL replica_parallel_workers = 4;
27 SET GLOBAL replica_preserve_commit_order= ON;
28 ## Sleep so any other statement running parallely executes first.
29 set GLOBAL debug="+d,delay_alter_table_by_one_second";
30
31 # Run ALTER TABLE and ALTER DATABASE in parallel.
32 --connection master
33 INSERT INTO d1.t1 VALUES(1, "");
34 --send ALTER TABLE d1.t1 ADD PRIMARY KEY (a)
35
36 --connection master1
37 --send ALTER DATABASE d1 DEFAULT CHARACTER SET = 'latin1'
38
39 --connection master
40 --reap
41
42 --connection master1
43 --reap
44
45 --connection slave
46 FLUSH TABLES;
47 --source include/start_slave.inc
48
49 # Verify ALTER TABLE and ALTER DATABASE do not run in parallel.
50 --connection master
51 --source include/sync_slave_sql_with_master.inc
52 --let $binlog_file= query_get_value(SHOW SLAVE STATUS, Relay_Log_File, 1)
53 --let $logical_timestamps=3 4
54 --source include/assert_logical_timestamps.inc
55 --source include/stop_slave.inc
56
57 # Assert ALTER TABLE and ALTER DATABASE runs successfully.
58 --let $assert_text= 'ALTER DATABASE runs successfully.'
59 --let $assert_cond= [SELECT COUNT(*) FROM information_schema.schemata WHERE schema_name = "d1" AND DEFAULT_CHARACTER_SET_NAME = "latin1"] = 1
60 --source include/assert.inc
61
62 --let $assert_text= 'ALTER TABLE runs successfully.'
63 --let $assert_cond= [SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = "d1" AND TABLE_NAME = "t1" AND COLUMN_KEY = "PRI"] = 1
64 --source include/assert.inc
65
66 # Cleanup
67 --connection master
68 DROP TABLE d1.t1;
69 DROP DATABASE d1;
70
71 --connection slave
72 SET @@GLOBAL.replica_parallel_type= @save_replica_parallel_type;
73 --disable_warnings
74 SET @@GLOBAL.replica_parallel_workers= @save_replica_parallel_workers;
75 --enable_warnings
76 SET @@GLOBAL.replica_preserve_commit_order= @saved_replica_preserve_commit_order;
77 SET @@GLOBAL.debug= @saved_debug;
78
79 --source include/start_slave.inc
80 --connection master
81 --source include/sync_slave_sql_with_master.inc
82
83 --source include/rpl_end.inc