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 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
|
###############################################################################
# Check that the server transaction count service can be used in plugins
#
# Test:
# 0. The test requires two servers
# 1. Establish 5 connections and create 2 tables
# 2. Lock a table so one query will block, this one is not counted
# 3. Leave a transaction open without commit (counted)
# 4. Leave a transaction stuck on after commit
# 5. Execute a query that on a server hook will count the number of queries
# 6. Clean up
#
###############################################################################
--source include/have_debug.inc
--source include/have_binlog_format_mixed.inc
--source include/have_replication_observers_example_plugin.inc
--source include/install_replication_observers_example.inc
--echo
--echo # 1. Establish 5 connections and create 2 tables
--connect(con1,localhost,root,,test)
--connect(con2,localhost,root,,test)
--connect(con3,localhost,root,,test)
--connect(con4,localhost,root,,test)
--connect(con5,localhost,root,,test)
--connect(con6,localhost,root,,test)
--let $rpl_connection_name= con1
--source include/rpl_connection.inc
CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB;
CREATE TABLE t2 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB;
--echo
--echo # 2. Lock a table so one query will block, this one is not counted
--let $rpl_connection_name= con2
--source include/rpl_connection.inc
LOCK TABLE t1 WRITE;
--let $rpl_connection_name= con3
--source include/rpl_connection.inc
--send INSERT INTO t1 VALUES (2);
--echo
--echo # 3. Leave a transaction open without commit (counted)
--let $rpl_connection_name= con4
--source include/rpl_connection.inc
BEGIN;
INSERT INTO t2 VALUES(1);
--echo
--echo # 4. Leave a transaction stuck on after commit
--let $rpl_connection_name= con5
--source include/rpl_connection.inc
SET @@GLOBAL.DEBUG='+d,bgc_after_after_commit_stage';
--send INSERT INTO t2 VALUES (3);
--let $rpl_connection_name= con1
--source include/rpl_connection.inc
# Ensuring that the insert actually hangs at the after commit hook (trans_after_commit).
--let $wait_condition=SELECT COUNT(*)=1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE State = 'debug sync point: now'
--source include/wait_condition.inc
SET @@GLOBAL.DEBUG='-d,bgc_after_after_commit_stage';
--echo #
--echo # 5. Execute a query that on a server hook will count the number of
--echo # queries
# It should count 3, the 2 above stuck ones plus the one invoking the hook.
SET @@GLOBAL.DEBUG= '+d,validate_replication_observers_plugin_counts_transactions';
# The after hook inforced order prevents this transaction from returning, even if the transaction commits
--send INSERT INTO t2 VALUES (10);
--let $rpl_connection_name= con6
--source include/rpl_connection.inc
SET @@GLOBAL.DEBUG= '-d,validate_replication_observers_plugin_counts_transactions';
--let $wait_condition=SELECT COUNT(*)=2 FROM test.t2
--source include/wait_condition.inc
--echo #
--echo # 6. Clean up
--let $rpl_connection_name= con2
--source include/rpl_connection.inc
UNLOCK TABLES;
--disconnect con2
--let $rpl_connection_name= con4
--source include/rpl_connection.inc
SET DEBUG_SYNC='now SIGNAL continue_commit';
COMMIT;
--let $rpl_connection_name= con3
--source include/rpl_connection.inc
--reap
--disconnect con3
--let $rpl_connection_name= con1
--source include/rpl_connection.inc
--reap
--disconnect con4
--let $rpl_connection_name= con5
--source include/rpl_connection.inc
--reap
--disconnect con5
--let $rpl_connection_name= con1
--source include/rpl_connection.inc
DROP TABLE t1;
DROP TABLE t2;
SET @@GLOBAL.DEBUG= '-d,validate_replication_observers_plugin_counts_transactions';
--disconnect con1
--connection default
--source include/uninstall_replication_observers_example.inc
|