Debian Codegraph @

mysql-test/suite/binlog/t/compression_incident_event.test

raw
1 #
2 # WL#3549: Test incident events and binlog compression
3 #
4 # This test injects an incident event and makes sure that no
5 # compression takes place. In addition to that it also makes
6 # sure that no compression stats appear in performance schema.
7 #
8
9 --source include/have_debug.inc
10 --source include/have_binlog_format_row.inc
11
12 call mtr.add_suppression("An incident event has been written to the binary log which will stop the replicas");
13
14 --let $show_rpl_debug_info = 0
15
16 --let $saved_binlog_transaction_compression_session = `SELECT @@SESSION.binlog_transaction_compression`
17 --let $compression_type = LZ4
18 --let $pfs_table = performance_schema.binary_log_transaction_compression_stats
19
20 --eval SET SESSION binlog_transaction_compression = ON
21
22 CREATE TABLE t1(c1 INT PRIMARY KEY, data TEXT(30000));
23
24 RESET MASTER;
25 --eval TRUNCATE $pfs_table
26
27 --let $pattern_to_match = $MYSQLTEST_VARDIR/mysqld.1/data/*binlog*.0*
28 --source include/rpl_log_file_max_number.inc
29 --let $max_log_file_before_incident = $log_file_max_number
30
31 --let $debug_point=binlog_compression_inject_incident
32 --source include/add_debug_point.inc
33
34 INSERT INTO t1 VALUES (1, REPEAT ('a', 1000));
35
36 # Prior to Bug#35671897 the Incident would not be written until subseqent
37 # query, this check verifies that it has already been written by reading the
38 # fourth event and showing it's type, before any other query is executed.
39 --echo Check that Incident has been written
40 --let $evt= query_get_value(SHOW BINLOG EVENTS, Event_type, 4)
41 echo $evt;
42
43 --let $debug_point=binlog_compression_inject_incident
44 --source include/remove_debug_point.inc
45
46 # 1 - Format_desc event, 2 - Previous_gtids event
47
48 --let $evt= query_get_value(SHOW BINLOG EVENTS, Event_type, 3)
49 --let $assert_text = Expected event type Anonymous_Gtid
50 --let $assert_cond = "$evt" = "Anonymous_Gtid" OR "$evt" = "Gtid"
51 --source include/assert.inc
52
53 --let $evt= query_get_value(SHOW BINLOG EVENTS, Event_type, 4)
54 --let $assert_text = Expected event type Incident
55 --let $assert_cond = "$evt" = "Incident"
56 --source include/assert.inc
57
58 # assert that we have no stats on the performance_schema table for compression
59 --let $nrows = `SELECT COUNT(*) FROM $pfs_table WHERE log_type ='BINARY' AND compression_type='$compression_type'`
60 --let $assert_cond = $nrows = 0
61 --let $assert_text = Number of rows in $pfs_table = 0 for compression_type != NONE (because of incident event)
62 --source include/assert.inc
63
64 # assert that we have the stats on the table
65 --let $nrows = `SELECT COUNT(*) FROM $pfs_table WHERE log_type ='BINARY' AND compression_type='NONE'`
66 --let $assert_cond = $nrows = 1
67 --let $assert_text = Number of rows in $pfs_table = 1 for compression_type = NONE
68 --source include/assert.inc
69
70 # assert the log file number increased, this shows that binlog was rotated
71 --source include/rpl_log_file_max_number.inc
72 --let $max_log_file_after_incident = $log_file_max_number
73 --let $assert_text = incident rotated binlog
74 --let $assert_cond = $max_log_file_before_incident + 1 = $max_log_file_after_incident
75 --source include/assert.inc
76
77 # clean up
78 DROP TABLE t1;
79 --replace_result $saved_binlog_transaction_compression_session SAVED
80 --eval SET SESSION binlog_transaction_compression = $saved_binlog_transaction_compression_session
81 RESET MASTER;
82 --eval TRUNCATE $pfs_table