Debian Codegraph @

mysql-test/suite/federated/r/federated_get_table_share.result

raw
1 CREATE DATABASE federated;
2 CREATE DATABASE federated;
3 ###########################################################
4 #
5 # Test cases for wl#7593: Don't hold LOCK_open...
6 #
7 # Most of the tests related to this wl are in a different
8 # test file main.get_table_share.test. One scenario is relevant
9 # for the federated storage engine, which is why it is put into
10 # this file.
11 #
12 # This test case is based on two threads: One thread master
13 # opening table tb, being paused while opening the share,
14 # while another thread issues a ALTER and DROP SERVER commands
15 # to make sure the tables related to the dropped server are
16 # being closed.
17 #
18 # Please note that the include files federated.inc and
19 # federated_cleanup.inc creates an cleans up various resources
20 # related to the federated engine (connections, schemas, etc).
21 #
22 #
23 connection slave;
24 # Create a database and the tables on the slave:
25 CREATE DATABASE new_federated;
26 CREATE TABLE federated.ta (pk integer primary key);
27 CREATE TABLE federated.tb (pk integer primary key);
28 CREATE TABLE new_federated.ta (pk integer primary key);
29 CREATE TABLE new_federated.tb (pk integer primary key);
30 #
31 connection master;
32 # Create one server and two local, federated tables on the master:
33 CREATE SERVER s FOREIGN DATA WRAPPER 'mysql' OPTIONS
34 (USER 'root', HOST '127.0.0.1', PORT SLAVE_PORT, DATABASE 'federated');
35 CREATE TABLE federated.ta (pk integer primary key)
36 ENGINE= FEDERATED CONNECTION= 's';
37 CREATE TABLE federated.tb (pk integer primary key)
38 ENGINE= FEDERATED CONNECTION= 's';
39 #
40 # Check that the server is created, and do an insert into ta to make
41 # sure it is open and in the cache, then show open federated tables:
42 SELECT * from mysql.servers;
43 Server_name Host Db Username Password Port Socket Wrapper Owner
44 s 127.0.0.1 federated root SLAVE_PORT mysql
45 INSERT INTO federated.ta VALUES(0);
46 SELECT * from federated.ta;
47 pk
48 0
49 SHOW OPEN TABLES IN federated;
50 Database Table In_use Name_locked
51 federated ta 0 0
52 #
53 # Wait after releasing LOCK_open for tb, and make sure we never
54 # end up at the 'found_share' sync point:
55 SET DEBUG_SYNC= 'get_share_before_open SIGNAL open_master WAIT_FOR cont_master';
56 SET DEBUG_SYNC= 'get_share_found_share HIT_LIMIT 1';
57 INSERT INTO federated.tb VALUES(1);
58 #
59 connection default;
60 # Wait for open_master, then issue an ALTER SERVER command, which will
61 # close the tables for the server being altered. The table ta is open,
62 # and will be closed, while tb is in the process of being opened, and
63 # will therefore be skipped (i.e. not closed):
64 SET DEBUG_SYNC= 'now WAIT_FOR open_master';
65 ALTER SERVER s OPTIONS (DATABASE 'new_federated');
66 #
67 # Then, we show open federated tables to verify that neither tb nor
68 # ta are open, then we let the master open the tb share and insert,
69 # then we reap the master to be sure it is done with the insert:
70 SHOW OPEN TABLES IN federated;
71 Database Table In_use Name_locked
72 SET DEBUG_SYNC= 'now SIGNAL cont_master';
73 connection master;
74 #
75 connection default;
76 # Now, tb should be open:
77 SHOW OPEN TABLES IN federated;
78 Database Table In_use Name_locked
79 federated tb 0 0
80 #
81 # A select from tb will show the inserted data since the
82 # actual server information from after the ALTER SERVER is used
83 # to open the table:
84 SELECT * from federated.tb;
85 pk
86 1
87 #
88 # A select from ta will now be empty since we switched
89 # remote table:
90 SELECT * from federated.ta;
91 pk
92 #
93 # Now, both ta and tb should be open:
94 SHOW OPEN TABLES IN federated;
95 Database Table In_use Name_locked
96 federated ta 0 0
97 federated tb 0 0
98 #
99 connection master;
100 # Back to the master, we flush table tb and do a new insert,
101 # pausing before opening the share, just like we did above:
102 FLUSH TABLE federated.tb;
103 SHOW OPEN TABLES IN federated;
104 Database Table In_use Name_locked
105 federated ta 0 0
106 SET DEBUG_SYNC= 'get_share_before_open SIGNAL open_master WAIT_FOR cont_master';
107 SET DEBUG_SYNC= 'get_share_found_share HIT_LIMIT 1';
108 INSERT INTO federated.tb VALUES(2);
109 #
110 connection default;
111 # Wait for open_master, then issue a DROP SERVER command:
112 SET DEBUG_SYNC= 'now WAIT_FOR open_master';
113 DROP SERVER s;
114 #
115 # Let the master finish opening the tb share, and then reap it, which
116 # will fail since the server has been deleted:
117 SET DEBUG_SYNC= 'now SIGNAL cont_master';
118 connection master;
119 ERROR HY000: server name: 's' doesn't exist!
120 SET DEBUG_SYNC= 'RESET';
121 #
122 connection default;
123 # Then, we show open tables to verify that tb is left opened,
124 # while ta is not open anymore:
125 SHOW OPEN TABLES IN federated;
126 Database Table In_use Name_locked
127 federated tb 0 0
128 #
129 connection slave;
130 # Drop remote tables and database:
131 DROP TABLE federated.ta, federated.tb;
132 DROP TABLE new_federated.ta, new_federated.tb;
133 DROP DATABASE new_federated;
134 #
135 connection default;
136 # Reset DEBUG_SYNC and drop local tables:
137 SET DEBUG_SYNC= 'RESET';
138 DROP TABLE federated.ta, federated.tb;
139 #
140 # Disconnecting slave and master is handled in federated_cleanup.inc
141 DROP TABLE IF EXISTS federated.t1;
142 DROP DATABASE federated;
143 DROP TABLE IF EXISTS federated.t1;
144 DROP DATABASE federated;