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

Proposed by Laurynas Biveinis on 2013-08-01
Status: Work in progress
Proposed branch: lp:~laurynas-biveinis/percona-server/i-s-temp-tables-fixes-1-5.5
Merge into: lp:percona-server/5.5
Diff against target: 250 lines (+115/-37)
7 files modified
Percona-Server/mysql-test/r/percona_bug_1113388.result (+16/-0)
Percona-Server/mysql-test/t/percona_bug_1113388.test (+34/-0)
Percona-Server/sql/ha_partition.cc (+6/-0)
Percona-Server/sql/handler.cc (+11/-0)
Percona-Server/sql/handler.h (+9/-1)
Percona-Server/sql/sql_show.cc (+38/-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.5
Reviewer Review Type Date Requested Status
Laurynas Biveinis (community) Resubmit on 2013-09-09
George Ormond Lorch III g2 2013-08-01 Approve on 2013-08-05
Review via email: mp+178094@code.launchpad.net

Description of the change

http://jenkins.percona.com/job/percona-server-5.5-param/814/

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

548. By Laurynas Biveinis 4 hours ago

    Merge bug 1113388 fix from 5.1.

    Add a testcase and supporting DEBUG_SYNC points.
547. By Laurynas Biveinis 7 hours ago

    Automerge bug 1193264 fix from 5.1.
546. By Laurynas Biveinis 7 hours ago

    Automerge bug 1193308 fix from 5.1.
545. By Laurynas Biveinis 8 hours ago

    Automerge bug 1206486 fix from 5.1.

To post a comment you must log in.
review: Approve (g2)

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

review: Resubmit

Unmerged revisions

548. By Laurynas Biveinis on 2013-08-01

Merge bug 1113388 fix from 5.1.

Add a testcase and supporting DEBUG_SYNC points.

547. By Laurynas Biveinis on 2013-08-01

Automerge bug 1193264 fix from 5.1.

546. By Laurynas Biveinis on 2013-08-01

Automerge bug 1193308 fix from 5.1.

545. By Laurynas Biveinis on 2013-08-01

Automerge bug 1206486 fix from 5.1.

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:09 +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/t/percona_bug_1113388.test'
23--- Percona-Server/mysql-test/t/percona_bug_1113388.test 1970-01-01 00:00:00 +0000
24+++ Percona-Server/mysql-test/t/percona_bug_1113388.test 2013-08-01 15:13:09 +0000
25@@ -0,0 +1,34 @@
26+# Test for bug 1113388 (field.cc:3822: virtual longlong Field_long::val_int(): Assertion `table->in_use == _current_thd()' failed)
27+
28+--source include/have_innodb.inc
29+--source include/have_debug_sync.inc
30+
31+--disable_warnings
32+DROP TABLE IF EXISTS t1;
33+--enable_warnings
34+
35+CREATE TABLE t1(a INT PRIMARY KEY) ENGINE=InnoDB;
36+INSERT INTO t1 VALUES (1);
37+INSERT INTO t1 VALUES (2);
38+
39+SET DEBUG_SYNC= 'after_copy_data_between_tables_one_row SIGNAL optimize_ready WAIT_FOR i_s_stopped';
40+send OPTIMIZE TABLE t1;
41+
42+connect (conn2,localhost,root,,);
43+connection conn2;
44+
45+SET DEBUG_SYNC= 'now WAIT_FOR optimize_ready';
46+SET DEBUG_SYNC= 'before_store_temporary_table_record SIGNAL i_s_stopped';
47+send SELECT COUNT(*) FROM INFORMATION_SCHEMA.GLOBAL_TEMPORARY_TABLES;
48+
49+connection default;
50+reap;
51+SET DEBUG_SYNC= 'now SIGNAL optimize_completed';
52+
53+connection conn2;
54+reap;
55+
56+disconnect conn2;
57+connection default;
58+
59+DROP TABLE t1;
60
61=== modified file 'Percona-Server/sql/ha_partition.cc'
62--- Percona-Server/sql/ha_partition.cc 2013-02-14 16:03:49 +0000
63+++ Percona-Server/sql/ha_partition.cc 2013-08-01 15:13:09 +0000
64@@ -2872,6 +2872,12 @@
65 ha_partition *new_handler;
66
67 DBUG_ENTER("ha_partition::clone");
68+
69+ /* If this->table == NULL, then the current handler has been created but not
70+ opened. Prohibit cloning such handler. */
71+ if (!table)
72+ DBUG_RETURN(NULL);
73+
74 new_handler= new (mem_root) ha_partition(ht, table_share, m_part_info,
75 this, mem_root);
76 /*
77
78=== modified file 'Percona-Server/sql/handler.cc'
79--- Percona-Server/sql/handler.cc 2013-06-27 15:35:20 +0000
80+++ Percona-Server/sql/handler.cc 2013-08-01 15:13:09 +0000
81@@ -2251,6 +2251,11 @@
82 ****************************************************************************/
83 handler *handler::clone(const char *name, MEM_ROOT *mem_root)
84 {
85+ /* If this->table == NULL, then the current handler has been created but not
86+ opened. Prohibit cloning such handler. */
87+ if (!table)
88+ return NULL;
89+
90 handler *new_handler= get_new_handler(table->s, mem_root, ht);
91 /*
92 Allocate handler->ref here because otherwise ha_open will allocate it
93@@ -2261,6 +2266,10 @@
94 !(new_handler->ref= (uchar*) alloc_root(mem_root,
95 ALIGN_SIZE(ref_length)*2)))
96 new_handler= NULL;
97+
98+ if (new_handler)
99+ new_handler->cloned = true;
100+
101 /*
102 TODO: Implement a more efficient way to have more than one index open for
103 the same table instance. The ha_open call is not cachable for clone.
104@@ -2288,6 +2297,8 @@
105
106 THD *handler::ha_thd(void) const
107 {
108+ if (unlikely(cloned))
109+ return current_thd;
110 DBUG_ASSERT(!table || !table->in_use || table->in_use == current_thd);
111 return (table && table->in_use) ? table->in_use : current_thd;
112 }
113
114=== modified file 'Percona-Server/sql/handler.h'
115--- Percona-Server/sql/handler.h 2013-01-22 16:32:44 +0000
116+++ Percona-Server/sql/handler.h 2013-08-01 15:13:09 +0000
117@@ -1399,7 +1399,8 @@
118 locked(FALSE), implicit_emptied(0),
119 pushed_cond(0), rows_read(0), rows_changed(0), next_insert_id(0), insert_id_for_cur_row(0),
120 auto_inc_intervals_count(0),
121- m_psi(NULL)
122+ m_psi(NULL),
123+ cloned(false)
124 {
125 memset(index_rows_read, 0, sizeof(index_rows_read));
126 }
127@@ -2119,6 +2120,13 @@
128 */
129 virtual int delete_table(const char *name);
130 private:
131+
132+ /**
133+ If true, the current handler is a clone. In that case certain invariants
134+ such as table->in_use == current_thd do not hold.
135+ */
136+ bool cloned;
137+
138 /* Private helpers */
139 inline void mark_trx_read_write();
140 private:
141
142=== modified file 'Percona-Server/sql/sql_show.cc'
143--- Percona-Server/sql/sql_show.cc 2013-06-27 15:11:49 +0000
144+++ Percona-Server/sql/sql_show.cc 2013-08-01 15:13:09 +0000
145@@ -3743,37 +3743,43 @@
146 it but rather clone it. */
147 file = file->clone(tmp_table->s->normalized_path.str, thd->mem_root);
148
149- /**
150- TODO: InnoDB stat(file) checks file on short names within data dictionary
151- rather than using full path, because of that, temp files created in
152- TMPDIR will not have access/create time as it will not find the file
153-
154- The fix is to patch InnoDB to use full path
155- */
156- file->info(HA_STATUS_VARIABLE | HA_STATUS_TIME | HA_STATUS_NO_LOCK);
157-
158- table->field[5]->store((longlong) file->stats.records, TRUE);
159- table->field[5]->set_notnull();
160-
161- table->field[6]->store((longlong) file->stats.mean_rec_length, TRUE);
162- table->field[7]->store((longlong) file->stats.data_file_length, TRUE);
163- table->field[8]->store((longlong) file->stats.index_file_length, TRUE);
164- if (file->stats.create_time)
165- {
166- thd->variables.time_zone->gmt_sec_to_TIME(&time,
167- (my_time_t) file->stats.create_time);
168- table->field[9]->store_time(&time, MYSQL_TIMESTAMP_DATETIME);
169- table->field[9]->set_notnull();
170- }
171- if (file->stats.update_time)
172- {
173- thd->variables.time_zone->gmt_sec_to_TIME(&time,
174- (my_time_t) file->stats.update_time);
175- table->field[10]->store_time(&time, MYSQL_TIMESTAMP_DATETIME);
176- table->field[10]->set_notnull();
177- }
178-
179- file->close();
180+ if (file) {
181+
182+ /**
183+ TODO: InnoDB stat(file) checks file on short names within data
184+ dictionary rather than using full path, because of that, temp files
185+ created in TMPDIR will not have access/create time as it will not find
186+ the file
187+
188+ The fix is to patch InnoDB to use full path
189+ */
190+ file->info(HA_STATUS_VARIABLE | HA_STATUS_TIME | HA_STATUS_NO_LOCK);
191+
192+ table->field[5]->store((longlong) file->stats.records, TRUE);
193+ table->field[5]->set_notnull();
194+
195+ table->field[6]->store((longlong) file->stats.mean_rec_length, TRUE);
196+ table->field[7]->store((longlong) file->stats.data_file_length, TRUE);
197+ table->field[8]->store((longlong) file->stats.index_file_length, TRUE);
198+ if (file->stats.create_time)
199+ {
200+ thd->variables.time_zone->gmt_sec_to_TIME(&time,
201+ (my_time_t)
202+ file->stats.create_time);
203+ table->field[9]->store_time(&time, MYSQL_TIMESTAMP_DATETIME);
204+ table->field[9]->set_notnull();
205+ }
206+ if (file->stats.update_time)
207+ {
208+ thd->variables.time_zone->gmt_sec_to_TIME(&time,
209+ (my_time_t)
210+ file->stats.update_time);
211+ table->field[10]->store_time(&time, MYSQL_TIMESTAMP_DATETIME);
212+ table->field[10]->set_notnull();
213+ }
214+
215+ file->close();
216+ }
217 }
218
219 DBUG_RETURN(schema_table_store_record(thd, table));
220@@ -3823,17 +3829,13 @@
221 }
222 #endif
223
224- THD *t= tmp->in_use;
225- tmp->in_use= thd;
226-
227+ DEBUG_SYNC(thd, "before_store_temporary_table_record");
228 if (store_temporary_table_record(thd_item, tables->table, tmp, thd->lex->select_lex.db, table_names_only)) {
229- tmp->in_use= t;
230 mysql_mutex_unlock(&thd_item->LOCK_temporary_tables);
231 mysql_mutex_unlock(&LOCK_thread_count);
232 DBUG_RETURN(1);
233 }
234
235- tmp->in_use= t;
236 }
237 mysql_mutex_unlock(&thd_item->LOCK_temporary_tables);
238 }
239
240=== modified file 'Percona-Server/sql/sql_table.cc'
241--- Percona-Server/sql/sql_table.cc 2013-06-26 07:01:13 +0000
242+++ Percona-Server/sql/sql_table.cc 2013-08-01 15:13:09 +0000
243@@ -7381,6 +7381,7 @@
244 }
245 prev_insert_id= to->file->next_insert_id;
246 error=to->file->ha_write_row(to->record[0]);
247+ DEBUG_SYNC(thd, "after_copy_data_between_tables_one_row");
248 to->auto_increment_field_not_null= FALSE;
249 if (error)
250 {

Subscribers

People subscribed via source and target branches