Merge lp:~laurynas-biveinis/percona-server/i-s-temp-tables-fixes-1-5.6 into lp:percona-server/5.6

Proposed by Laurynas Biveinis
Status: Work in progress
Proposed branch: lp:~laurynas-biveinis/percona-server/i-s-temp-tables-fixes-1-5.6
Merge into: lp:percona-server/5.6
Diff against target: 346 lines (+190/-37)
11 files modified
Percona-Server/mysql-test/r/percona_bug_1113388.result (+16/-0)
Percona-Server/mysql-test/r/percona_bug_1193264.result (+11/-0)
Percona-Server/mysql-test/r/percona_bug_1193308.result (+11/-0)
Percona-Server/mysql-test/t/percona_bug_1113388.test (+34/-0)
Percona-Server/mysql-test/t/percona_bug_1193264.test (+28/-0)
Percona-Server/mysql-test/t/percona_bug_1193308.test (+27/-0)
Percona-Server/sql/ha_partition.cc (+6/-0)
Percona-Server/sql/handler.cc (+10/-0)
Percona-Server/sql/handler.h (+9/-1)
Percona-Server/sql/sql_show.cc (+37/-36)
Percona-Server/sql/sql_table.cc (+1/-0)
To merge this branch: bzr merge lp:~laurynas-biveinis/percona-server/i-s-temp-tables-fixes-1-5.6
Reviewer Review Type Date Requested Status
Laurynas Biveinis (community) Needs Resubmitting
George Ormond Lorch III (community) g2 Approve
Review via email: mp+178095@code.launchpad.net

Description of the change

http://jenkins.percona.com/job/percona-server-5.6-param/217/

Fix several INFORMATION_SCHEMA.GLOBAL_TEMPORARY_TABLES bugs. No BT or ST, but bug 1193308 is a 5.6 QA blocker.

411. By Laurynas Biveinis 4 hours ago

    Merge bug 1113388 fix from 5.5.
410. By Laurynas Biveinis 7 hours ago

    Merge bug 1193264 fix from 5.5.

    Add a testcase that uses the new in 5.6 ALTER code path that creates
    temp tables without calling handler open for them.
409. By Laurynas Biveinis 7 hours ago

    Merge bug 1193308 fix from 5.5.

    In contrast to the lower versions, 5.6 has a more common code path
    that creates temp tables without calling handler open on them: temp
    tables created for 5.6 ALTER. Thus add a DEBUG_SYNC testcase using
    this code path.
408. By Laurynas Biveinis 7 hours ago

    Trivially merge bug 1206486 fix from 5.5.

To post a comment you must log in.
Revision history for this message
George Ormond Lorch III (gl-az) :
review: Approve (g2)
Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote :

Bug 1222709 means that this needs reworking even if OK technically.

review: Needs Resubmitting

Unmerged revisions

411. By Laurynas Biveinis

Merge bug 1113388 fix from 5.5.

410. By Laurynas Biveinis

Merge bug 1193264 fix from 5.5.

Add a testcase that uses the new in 5.6 ALTER code path that creates
temp tables without calling handler open for them.

409. By Laurynas Biveinis

Merge bug 1193308 fix from 5.5.

In contrast to the lower versions, 5.6 has a more common code path
that creates temp tables without calling handler open on them: temp
tables created for 5.6 ALTER. Thus add a DEBUG_SYNC testcase using
this code path.

408. By Laurynas Biveinis

Trivially merge bug 1206486 fix from 5.5.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'Percona-Server/mysql-test/r/percona_bug_1113388.result'
2--- Percona-Server/mysql-test/r/percona_bug_1113388.result 1970-01-01 00:00:00 +0000
3+++ Percona-Server/mysql-test/r/percona_bug_1113388.result 2013-08-01 15:13:20 +0000
4@@ -0,0 +1,16 @@
5+DROP TABLE IF EXISTS t1;
6+CREATE TABLE t1(a INT PRIMARY KEY) ENGINE=InnoDB;
7+INSERT INTO t1 VALUES (1);
8+INSERT INTO t1 VALUES (2);
9+SET DEBUG_SYNC= 'after_copy_data_between_tables_one_row SIGNAL optimize_ready WAIT_FOR i_s_stopped';
10+OPTIMIZE TABLE t1;
11+SET DEBUG_SYNC= 'now WAIT_FOR optimize_ready';
12+SET DEBUG_SYNC= 'before_store_temporary_table_record SIGNAL i_s_stopped';
13+SELECT COUNT(*) FROM INFORMATION_SCHEMA.GLOBAL_TEMPORARY_TABLES;
14+Table Op Msg_type Msg_text
15+test.t1 optimize note Table does not support optimize, doing recreate + analyze instead
16+test.t1 optimize status OK
17+SET DEBUG_SYNC= 'now SIGNAL optimize_completed';
18+COUNT(*)
19+1
20+DROP TABLE t1;
21
22=== added file 'Percona-Server/mysql-test/r/percona_bug_1193264.result'
23--- Percona-Server/mysql-test/r/percona_bug_1193264.result 1970-01-01 00:00:00 +0000
24+++ Percona-Server/mysql-test/r/percona_bug_1193264.result 2013-08-01 15:13:20 +0000
25@@ -0,0 +1,11 @@
26+DROP TABLE IF EXISTS t1;
27+CREATE TABLE t1(a INT PRIMARY KEY, b INT, c INT) ENGINE=InnoDB PARTITION BY HASH(a) PARTITIONS 2;
28+INSERT INTO t1 VALUES (1, 1, 1);
29+SET DEBUG_SYNC= 'innodb_alter_commit_after_lock_table SIGNAL alter_ready WAIT_FOR i_s_completed';
30+ALTER TABLE t1 DROP COLUMN c, ALGORITHM=INPLACE;
31+SET DEBUG_SYNC= 'now WAIT_FOR alter_ready';
32+SELECT COUNT(*) FROM INFORMATION_SCHEMA.GLOBAL_TEMPORARY_TABLES;
33+COUNT(*)
34+1
35+SET DEBUG_SYNC= 'now SIGNAL i_s_completed';
36+DROP TABLE t1;
37
38=== added file 'Percona-Server/mysql-test/r/percona_bug_1193308.result'
39--- Percona-Server/mysql-test/r/percona_bug_1193308.result 1970-01-01 00:00:00 +0000
40+++ Percona-Server/mysql-test/r/percona_bug_1193308.result 2013-08-01 15:13:20 +0000
41@@ -0,0 +1,11 @@
42+DROP TABLE IF EXISTS t1;
43+CREATE TABLE t1(a INT PRIMARY KEY, b INT, c INT) ENGINE=InnoDB;
44+INSERT INTO t1 VALUES (1, 1, 1);
45+SET DEBUG_SYNC= 'innodb_alter_commit_after_lock_table SIGNAL alter_ready WAIT_FOR i_s_completed';
46+ALTER TABLE t1 DROP COLUMN c, ALGORITHM=INPLACE;
47+SET DEBUG_SYNC= 'now WAIT_FOR alter_ready';
48+SELECT COUNT(*) FROM INFORMATION_SCHEMA.GLOBAL_TEMPORARY_TABLES;
49+COUNT(*)
50+1
51+SET DEBUG_SYNC= 'now SIGNAL i_s_completed';
52+DROP TABLE t1;
53
54=== added file 'Percona-Server/mysql-test/t/percona_bug_1113388.test'
55--- Percona-Server/mysql-test/t/percona_bug_1113388.test 1970-01-01 00:00:00 +0000
56+++ Percona-Server/mysql-test/t/percona_bug_1113388.test 2013-08-01 15:13:20 +0000
57@@ -0,0 +1,34 @@
58+# Test for bug 1113388 (field.cc:3822: virtual longlong Field_long::val_int(): Assertion `table->in_use == _current_thd()' failed)
59+
60+--source include/have_innodb.inc
61+--source include/have_debug_sync.inc
62+
63+--disable_warnings
64+DROP TABLE IF EXISTS t1;
65+--enable_warnings
66+
67+CREATE TABLE t1(a INT PRIMARY KEY) ENGINE=InnoDB;
68+INSERT INTO t1 VALUES (1);
69+INSERT INTO t1 VALUES (2);
70+
71+SET DEBUG_SYNC= 'after_copy_data_between_tables_one_row SIGNAL optimize_ready WAIT_FOR i_s_stopped';
72+send OPTIMIZE TABLE t1;
73+
74+connect (conn2,localhost,root,,);
75+connection conn2;
76+
77+SET DEBUG_SYNC= 'now WAIT_FOR optimize_ready';
78+SET DEBUG_SYNC= 'before_store_temporary_table_record SIGNAL i_s_stopped';
79+send SELECT COUNT(*) FROM INFORMATION_SCHEMA.GLOBAL_TEMPORARY_TABLES;
80+
81+connection default;
82+reap;
83+SET DEBUG_SYNC= 'now SIGNAL optimize_completed';
84+
85+connection conn2;
86+reap;
87+
88+disconnect conn2;
89+connection default;
90+
91+DROP TABLE t1;
92
93=== added file 'Percona-Server/mysql-test/t/percona_bug_1193264.test'
94--- Percona-Server/mysql-test/t/percona_bug_1193264.test 1970-01-01 00:00:00 +0000
95+++ Percona-Server/mysql-test/t/percona_bug_1193264.test 2013-08-01 15:13:20 +0000
96@@ -0,0 +1,28 @@
97+# Test for bug 1193264 (handle_fatal_signal in ha_partition::clone (sql/ha_partition.cc:3412))
98+
99+--source include/have_partition.inc
100+--source include/have_innodb.inc
101+--source include/have_debug_sync.inc
102+
103+--disable_warnings
104+DROP TABLE IF EXISTS t1;
105+--enable_warnings
106+
107+CREATE TABLE t1(a INT PRIMARY KEY, b INT, c INT) ENGINE=InnoDB PARTITION BY HASH(a) PARTITIONS 2;
108+INSERT INTO t1 VALUES (1, 1, 1);
109+
110+SET DEBUG_SYNC= 'innodb_alter_commit_after_lock_table SIGNAL alter_ready WAIT_FOR i_s_completed';
111+send ALTER TABLE t1 DROP COLUMN c, ALGORITHM=INPLACE;
112+
113+connect (conn2,localhost,root,,);
114+connection conn2;
115+
116+SET DEBUG_SYNC= 'now WAIT_FOR alter_ready';
117+SELECT COUNT(*) FROM INFORMATION_SCHEMA.GLOBAL_TEMPORARY_TABLES;
118+SET DEBUG_SYNC= 'now SIGNAL i_s_completed';
119+
120+disconnect conn2;
121+connection default;
122+reap;
123+
124+DROP TABLE t1;
125
126=== added file 'Percona-Server/mysql-test/t/percona_bug_1193308.test'
127--- Percona-Server/mysql-test/t/percona_bug_1193308.test 1970-01-01 00:00:00 +0000
128+++ Percona-Server/mysql-test/t/percona_bug_1193308.test 2013-08-01 15:13:20 +0000
129@@ -0,0 +1,27 @@
130+# Test for bug 1193308 (handle_fatal_signal (sig=11) in handler::clone at sql/handler.cc:2370 | crash with concurrent I_S.TEMPORARY_TABLES query and online ALTER)
131+
132+--source include/have_innodb.inc
133+--source include/have_debug_sync.inc
134+
135+--disable_warnings
136+DROP TABLE IF EXISTS t1;
137+--enable_warnings
138+
139+CREATE TABLE t1(a INT PRIMARY KEY, b INT, c INT) ENGINE=InnoDB;
140+INSERT INTO t1 VALUES (1, 1, 1);
141+
142+SET DEBUG_SYNC= 'innodb_alter_commit_after_lock_table SIGNAL alter_ready WAIT_FOR i_s_completed';
143+send ALTER TABLE t1 DROP COLUMN c, ALGORITHM=INPLACE;
144+
145+connect (conn2,localhost,root,,);
146+connection conn2;
147+
148+SET DEBUG_SYNC= 'now WAIT_FOR alter_ready';
149+SELECT COUNT(*) FROM INFORMATION_SCHEMA.GLOBAL_TEMPORARY_TABLES;
150+SET DEBUG_SYNC= 'now SIGNAL i_s_completed';
151+
152+disconnect conn2;
153+connection default;
154+reap;
155+
156+DROP TABLE t1;
157
158=== modified file 'Percona-Server/sql/ha_partition.cc'
159--- Percona-Server/sql/ha_partition.cc 2013-06-20 15:16:00 +0000
160+++ Percona-Server/sql/ha_partition.cc 2013-08-01 15:13:20 +0000
161@@ -3388,6 +3388,12 @@
162 ha_partition *new_handler;
163
164 DBUG_ENTER("ha_partition::clone");
165+
166+ /* If this->table == NULL, then the current handler has been created but not
167+ opened. Prohibit cloning such handler. */
168+ if (!table)
169+ DBUG_RETURN(NULL);
170+
171 new_handler= new (mem_root) ha_partition(ht, table_share, m_part_info,
172 this, mem_root);
173 if (!new_handler)
174
175=== modified file 'Percona-Server/sql/handler.cc'
176--- Percona-Server/sql/handler.cc 2013-06-25 13:13:06 +0000
177+++ Percona-Server/sql/handler.cc 2013-08-01 15:13:20 +0000
178@@ -2372,6 +2372,11 @@
179 ****************************************************************************/
180 handler *handler::clone(const char *name, MEM_ROOT *mem_root)
181 {
182+ /* If this->table == NULL, then the current handler has been created but not
183+ opened. Prohibit cloning such handler. */
184+ if (!table)
185+ return NULL;
186+
187 handler *new_handler= get_new_handler(table->s, mem_root, ht);
188
189 if (!new_handler)
190@@ -2387,6 +2392,9 @@
191 if (!(new_handler->ref= (uchar*) alloc_root(mem_root,
192 ALIGN_SIZE(ref_length)*2)))
193 goto err;
194+
195+ new_handler->cloned = true;
196+
197 /*
198 TODO: Implement a more efficient way to have more than one index open for
199 the same table instance. The ha_open call is not cachable for clone.
200@@ -2416,6 +2424,8 @@
201
202 THD *handler::ha_thd(void) const
203 {
204+ if (unlikely(cloned))
205+ return current_thd;
206 DBUG_ASSERT(!table || !table->in_use || table->in_use == current_thd);
207 return (table && table->in_use) ? table->in_use : current_thd;
208 }
209
210=== modified file 'Percona-Server/sql/handler.h'
211--- Percona-Server/sql/handler.h 2013-06-20 15:16:00 +0000
212+++ Percona-Server/sql/handler.h 2013-08-01 15:13:20 +0000
213@@ -1944,7 +1944,8 @@
214 pushed_idx_cond_keyno(MAX_KEY), rows_read(0), rows_changed(0),
215 next_insert_id(0), insert_id_for_cur_row(0),
216 auto_inc_intervals_count(0),
217- m_psi(NULL), m_lock_type(F_UNLCK), ha_share(NULL)
218+ m_psi(NULL), m_lock_type(F_UNLCK), ha_share(NULL),
219+ cloned(false)
220 {
221 DBUG_PRINT("info",
222 ("handler created F_UNLCK %d F_RDLCK %d F_WRLCK %d",
223@@ -3046,6 +3047,13 @@
224 */
225 virtual int delete_table(const char *name);
226 private:
227+
228+ /**
229+ If true, the current handler is a clone. In that case certain invariants
230+ such as table->in_use == current_thd do not hold.
231+ */
232+ bool cloned;
233+
234 /* Private helpers */
235 inline void mark_trx_read_write();
236 /*
237
238=== modified file 'Percona-Server/sql/sql_show.cc'
239--- Percona-Server/sql/sql_show.cc 2013-06-27 15:15:35 +0000
240+++ Percona-Server/sql/sql_show.cc 2013-08-01 15:13:20 +0000
241@@ -3957,37 +3957,42 @@
242 it but rather clone it. */
243 file = file->clone(tmp_table->s->normalized_path.str, thd->mem_root);
244
245- /**
246- TODO: InnoDB stat(file) checks file on short names within data dictionary
247- rather than using full path, because of that, temp files created in
248- TMPDIR will not have access/create time as it will not find the file
249-
250- The fix is to patch InnoDB to use full path
251- */
252- file->info(HA_STATUS_VARIABLE | HA_STATUS_TIME | HA_STATUS_NO_LOCK);
253-
254- table->field[5]->store((longlong) file->stats.records, TRUE);
255- table->field[5]->set_notnull();
256-
257- table->field[6]->store((longlong) file->stats.mean_rec_length, TRUE);
258- table->field[7]->store((longlong) file->stats.data_file_length, TRUE);
259- table->field[8]->store((longlong) file->stats.index_file_length, TRUE);
260- if (file->stats.create_time)
261- {
262- thd->variables.time_zone->gmt_sec_to_TIME(&time,
263- (my_time_t) file->stats.create_time);
264- table->field[9]->store_time(&time, MYSQL_TIMESTAMP_DATETIME);
265- table->field[9]->set_notnull();
266- }
267- if (file->stats.update_time)
268- {
269- thd->variables.time_zone->gmt_sec_to_TIME(&time,
270- (my_time_t) file->stats.update_time);
271- table->field[10]->store_time(&time, MYSQL_TIMESTAMP_DATETIME);
272- table->field[10]->set_notnull();
273- }
274-
275- file->ha_close();
276+ if (file) {
277+ /**
278+ TODO: InnoDB stat(file) checks file on short names within data
279+ dictionary rather than using full path, because of that, temp files
280+ created in TMPDIR will not have access/create time as it will not find
281+ the file
282+
283+ The fix is to patch InnoDB to use full path
284+ */
285+ file->info(HA_STATUS_VARIABLE | HA_STATUS_TIME | HA_STATUS_NO_LOCK);
286+
287+ table->field[5]->store((longlong) file->stats.records, TRUE);
288+ table->field[5]->set_notnull();
289+
290+ table->field[6]->store((longlong) file->stats.mean_rec_length, TRUE);
291+ table->field[7]->store((longlong) file->stats.data_file_length, TRUE);
292+ table->field[8]->store((longlong) file->stats.index_file_length, TRUE);
293+ if (file->stats.create_time)
294+ {
295+ thd->variables.time_zone->gmt_sec_to_TIME(&time,
296+ (my_time_t)
297+ file->stats.create_time);
298+ table->field[9]->store_time(&time, MYSQL_TIMESTAMP_DATETIME);
299+ table->field[9]->set_notnull();
300+ }
301+ if (file->stats.update_time)
302+ {
303+ thd->variables.time_zone->gmt_sec_to_TIME(&time,
304+ (my_time_t)
305+ file->stats.update_time);
306+ table->field[10]->store_time(&time, MYSQL_TIMESTAMP_DATETIME);
307+ table->field[10]->set_notnull();
308+ }
309+
310+ file->ha_close();
311+ }
312 }
313
314 DBUG_RETURN(schema_table_store_record(thd, table));
315@@ -4037,18 +4042,14 @@
316 }
317 #endif
318
319- THD *t= tmp->in_use;
320- tmp->in_use= thd;
321-
322+ DEBUG_SYNC(thd, "before_store_temporary_table_record");
323 if (store_temporary_table_record(thd_item, tables->table, tmp,
324 thd->lex->select_lex.db)) {
325- tmp->in_use= t;
326 mysql_mutex_unlock(&thd_item->LOCK_temporary_tables);
327 mysql_mutex_unlock(&LOCK_thread_count);
328 DBUG_RETURN(1);
329 }
330
331- tmp->in_use= t;
332 }
333 mysql_mutex_unlock(&thd_item->LOCK_temporary_tables);
334 }
335
336=== modified file 'Percona-Server/sql/sql_table.cc'
337--- Percona-Server/sql/sql_table.cc 2013-06-25 13:13:06 +0000
338+++ Percona-Server/sql/sql_table.cc 2013-08-01 15:13:20 +0000
339@@ -8957,6 +8957,7 @@
340 prev_insert_id= to->file->next_insert_id;
341
342 error=to->file->ha_write_row(to->record[0]);
343+ DEBUG_SYNC(thd, "after_copy_data_between_tables_one_row");
344 to->auto_increment_field_not_null= FALSE;
345 if (error)
346 {

Subscribers

People subscribed via source and target branches