File: rpl_binlog_failed_drop_table.test

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (78 lines) | stat: -rw-r--r-- 3,286 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# ==== Purpose ====
#
# Check that when the exectuion of a DROP TABLE command with single table
# fails it should not be written to the binary log. Also test that when the
# execution of DROP TABLE command with multiple tables fails then the fact
# if it will be logged or not depends on if any non-InnoDB tables are
# involved (as failed InnoDB-only multi-table DROP TABLE will have no
# effect).
#
# The above also provides coverage for changes to binary logging of failed
# DROP TABLES implemented as part of WL#7743 "New data dictionary: changes
# to DDL-related parts of SE API".
#
# ==== Implementation ====
# Create a database `db1` on master and ignore this database on the slave side
# using --replicate-ignore-db=db1 --replicate-wild-ignore-table=db1.%. Now
# execute a DROP TABLE command with single table in it and the command should
# fail thanks to error injection. Check in the binlog that query should
# not be binlogged. Slave should also be up and running without any errors.
# Execute another DROP TABLE command with multiple InnoDB tables in the drop
# list which will also fail. Check that the query is not binlogged in this
# case (as the whole statement is rolled back). Finally, execute multi-table
# DROP TABLE command involving MyISAM table which fails after deleting it.
# Check that query gets written into the binary log and slave should not fail
# since query is filtered on it.
#
# ==== References ====
#
# Bug#21435502: DROP TABLE IF EXISTS MAY BRAKE REPLICATION IF SLAVE HAS
# REPLICATION FILTERS.
#
################################################################################
--source include/master-slave.inc
-- source include/have_debug.inc

CREATE DATABASE `db1`;

USE `db1`;

CREATE TABLE `t1` (`ID` bigint(20) primary key) ENGINE=InnoDB;

CREATE TABLE `t2` (`ID` bigint(20) primary key) ENGINE=InnoDB;

CREATE TABLE `t3` (`ID` bigint(20) primary key) ENGINE=InnoDB;

# Save master position
--let $saved_master_pos=query_get_value('SHOW MASTER STATUS', Position, 1)

# Test a single table drop failure
SET SESSION DEBUG='+d,rm_table_no_locks_abort_after_atomic_tables';
--error ER_UNKNOWN_ERROR
DROP TABLE IF EXISTS `db1`.`t1`;
SET SESSION DEBUG='-d,rm_table_no_locks_abort_after_atomic_tables';
--let $current_master_pos=query_get_value('SHOW MASTER STATUS', Position, 1)
--let $assert_text= Drop with single table should not be written to the binary log if the query execution fails
--let $assert_cond= $current_master_pos = $saved_master_pos
--source include/assert.inc

# Test a multiple table InnoDB-only drop failure
SET SESSION DEBUG='+d,rm_table_no_locks_abort_after_atomic_tables';
--error ER_UNKNOWN_ERROR
DROP TABLE `t3`, `t1`, `t2`;
SET SESSION DEBUG='-d,rm_table_no_locks_abort_after_atomic_tables';
--let $current_master_pos=query_get_value('SHOW MASTER STATUS', Position, 1)
--let $assert_text= Drop with multiple InnoDB-only tables should not be written to the binary log if the query execution fails
--let $assert_cond= $current_master_pos = $saved_master_pos
--source include/assert.inc

--let $binlog_start= $saved_master_pos
--source include/show_binlog_events.inc

--source include/sync_slave_sql_with_master.inc

--echo Cleanup
--source include/rpl_connection_master.inc
DROP DATABASE `db1`;

--source include/rpl_end.inc