Debian Codegraph @

mysql-test/suite/rpl/t/rpl_replication_observers_example_plugin_ongoing_transaction.test

raw
1 ###############################################################################
2 # Check that the server transaction count service can be used in plugins
3 #
4 # Test:
5 # 0. The test requires two servers
6 # 1. Establish 5 connections and create 2 tables
7 # 2. Lock a table so one query will block, this one is not counted
8 # 3. Leave a transaction open without commit (counted)
9 # 4. Leave a transaction stuck on after commit
10 # 5. Execute a query that on a server hook will count the number of queries
11 # 6. Clean up
12 #
13 ###############################################################################
14
15 --source include/have_debug.inc
16 --source include/have_binlog_format_mixed.inc
17 --source include/have_replication_observers_example_plugin.inc
18 --source include/install_replication_observers_example.inc
19
20 --echo
21 --echo # 1. Establish 5 connections and create 2 tables
22
23 --connect(con1,localhost,root,,test)
24 --connect(con2,localhost,root,,test)
25 --connect(con3,localhost,root,,test)
26 --connect(con4,localhost,root,,test)
27 --connect(con5,localhost,root,,test)
28 --connect(con6,localhost,root,,test)
29
30 --let $rpl_connection_name= con1
31 --source include/rpl_connection.inc
32
33 CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB;
34 CREATE TABLE t2 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB;
35
36 --echo
37 --echo # 2. Lock a table so one query will block, this one is not counted
38
39 --let $rpl_connection_name= con2
40 --source include/rpl_connection.inc
41
42 LOCK TABLE t1 WRITE;
43
44 --let $rpl_connection_name= con3
45 --source include/rpl_connection.inc
46
47 --send INSERT INTO t1 VALUES (2);
48
49 --echo
50 --echo # 3. Leave a transaction open without commit (counted)
51
52 --let $rpl_connection_name= con4
53 --source include/rpl_connection.inc
54
55 BEGIN;
56 INSERT INTO t2 VALUES(1);
57
58 --echo
59 --echo # 4. Leave a transaction stuck on after commit
60
61 --let $rpl_connection_name= con5
62 --source include/rpl_connection.inc
63
64 SET @@GLOBAL.DEBUG='+d,bgc_after_after_commit_stage';
65
66 --send INSERT INTO t2 VALUES (3);
67
68 --let $rpl_connection_name= con1
69 --source include/rpl_connection.inc
70
71 # Ensuring that the insert actually hangs at the after commit hook (trans_after_commit).
72 --let $wait_condition=SELECT COUNT(*)=1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE State = 'debug sync point: now'
73 --source include/wait_condition.inc
74
75 SET @@GLOBAL.DEBUG='-d,bgc_after_after_commit_stage';
76
77 --echo #
78 --echo # 5. Execute a query that on a server hook will count the number of
79 --echo # queries
80
81 # It should count 3, the 2 above stuck ones plus the one invoking the hook.
82
83 SET @@GLOBAL.DEBUG= '+d,validate_replication_observers_plugin_counts_transactions';
84
85 # The after hook inforced order prevents this transaction from returning, even if the transaction commits
86 --send INSERT INTO t2 VALUES (10);
87
88 --let $rpl_connection_name= con6
89 --source include/rpl_connection.inc
90
91 SET @@GLOBAL.DEBUG= '-d,validate_replication_observers_plugin_counts_transactions';
92
93 --let $wait_condition=SELECT COUNT(*)=2 FROM test.t2
94 --source include/wait_condition.inc
95
96 --echo #
97 --echo # 6. Clean up
98
99 --let $rpl_connection_name= con2
100 --source include/rpl_connection.inc
101
102 UNLOCK TABLES;
103
104 --disconnect con2
105
106 --let $rpl_connection_name= con4
107 --source include/rpl_connection.inc
108
109 SET DEBUG_SYNC='now SIGNAL continue_commit';
110
111 COMMIT;
112
113 --let $rpl_connection_name= con3
114 --source include/rpl_connection.inc
115
116 --reap
117
118 --disconnect con3
119
120 --let $rpl_connection_name= con1
121 --source include/rpl_connection.inc
122
123 --reap
124
125 --disconnect con4
126
127 --let $rpl_connection_name= con5
128 --source include/rpl_connection.inc
129
130 --reap
131
132 --disconnect con5
133
134 --let $rpl_connection_name= con1
135 --source include/rpl_connection.inc
136
137 DROP TABLE t1;
138 DROP TABLE t2;
139
140 SET @@GLOBAL.DEBUG= '-d,validate_replication_observers_plugin_counts_transactions';
141
142 --disconnect con1
143
144 --connection default
145
146 --source include/uninstall_replication_observers_example.inc