Debian Codegraph @

mysql-test/suite/perfschema/t/rpl_threads.test

raw
1 # Tests for PERFORMANCE_SCHEMA
2
3 --source include/have_log_bin.inc
4 --source include/master-slave.inc
5
6 --disable_warnings
7 drop table if exists test.t1;
8 --sync_slave_with_master
9 reset master;
10 --enable_warnings
11
12 create table test.t1(a int);
13 drop table test.t1;
14
15 --source include/show_binlog_events.inc
16
17 # Notes
18 #
19 # The point of this test is to make sure code is properly instrumented,
20 # for replication threads.
21 # Each time an ID is assigned to a replication thread,
22 # visible in the INFORMATION_SCHEMA.PROCESSLIST table,
23 # the same PROCESSLIST_ID should be visible in table performance_schema.threads
24
25 connection master;
26 -- echo "============ Performance schema on master ============"
27
28 # Read the ID of the binlog dump connection,
29 # as exposed in PROCESSLIST.
30 select ID from INFORMATION_SCHEMA.PROCESSLIST
31 where COMMAND = "Binlog Dump"
32 into @master_dump_pid;
33
34 select COMMAND, STATE
35 from INFORMATION_SCHEMA.PROCESSLIST
36 where ID = @master_dump_pid;
37
38 # Make sure the performance schema also knows this PROCESSLIST_ID
39 select NAME, TYPE, PROCESSLIST_COMMAND, PROCESSLIST_STATE
40 from performance_schema.threads
41 where PROCESSLIST_ID = @master_dump_pid;
42
43 select THREAD_ID from performance_schema.threads
44 where PROCESSLIST_ID = @master_dump_pid
45 into @master_dump_tid;
46
47 # Make sure thread variables can be inspected.
48 select VARIABLE_NAME,
49 IF (VARIABLE_VALUE = @master_dump_pid, "same", "different") as 'test'
50 from performance_schema.variables_by_thread
51 where VARIABLE_NAME = 'pseudo_thread_id' and THREAD_ID = @master_dump_tid;
52
53 # Make sure thread status can be inspected.
54 select VARIABLE_NAME, VARIABLE_VALUE
55 from performance_schema.status_by_thread
56 where VARIABLE_NAME = 'Compression_level' and THREAD_ID = @master_dump_tid;
57
58 sync_slave_with_master;
59 -- echo "============ Performance schema on slave ============"
60
61 # Read the ID of the SLAVE IO thread,
62 # as exposed in PROCESSLIST.
63 select ID from INFORMATION_SCHEMA.PROCESSLIST
64 where STATE like "Waiting for source to send event%"
65 into @slave_io_pid;
66
67 select COMMAND, STATE
68 from INFORMATION_SCHEMA.PROCESSLIST
69 where ID = @slave_io_pid;
70
71 # Make sure the performance schema also knows this PROCESSLIST_ID
72 select NAME, TYPE, PROCESSLIST_COMMAND, PROCESSLIST_STATE
73 from performance_schema.threads
74 where PROCESSLIST_ID = @slave_io_pid;
75
76 select THREAD_ID from performance_schema.threads
77 where PROCESSLIST_ID = @slave_io_pid
78 into @slave_io_tid;
79
80 # Make sure thread variables can be inspected.
81 select VARIABLE_NAME,
82 IF (VARIABLE_VALUE = @slave_io_pid, "same", "different") as 'test'
83 from performance_schema.variables_by_thread
84 where VARIABLE_NAME = 'pseudo_thread_id' and THREAD_ID = @slave_io_tid;
85
86 # Make sure thread status can be inspected.
87 select VARIABLE_NAME, VARIABLE_VALUE
88 from performance_schema.status_by_thread
89 where VARIABLE_NAME = 'Compression_level' and THREAD_ID = @slave_io_tid;
90
91 # Read the ID of the SLAVE SQL thread,
92 # as exposed in PROCESSLIST.
93 select ID from INFORMATION_SCHEMA.PROCESSLIST
94 where STATE like "Replica has read all relay log%"
95 into @slave_sql_pid;
96
97 select COMMAND, STATE
98 from INFORMATION_SCHEMA.PROCESSLIST
99 where ID = @slave_sql_pid;
100
101 # Make sure the performance schema also knows this PROCESSLIST_ID
102 select NAME, TYPE, PROCESSLIST_COMMAND, PROCESSLIST_STATE
103 from performance_schema.threads
104 where PROCESSLIST_ID = @slave_sql_pid;
105
106 select THREAD_ID from performance_schema.threads
107 where PROCESSLIST_ID = @slave_sql_pid
108 into @slave_sql_tid;
109
110 # Make sure thread variables can be inspected.
111 select VARIABLE_NAME,
112 IF (VARIABLE_VALUE = @slave_sql_pid, "same", "different") as 'test'
113 from performance_schema.variables_by_thread
114 where VARIABLE_NAME = 'pseudo_thread_id' and THREAD_ID = @slave_sql_tid;
115
116 # Make sure thread status can be inspected.
117 select VARIABLE_NAME, VARIABLE_VALUE
118 from performance_schema.status_by_thread
119 where VARIABLE_NAME = 'Compression_level' and THREAD_ID = @slave_sql_tid;
120
121 --source include/rpl_end.inc
122