Debian Codegraph @

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

raw
1 # ==== Purpose ====
2 #
3 # Verify that writing an incident log event that
4 # also rotates the binlog works while concurrent DML are ongoing.
5 #
6 # ==== Requirements ====
7 #
8 # R1. When the server generates an incident while there are concurrent DML
9 # statements, it should not crash or lockup.
10 #
11 # ==== Implementation ====
12 #
13 # - In one session, execute a DML load for 5 seconds.
14 # - In another concurrent session, generate incident events 10 times per seconds,
15 # for 5 seconds.
16 # - Verify that there are 50 binlogs and that each of them contains an Incident
17 # event.
18 # - (Verify that it did not crash or lockup).
19 #
20 # ==== References ====
21 #
22 # Bug#35671897 Concurrent Binlog rotate and DDL commit hit safe_mutex assertion
23 #
24
25 --source include/have_log_bin.inc
26 --source include/have_myisam.inc
27 # Test in this file is binlog format agnostic, thus no need
28 # to rerun it for every format.
29 --source include/have_binlog_format_row.inc
30
31 call mtr.add_suppression("Non-transactional changes were not written to the binlog. An incident event has been written to the binary log which will stop the replicas.");
32
33 let $old_max_binlog_stmt_cache_size=
34 query_get_value(SHOW VARIABLES LIKE "max_binlog_stmt_cache_size", Value, 1);
35 let $old_binlog_stmt_cache_size=
36 query_get_value(SHOW VARIABLES LIKE "binlog_stmt_cache_size", Value, 1);
37 SET GLOBAL max_binlog_stmt_cache_size = 4096;
38 SET GLOBAL binlog_stmt_cache_size = 4096;
39
40
41 CREATE TABLE t1(c1 INT PRIMARY KEY, data TEXT(30000)) ENGINE=MyIsam;
42 CREATE TABLE t2 (a INT PRIMARY KEY, b VARCHAR(400)) engine=InnoDB;
43
44 delimiter %;
45 CREATE PROCEDURE dmlload (seconds int)
46 begin
47 set @x=time_to_sec(current_time()) + seconds;
48 repeat
49 start transaction;
50 insert into t2 values (2, repeat('I', 400));
51 commit;
52 start transaction;
53 update t2 set b=repeat('Z', 400) where a=2;
54 commit;
55 start transaction;
56 delete from t2 where a=2;
57 commit;
58 until @x <= time_to_sec(current_time())
59 end repeat;
60 end%
61 delimiter ;%
62
63 RESET MASTER;
64
65 # Start new connections to let the stmt_cache_size setting take effect
66 connect(foreground,localhost,root,,);
67 connect(background,localhost,root,,);
68 --connection background
69 --echo # Start running background load for 5 seconds
70 send call dmlload(5);
71
72 --connection foreground
73 # Using another connection, provoke writing Incident log events by
74 # exceeding the stmt_cache_size
75 let $i = 1;
76 let $incidents = 50; # Aprox matching runtime of dml_load
77 let $data= `SELECT CONCAT('"', repeat('a',2000), '"')`;
78 while ($i <= $incidents)
79 {
80 --echo # i: $i
81 --disable_query_log
82 --error ER_STMT_CACHE_FULL, ER_ERROR_ON_WRITE
83 eval INSERT INTO t1 (c1, data) VALUES ($i,
84 CONCAT($data, $data, $data, $data, $data, $data));
85 --enable_query_log
86
87 sleep 0.1;
88 inc $i;
89 }
90 --echo # There should now be $incidents incidents in the binlog
91
92 --connection background
93 --echo # Collect background load result
94 reap;
95
96 --connection default
97
98 --echo # Check that binlogs contain Gtid + Incident
99 --let $i= 1
100 while ($i <= $incidents)
101 {
102 --let $binlog_file= query_get_value(SHOW BINARY LOGS, Log_name, $i)
103 --let $somewhere = 1
104 --let $event_sequence= !Gtid_or_anon # Incident
105 --source include/assert_binlog_events.inc
106
107 inc $i;
108 }
109
110 # Cleanup
111 DROP TABLE t1;
112 DROP TABLE t2;
113 DROP PROCEDURE dmlload;
114 --replace_result $old_max_binlog_stmt_cache_size ORIGINAL_VALUE
115 eval SET GLOBAL max_binlog_stmt_cache_size= $old_max_binlog_stmt_cache_size;
116 --replace_result $old_binlog_stmt_cache_size ORIGINAL_VALUE
117 eval SET GLOBAL binlog_stmt_cache_size= $old_binlog_stmt_cache_size;
118 --disconnect foreground
119 --disconnect background