File: rpl_kill_query.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 (93 lines) | stat: -rw-r--r-- 3,395 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# ==== Purpose ====
#
# Test the behavior of slave when binlog_format=statement and a query
# that updates a non-transactional table is killed on the master,
# after being only half-way completed.
#
# The following should hold:
# - The statement should be logged with error code ER_QUERY_INTERRUPTED.
# - The slave should normally stop with an error.
# - If the table or database is filtered out, the slave should not stop.
#
# To test this, we test three cases:
#  1. Killed query on master generates error on slave.
#  2. Killed query on master, on a filtered-out table, does not
#     generate error on slave.
#  3. Killed query on master, on a table in a filtered-out database,
#     does not generate error on slave.
#
# ==== Implemenation ====
#
# For case 1, we extecute a statement and kill it in the middle, then
# verify that the slave stops with the correct error.
#
# For cases 2 and 3, we execute a statement and kill it in the middle,
# then verify that the slave replicates without problems.  In case 2,
# the statement is executed when the current database is filtered-out.
# In case 3, the statement modifies a table that is filtered-out.
#
# Slave filters are specified in rpl_kill_query.cnf
#
# The procedure to generate a killed statement is similar in all three
# cases.  See extra/rpl_tests/rpl_kill_query.inc for details.
#
# ==== References ====
#
# BUG#18145032: NO EMPTY TRANSACTION IS CREATED FOR A FILTERED CREATE TEMPORARY TABLE WITH GTIDS
# - Test created as part of this fix, since it touches the code for
#   filtering.

--source include/have_binlog_format_statement.inc
--source include/master-slave.inc
CALL mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
CALL mtr.add_suppression("The replica coordinator and worker threads are stopped, possibly leaving data in inconsistent state");
--sync_slave_with_master
--connection master

--echo ==== Case 1: Killed query on master -> error on slave ====

--let $database= db1
--let $table= t1
--source extra/rpl_tests/rpl_kill_query.inc

--echo ---- Verify there is an error on slave ----
--source include/sync_slave_io_with_master.inc
--let $slave_sql_errno= convert_error(ER_ERROR_ON_SOURCE)
--source include/wait_for_slave_sql_error.inc

--echo ---- Verify that nothing was inserted on slave -----
--let $assert_text= Nothing should be inserted on slave
--let $assert_cond= [slave:SELECT COUNT(*) FROM $database.t1] = 0
--source include/assert.inc

--echo ---- Clean up ----
--source include/stop_slave_io.inc
RESET SLAVE;
RESET MASTER;
DROP DATABASE db1;
--source include/rpl_connection_master.inc
RESET MASTER;
--source include/rpl_connection_slave.inc
--source include/start_slave.inc
--source include/rpl_connection_master.inc

--echo ==== Case 2: Master kills query -> no error if slave filters by db ====

--let $database= ignored_db
--let $table= t1
--source extra/rpl_tests/rpl_kill_query.inc

--echo ---- Verify all was replicated ok ----
--source include/sync_slave_sql_with_master.inc
--source include/rpl_connection_master.inc

--echo ==== Case 3: Master kills query -> no error if slave filters by table ====

--let $database= db1
--let $table= ignored_table
--source extra/rpl_tests/rpl_kill_query.inc

--echo ---- Verify all was replicated ok ----
--source include/sync_slave_sql_with_master.inc

--source include/rpl_end.inc