Merge lp:~percona-toolkit-dev/percona-toolkit/fix-1047335-crashed-tables into lp:percona-toolkit/2.1
- fix-1047335-crashed-tables
- Merge into 2.1
Status: | Superseded |
---|---|
Proposed branch: | lp:~percona-toolkit-dev/percona-toolkit/fix-1047335-crashed-tables |
Merge into: | lp:percona-toolkit/2.1 |
Diff against target: |
593 lines (+232/-68) 18 files modified
bin/pt-archiver (+2/-4) bin/pt-config-diff (+3/-1) bin/pt-duplicate-key-checker (+14/-5) bin/pt-find (+2/-4) bin/pt-heartbeat (+2/-4) bin/pt-index-usage (+14/-5) bin/pt-kill (+5/-5) bin/pt-online-schema-change (+5/-5) bin/pt-query-advisor (+2/-4) bin/pt-query-digest (+2/-4) bin/pt-table-checksum (+14/-5) bin/pt-table-sync (+2/-2) bin/pt-upgrade (+2/-4) lib/SchemaIterator.pm (+16/-1) lib/TableParser.pm (+2/-8) t/lib/SchemaIterator.t (+70/-2) t/lib/TableParser.t (+64/-5) t/lib/samples/bug_1047335_crashed_table.sql (+11/-0) |
To merge this branch: | bzr merge lp:~percona-toolkit-dev/percona-toolkit/fix-1047335-crashed-tables |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Daniel Nichter | Needs Resubmitting | ||
Review via email: mp+132185@code.launchpad.net |
This proposal has been superseded by a proposal from 2012-10-30.
Commit message
Description of the change
Daniel Nichter (daniel-nichter) wrote : | # |
Daniel Nichter (daniel-nichter) wrote : | # |
Also, the local $EVAL_ERROR (re another branch).
I think we have a crashed .frm in the source somewhere; I just looked but couldn't find it; I recall testing this before for something else.
Re 469 +# This might fail. Doesn't matter -- stop_sandbox will just rm -rf the folder -- will this cause output to STDERR? If so, that's bad because it shows up as an error.
- 436. By Brian Fraser
-
Fix for 1047335: SchemaIterator fails when it encounters a crashed table
- 437. By Brian Fraser
-
Removed local $EVAL_ERROR, added a test using t/lib/samples/
broken_ tbl.frm, and updated all modules - 438. By Brian Fraser
-
Fixes per Daniel's review
- 439. By Brian Fraser
-
t/lib/samples/
bug_1047335_ crashed_ table.sql: Use a single INSERT with all the values instead of 1k statements
Unmerged revisions
Preview Diff
1 | === modified file 'bin/pt-archiver' | |||
2 | --- bin/pt-archiver 2012-10-22 18:17:08 +0000 | |||
3 | +++ bin/pt-archiver 2012-10-30 21:38:20 +0000 | |||
4 | @@ -1584,13 +1584,11 @@ | |||
5 | 1584 | PTDEBUG && _d($show_sql); | 1584 | PTDEBUG && _d($show_sql); |
6 | 1585 | my $href; | 1585 | my $href; |
7 | 1586 | eval { $href = $dbh->selectrow_hashref($show_sql); }; | 1586 | eval { $href = $dbh->selectrow_hashref($show_sql); }; |
11 | 1587 | if ( $EVAL_ERROR ) { | 1587 | if ( my $e = $EVAL_ERROR ) { |
9 | 1588 | PTDEBUG && _d($EVAL_ERROR); | ||
10 | 1589 | |||
12 | 1590 | PTDEBUG && _d($old_sql_mode); | 1588 | PTDEBUG && _d($old_sql_mode); |
13 | 1591 | $dbh->do($old_sql_mode); | 1589 | $dbh->do($old_sql_mode); |
14 | 1592 | 1590 | ||
16 | 1593 | return; | 1591 | die $e; |
17 | 1594 | } | 1592 | } |
18 | 1595 | 1593 | ||
19 | 1596 | PTDEBUG && _d($old_sql_mode); | 1594 | PTDEBUG && _d($old_sql_mode); |
20 | 1597 | 1595 | ||
21 | === modified file 'bin/pt-config-diff' | |||
22 | --- bin/pt-config-diff 2012-10-22 18:17:08 +0000 | |||
23 | +++ bin/pt-config-diff 2012-10-30 21:38:20 +0000 | |||
24 | @@ -1576,7 +1576,9 @@ | |||
25 | 1576 | PTDEBUG && _d($sql); | 1576 | PTDEBUG && _d($sql); |
26 | 1577 | my $row = $self->{dbh}->selectrow_arrayref($sql); | 1577 | my $row = $self->{dbh}->selectrow_arrayref($sql); |
27 | 1578 | PTDEBUG && _d(defined $row ? @$row : 'undef'); | 1578 | PTDEBUG && _d(defined $row ? @$row : 'undef'); |
29 | 1579 | $self->{is_cluster_node} = $row && $row->[0] ? 1 : 0; | 1579 | $self->{is_cluster_node} = $row && $row->[1] |
30 | 1580 | ? ($row->[1] eq 'ON' || $row->[1] eq '1') | ||
31 | 1581 | : 0; | ||
32 | 1580 | 1582 | ||
33 | 1581 | return $self->{is_cluster_node}; | 1583 | return $self->{is_cluster_node}; |
34 | 1582 | } | 1584 | } |
35 | 1583 | 1585 | ||
36 | === modified file 'bin/pt-duplicate-key-checker' | |||
37 | --- bin/pt-duplicate-key-checker 2012-10-22 18:17:08 +0000 | |||
38 | +++ bin/pt-duplicate-key-checker 2012-10-30 21:38:20 +0000 | |||
39 | @@ -226,13 +226,11 @@ | |||
40 | 226 | PTDEBUG && _d($show_sql); | 226 | PTDEBUG && _d($show_sql); |
41 | 227 | my $href; | 227 | my $href; |
42 | 228 | eval { $href = $dbh->selectrow_hashref($show_sql); }; | 228 | eval { $href = $dbh->selectrow_hashref($show_sql); }; |
46 | 229 | if ( $EVAL_ERROR ) { | 229 | if ( my $e = $EVAL_ERROR ) { |
44 | 230 | PTDEBUG && _d($EVAL_ERROR); | ||
45 | 231 | |||
47 | 232 | PTDEBUG && _d($old_sql_mode); | 230 | PTDEBUG && _d($old_sql_mode); |
48 | 233 | $dbh->do($old_sql_mode); | 231 | $dbh->do($old_sql_mode); |
49 | 234 | 232 | ||
51 | 235 | return; | 233 | die $e; |
52 | 236 | } | 234 | } |
53 | 237 | 235 | ||
54 | 238 | PTDEBUG && _d($old_sql_mode); | 236 | PTDEBUG && _d($old_sql_mode); |
55 | @@ -3138,7 +3136,18 @@ | |||
56 | 3138 | } | 3136 | } |
57 | 3139 | 3137 | ||
58 | 3140 | while ( my $tbl = shift @{$self->{tbls}} ) { | 3138 | while ( my $tbl = shift @{$self->{tbls}} ) { |
60 | 3141 | my $ddl = $tp->get_create_table($dbh, $self->{db}, $tbl); | 3139 | local $EVAL_ERROR; |
61 | 3140 | my $ddl = eval { $tp->get_create_table($dbh, $self->{db}, $tbl) }; | ||
62 | 3141 | if ( my $e = $EVAL_ERROR ) { | ||
63 | 3142 | my $table_name = "$self->{db}.$tbl"; | ||
64 | 3143 | if ( $e =~ /\QTable '$table_name' doesn't exist/ ) { | ||
65 | 3144 | PTDEBUG && _d("Skipping $table_name because it no longer exists"); | ||
66 | 3145 | } | ||
67 | 3146 | else { | ||
68 | 3147 | warn "Skipping $table_name because SHOW CREATE TABLE failed: $e"; | ||
69 | 3148 | } | ||
70 | 3149 | next; | ||
71 | 3150 | } | ||
72 | 3142 | my $tbl_struct = $tp->parse($ddl); | 3151 | my $tbl_struct = $tp->parse($ddl); |
73 | 3143 | if ( $self->engine_is_allowed($tbl_struct->{engine}) ) { | 3152 | if ( $self->engine_is_allowed($tbl_struct->{engine}) ) { |
74 | 3144 | return { | 3153 | return { |
75 | 3145 | 3154 | ||
76 | === modified file 'bin/pt-find' | |||
77 | --- bin/pt-find 2012-10-22 18:17:08 +0000 | |||
78 | +++ bin/pt-find 2012-10-30 21:38:20 +0000 | |||
79 | @@ -1623,13 +1623,11 @@ | |||
80 | 1623 | PTDEBUG && _d($show_sql); | 1623 | PTDEBUG && _d($show_sql); |
81 | 1624 | my $href; | 1624 | my $href; |
82 | 1625 | eval { $href = $dbh->selectrow_hashref($show_sql); }; | 1625 | eval { $href = $dbh->selectrow_hashref($show_sql); }; |
86 | 1626 | if ( $EVAL_ERROR ) { | 1626 | if ( my $e = $EVAL_ERROR ) { |
84 | 1627 | PTDEBUG && _d($EVAL_ERROR); | ||
85 | 1628 | |||
87 | 1629 | PTDEBUG && _d($old_sql_mode); | 1627 | PTDEBUG && _d($old_sql_mode); |
88 | 1630 | $dbh->do($old_sql_mode); | 1628 | $dbh->do($old_sql_mode); |
89 | 1631 | 1629 | ||
91 | 1632 | return; | 1630 | die $e; |
92 | 1633 | } | 1631 | } |
93 | 1634 | 1632 | ||
94 | 1635 | PTDEBUG && _d($old_sql_mode); | 1633 | PTDEBUG && _d($old_sql_mode); |
95 | 1636 | 1634 | ||
96 | === modified file 'bin/pt-heartbeat' | |||
97 | --- bin/pt-heartbeat 2012-10-22 18:17:08 +0000 | |||
98 | +++ bin/pt-heartbeat 2012-10-30 21:38:20 +0000 | |||
99 | @@ -2549,13 +2549,11 @@ | |||
100 | 2549 | PTDEBUG && _d($show_sql); | 2549 | PTDEBUG && _d($show_sql); |
101 | 2550 | my $href; | 2550 | my $href; |
102 | 2551 | eval { $href = $dbh->selectrow_hashref($show_sql); }; | 2551 | eval { $href = $dbh->selectrow_hashref($show_sql); }; |
106 | 2552 | if ( $EVAL_ERROR ) { | 2552 | if ( my $e = $EVAL_ERROR ) { |
104 | 2553 | PTDEBUG && _d($EVAL_ERROR); | ||
105 | 2554 | |||
107 | 2555 | PTDEBUG && _d($old_sql_mode); | 2553 | PTDEBUG && _d($old_sql_mode); |
108 | 2556 | $dbh->do($old_sql_mode); | 2554 | $dbh->do($old_sql_mode); |
109 | 2557 | 2555 | ||
111 | 2558 | return; | 2556 | die $e; |
112 | 2559 | } | 2557 | } |
113 | 2560 | 2558 | ||
114 | 2561 | PTDEBUG && _d($old_sql_mode); | 2559 | PTDEBUG && _d($old_sql_mode); |
115 | 2562 | 2560 | ||
116 | === modified file 'bin/pt-index-usage' | |||
117 | --- bin/pt-index-usage 2012-10-22 18:17:08 +0000 | |||
118 | +++ bin/pt-index-usage 2012-10-30 21:38:20 +0000 | |||
119 | @@ -2821,13 +2821,11 @@ | |||
120 | 2821 | PTDEBUG && _d($show_sql); | 2821 | PTDEBUG && _d($show_sql); |
121 | 2822 | my $href; | 2822 | my $href; |
122 | 2823 | eval { $href = $dbh->selectrow_hashref($show_sql); }; | 2823 | eval { $href = $dbh->selectrow_hashref($show_sql); }; |
126 | 2824 | if ( $EVAL_ERROR ) { | 2824 | if ( my $e = $EVAL_ERROR ) { |
124 | 2825 | PTDEBUG && _d($EVAL_ERROR); | ||
125 | 2826 | |||
127 | 2827 | PTDEBUG && _d($old_sql_mode); | 2825 | PTDEBUG && _d($old_sql_mode); |
128 | 2828 | $dbh->do($old_sql_mode); | 2826 | $dbh->do($old_sql_mode); |
129 | 2829 | 2827 | ||
131 | 2830 | return; | 2828 | die $e; |
132 | 2831 | } | 2829 | } |
133 | 2832 | 2830 | ||
134 | 2833 | PTDEBUG && _d($old_sql_mode); | 2831 | PTDEBUG && _d($old_sql_mode); |
135 | @@ -3968,7 +3966,18 @@ | |||
136 | 3968 | } | 3966 | } |
137 | 3969 | 3967 | ||
138 | 3970 | while ( my $tbl = shift @{$self->{tbls}} ) { | 3968 | while ( my $tbl = shift @{$self->{tbls}} ) { |
140 | 3971 | my $ddl = $tp->get_create_table($dbh, $self->{db}, $tbl); | 3969 | local $EVAL_ERROR; |
141 | 3970 | my $ddl = eval { $tp->get_create_table($dbh, $self->{db}, $tbl) }; | ||
142 | 3971 | if ( my $e = $EVAL_ERROR ) { | ||
143 | 3972 | my $table_name = "$self->{db}.$tbl"; | ||
144 | 3973 | if ( $e =~ /\QTable '$table_name' doesn't exist/ ) { | ||
145 | 3974 | PTDEBUG && _d("Skipping $table_name because it no longer exists"); | ||
146 | 3975 | } | ||
147 | 3976 | else { | ||
148 | 3977 | warn "Skipping $table_name because SHOW CREATE TABLE failed: $e"; | ||
149 | 3978 | } | ||
150 | 3979 | next; | ||
151 | 3980 | } | ||
152 | 3972 | my $tbl_struct = $tp->parse($ddl); | 3981 | my $tbl_struct = $tp->parse($ddl); |
153 | 3973 | if ( $self->engine_is_allowed($tbl_struct->{engine}) ) { | 3982 | if ( $self->engine_is_allowed($tbl_struct->{engine}) ) { |
154 | 3974 | return { | 3983 | return { |
155 | 3975 | 3984 | ||
156 | === modified file 'bin/pt-kill' | |||
157 | --- bin/pt-kill 2012-10-22 18:17:08 +0000 | |||
158 | +++ bin/pt-kill 2012-10-30 21:38:20 +0000 | |||
159 | @@ -2499,13 +2499,11 @@ | |||
160 | 2499 | PTDEBUG && _d($show_sql); | 2499 | PTDEBUG && _d($show_sql); |
161 | 2500 | my $href; | 2500 | my $href; |
162 | 2501 | eval { $href = $dbh->selectrow_hashref($show_sql); }; | 2501 | eval { $href = $dbh->selectrow_hashref($show_sql); }; |
166 | 2502 | if ( $EVAL_ERROR ) { | 2502 | if ( my $e = $EVAL_ERROR ) { |
164 | 2503 | PTDEBUG && _d($EVAL_ERROR); | ||
165 | 2504 | |||
167 | 2505 | PTDEBUG && _d($old_sql_mode); | 2503 | PTDEBUG && _d($old_sql_mode); |
168 | 2506 | $dbh->do($old_sql_mode); | 2504 | $dbh->do($old_sql_mode); |
169 | 2507 | 2505 | ||
171 | 2508 | return; | 2506 | die $e; |
172 | 2509 | } | 2507 | } |
173 | 2510 | 2508 | ||
174 | 2511 | PTDEBUG && _d($old_sql_mode); | 2509 | PTDEBUG && _d($old_sql_mode); |
175 | @@ -4807,7 +4805,9 @@ | |||
176 | 4807 | PTDEBUG && _d($sql); | 4805 | PTDEBUG && _d($sql); |
177 | 4808 | my $row = $self->{dbh}->selectrow_arrayref($sql); | 4806 | my $row = $self->{dbh}->selectrow_arrayref($sql); |
178 | 4809 | PTDEBUG && _d(defined $row ? @$row : 'undef'); | 4807 | PTDEBUG && _d(defined $row ? @$row : 'undef'); |
180 | 4810 | $self->{is_cluster_node} = $row && $row->[0] ? 1 : 0; | 4808 | $self->{is_cluster_node} = $row && $row->[1] |
181 | 4809 | ? ($row->[1] eq 'ON' || $row->[1] eq '1') | ||
182 | 4810 | : 0; | ||
183 | 4811 | 4811 | ||
184 | 4812 | return $self->{is_cluster_node}; | 4812 | return $self->{is_cluster_node}; |
185 | 4813 | } | 4813 | } |
186 | 4814 | 4814 | ||
187 | === modified file 'bin/pt-online-schema-change' | |||
188 | --- bin/pt-online-schema-change 2012-10-22 20:23:05 +0000 | |||
189 | +++ bin/pt-online-schema-change 2012-10-30 21:38:20 +0000 | |||
190 | @@ -2733,13 +2733,11 @@ | |||
191 | 2733 | PTDEBUG && _d($show_sql); | 2733 | PTDEBUG && _d($show_sql); |
192 | 2734 | my $href; | 2734 | my $href; |
193 | 2735 | eval { $href = $dbh->selectrow_hashref($show_sql); }; | 2735 | eval { $href = $dbh->selectrow_hashref($show_sql); }; |
197 | 2736 | if ( $EVAL_ERROR ) { | 2736 | if ( my $e = $EVAL_ERROR ) { |
195 | 2737 | PTDEBUG && _d($EVAL_ERROR); | ||
196 | 2738 | |||
198 | 2739 | PTDEBUG && _d($old_sql_mode); | 2737 | PTDEBUG && _d($old_sql_mode); |
199 | 2740 | $dbh->do($old_sql_mode); | 2738 | $dbh->do($old_sql_mode); |
200 | 2741 | 2739 | ||
202 | 2742 | return; | 2740 | die $e; |
203 | 2743 | } | 2741 | } |
204 | 2744 | 2742 | ||
205 | 2745 | PTDEBUG && _d($old_sql_mode); | 2743 | PTDEBUG && _d($old_sql_mode); |
206 | @@ -3437,7 +3435,9 @@ | |||
207 | 3437 | PTDEBUG && _d($sql); | 3435 | PTDEBUG && _d($sql); |
208 | 3438 | my $row = $self->{dbh}->selectrow_arrayref($sql); | 3436 | my $row = $self->{dbh}->selectrow_arrayref($sql); |
209 | 3439 | PTDEBUG && _d(defined $row ? @$row : 'undef'); | 3437 | PTDEBUG && _d(defined $row ? @$row : 'undef'); |
211 | 3440 | $self->{is_cluster_node} = $row && $row->[0] ? 1 : 0; | 3438 | $self->{is_cluster_node} = $row && $row->[1] |
212 | 3439 | ? ($row->[1] eq 'ON' || $row->[1] eq '1') | ||
213 | 3440 | : 0; | ||
214 | 3441 | 3441 | ||
215 | 3442 | return $self->{is_cluster_node}; | 3442 | return $self->{is_cluster_node}; |
216 | 3443 | } | 3443 | } |
217 | 3444 | 3444 | ||
218 | === modified file 'bin/pt-query-advisor' | |||
219 | --- bin/pt-query-advisor 2012-10-22 18:17:08 +0000 | |||
220 | +++ bin/pt-query-advisor 2012-10-30 21:38:20 +0000 | |||
221 | @@ -5311,13 +5311,11 @@ | |||
222 | 5311 | PTDEBUG && _d($show_sql); | 5311 | PTDEBUG && _d($show_sql); |
223 | 5312 | my $href; | 5312 | my $href; |
224 | 5313 | eval { $href = $dbh->selectrow_hashref($show_sql); }; | 5313 | eval { $href = $dbh->selectrow_hashref($show_sql); }; |
228 | 5314 | if ( $EVAL_ERROR ) { | 5314 | if ( my $e = $EVAL_ERROR ) { |
226 | 5315 | PTDEBUG && _d($EVAL_ERROR); | ||
227 | 5316 | |||
229 | 5317 | PTDEBUG && _d($old_sql_mode); | 5315 | PTDEBUG && _d($old_sql_mode); |
230 | 5318 | $dbh->do($old_sql_mode); | 5316 | $dbh->do($old_sql_mode); |
231 | 5319 | 5317 | ||
233 | 5320 | return; | 5318 | die $e; |
234 | 5321 | } | 5319 | } |
235 | 5322 | 5320 | ||
236 | 5323 | PTDEBUG && _d($old_sql_mode); | 5321 | PTDEBUG && _d($old_sql_mode); |
237 | 5324 | 5322 | ||
238 | === modified file 'bin/pt-query-digest' | |||
239 | --- bin/pt-query-digest 2012-10-22 18:17:08 +0000 | |||
240 | +++ bin/pt-query-digest 2012-10-30 21:38:20 +0000 | |||
241 | @@ -8140,13 +8140,11 @@ | |||
242 | 8140 | PTDEBUG && _d($show_sql); | 8140 | PTDEBUG && _d($show_sql); |
243 | 8141 | my $href; | 8141 | my $href; |
244 | 8142 | eval { $href = $dbh->selectrow_hashref($show_sql); }; | 8142 | eval { $href = $dbh->selectrow_hashref($show_sql); }; |
248 | 8143 | if ( $EVAL_ERROR ) { | 8143 | if ( my $e = $EVAL_ERROR ) { |
246 | 8144 | PTDEBUG && _d($EVAL_ERROR); | ||
247 | 8145 | |||
249 | 8146 | PTDEBUG && _d($old_sql_mode); | 8144 | PTDEBUG && _d($old_sql_mode); |
250 | 8147 | $dbh->do($old_sql_mode); | 8145 | $dbh->do($old_sql_mode); |
251 | 8148 | 8146 | ||
253 | 8149 | return; | 8147 | die $e; |
254 | 8150 | } | 8148 | } |
255 | 8151 | 8149 | ||
256 | 8152 | PTDEBUG && _d($old_sql_mode); | 8150 | PTDEBUG && _d($old_sql_mode); |
257 | 8153 | 8151 | ||
258 | === modified file 'bin/pt-table-checksum' | |||
259 | --- bin/pt-table-checksum 2012-10-26 23:06:21 +0000 | |||
260 | +++ bin/pt-table-checksum 2012-10-30 21:38:20 +0000 | |||
261 | @@ -3725,13 +3725,11 @@ | |||
262 | 3725 | PTDEBUG && _d($show_sql); | 3725 | PTDEBUG && _d($show_sql); |
263 | 3726 | my $href; | 3726 | my $href; |
264 | 3727 | eval { $href = $dbh->selectrow_hashref($show_sql); }; | 3727 | eval { $href = $dbh->selectrow_hashref($show_sql); }; |
268 | 3728 | if ( $EVAL_ERROR ) { | 3728 | if ( my $e = $EVAL_ERROR ) { |
266 | 3729 | PTDEBUG && _d($EVAL_ERROR); | ||
267 | 3730 | |||
269 | 3731 | PTDEBUG && _d($old_sql_mode); | 3729 | PTDEBUG && _d($old_sql_mode); |
270 | 3732 | $dbh->do($old_sql_mode); | 3730 | $dbh->do($old_sql_mode); |
271 | 3733 | 3731 | ||
273 | 3734 | return; | 3732 | die $e; |
274 | 3735 | } | 3733 | } |
275 | 3736 | 3734 | ||
276 | 3737 | PTDEBUG && _d($old_sql_mode); | 3735 | PTDEBUG && _d($old_sql_mode); |
277 | @@ -6784,7 +6782,18 @@ | |||
278 | 6784 | } | 6782 | } |
279 | 6785 | 6783 | ||
280 | 6786 | while ( my $tbl = shift @{$self->{tbls}} ) { | 6784 | while ( my $tbl = shift @{$self->{tbls}} ) { |
282 | 6787 | my $ddl = $tp->get_create_table($dbh, $self->{db}, $tbl); | 6785 | local $EVAL_ERROR; |
283 | 6786 | my $ddl = eval { $tp->get_create_table($dbh, $self->{db}, $tbl) }; | ||
284 | 6787 | if ( my $e = $EVAL_ERROR ) { | ||
285 | 6788 | my $table_name = "$self->{db}.$tbl"; | ||
286 | 6789 | if ( $e =~ /\QTable '$table_name' doesn't exist/ ) { | ||
287 | 6790 | PTDEBUG && _d("Skipping $table_name because it no longer exists"); | ||
288 | 6791 | } | ||
289 | 6792 | else { | ||
290 | 6793 | warn "Skipping $table_name because SHOW CREATE TABLE failed: $e"; | ||
291 | 6794 | } | ||
292 | 6795 | next; | ||
293 | 6796 | } | ||
294 | 6788 | my $tbl_struct = $tp->parse($ddl); | 6797 | my $tbl_struct = $tp->parse($ddl); |
295 | 6789 | if ( $self->engine_is_allowed($tbl_struct->{engine}) ) { | 6798 | if ( $self->engine_is_allowed($tbl_struct->{engine}) ) { |
296 | 6790 | return { | 6799 | return { |
297 | 6791 | 6800 | ||
298 | === modified file 'bin/pt-table-sync' | |||
299 | --- bin/pt-table-sync 2012-10-22 18:17:08 +0000 | |||
300 | +++ bin/pt-table-sync 2012-10-30 21:38:20 +0000 | |||
301 | @@ -2990,7 +2990,7 @@ | |||
302 | 2990 | my ( $self, $dbh, $quoter, $db, $tbl, $what ) = @_; | 2990 | my ( $self, $dbh, $quoter, $db, $tbl, $what ) = @_; |
303 | 2991 | 2991 | ||
304 | 2992 | if ( $what eq 'table' ) { | 2992 | if ( $what eq 'table' ) { |
306 | 2993 | my $ddl = $self->get_create_table($dbh, $quoter, $db, $tbl); | 2993 | my $ddl = $self->get_create_table($dbh, $dbh, $db, $tbl); |
307 | 2994 | return unless $ddl; | 2994 | return unless $ddl; |
308 | 2995 | if ( $ddl->[0] eq 'table' ) { | 2995 | if ( $ddl->[0] eq 'table' ) { |
309 | 2996 | return $before | 2996 | return $before |
310 | @@ -3033,7 +3033,7 @@ | |||
311 | 3033 | } | 3033 | } |
312 | 3034 | } | 3034 | } |
313 | 3035 | elsif ( $what eq 'view' ) { | 3035 | elsif ( $what eq 'view' ) { |
315 | 3036 | my $ddl = $self->get_create_table($dbh, $quoter, $db, $tbl); | 3036 | my $ddl = $self->get_create_table($dbh, $dbh, $db, $tbl); |
316 | 3037 | return '/*!50001 DROP TABLE IF EXISTS ' . $quoter->quote($tbl) . "*/;\n" | 3037 | return '/*!50001 DROP TABLE IF EXISTS ' . $quoter->quote($tbl) . "*/;\n" |
317 | 3038 | . '/*!50001 DROP VIEW IF EXISTS ' . $quoter->quote($tbl) . "*/;\n" | 3038 | . '/*!50001 DROP VIEW IF EXISTS ' . $quoter->quote($tbl) . "*/;\n" |
318 | 3039 | . '/*!50001 ' . $ddl->[1] . "*/;\n"; | 3039 | . '/*!50001 ' . $ddl->[1] . "*/;\n"; |
319 | 3040 | 3040 | ||
320 | === modified file 'bin/pt-upgrade' | |||
321 | --- bin/pt-upgrade 2012-10-22 18:17:08 +0000 | |||
322 | +++ bin/pt-upgrade 2012-10-30 21:38:20 +0000 | |||
323 | @@ -498,13 +498,11 @@ | |||
324 | 498 | PTDEBUG && _d($show_sql); | 498 | PTDEBUG && _d($show_sql); |
325 | 499 | my $href; | 499 | my $href; |
326 | 500 | eval { $href = $dbh->selectrow_hashref($show_sql); }; | 500 | eval { $href = $dbh->selectrow_hashref($show_sql); }; |
330 | 501 | if ( $EVAL_ERROR ) { | 501 | if ( my $e = $EVAL_ERROR ) { |
328 | 502 | PTDEBUG && _d($EVAL_ERROR); | ||
329 | 503 | |||
331 | 504 | PTDEBUG && _d($old_sql_mode); | 502 | PTDEBUG && _d($old_sql_mode); |
332 | 505 | $dbh->do($old_sql_mode); | 503 | $dbh->do($old_sql_mode); |
333 | 506 | 504 | ||
335 | 507 | return; | 505 | die $e; |
336 | 508 | } | 506 | } |
337 | 509 | 507 | ||
338 | 510 | PTDEBUG && _d($old_sql_mode); | 508 | PTDEBUG && _d($old_sql_mode); |
339 | 511 | 509 | ||
340 | === modified file 'lib/SchemaIterator.pm' | |||
341 | --- lib/SchemaIterator.pm 2012-04-03 18:21:15 +0000 | |||
342 | +++ lib/SchemaIterator.pm 2012-10-30 21:38:20 +0000 | |||
343 | @@ -352,7 +352,22 @@ | |||
344 | 352 | } | 352 | } |
345 | 353 | 353 | ||
346 | 354 | while ( my $tbl = shift @{$self->{tbls}} ) { | 354 | while ( my $tbl = shift @{$self->{tbls}} ) { |
348 | 355 | my $ddl = $tp->get_create_table($dbh, $self->{db}, $tbl); | 355 | local $EVAL_ERROR; |
349 | 356 | my $ddl = eval { $tp->get_create_table($dbh, $self->{db}, $tbl) }; | ||
350 | 357 | if ( my $e = $EVAL_ERROR ) { | ||
351 | 358 | my $table_name = "$self->{db}.$tbl"; | ||
352 | 359 | # SHOW CREATE TABLE failed. This is a bit puzzling; | ||
353 | 360 | # maybe the table got dropped, or crashed. Not much we can | ||
354 | 361 | # do about it; If the table is missing, just PTDEBUG it, but | ||
355 | 362 | # otherwise, warn with the error. | ||
356 | 363 | if ( $e =~ /\QTable '$table_name' doesn't exist/ ) { | ||
357 | 364 | PTDEBUG && _d("Skipping $table_name because it no longer exists"); | ||
358 | 365 | } | ||
359 | 366 | else { | ||
360 | 367 | warn "Skipping $table_name because SHOW CREATE TABLE failed: $e"; | ||
361 | 368 | } | ||
362 | 369 | next; | ||
363 | 370 | } | ||
364 | 356 | my $tbl_struct = $tp->parse($ddl); | 371 | my $tbl_struct = $tp->parse($ddl); |
365 | 357 | if ( $self->engine_is_allowed($tbl_struct->{engine}) ) { | 372 | if ( $self->engine_is_allowed($tbl_struct->{engine}) ) { |
366 | 358 | return { | 373 | return { |
367 | 359 | 374 | ||
368 | === modified file 'lib/TableParser.pm' | |||
369 | --- lib/TableParser.pm 2012-10-19 23:14:07 +0000 | |||
370 | +++ lib/TableParser.pm 2012-10-30 21:38:20 +0000 | |||
371 | @@ -82,18 +82,12 @@ | |||
372 | 82 | PTDEBUG && _d($show_sql); | 82 | PTDEBUG && _d($show_sql); |
373 | 83 | my $href; | 83 | my $href; |
374 | 84 | eval { $href = $dbh->selectrow_hashref($show_sql); }; | 84 | eval { $href = $dbh->selectrow_hashref($show_sql); }; |
382 | 85 | if ( $EVAL_ERROR ) { | 85 | if ( my $e = $EVAL_ERROR ) { |
376 | 86 | # TODO: I think we fail silently for tools which may try to call | ||
377 | 87 | # this on temp tables, or don't care if the table goes away. We | ||
378 | 88 | # should warn $EVAL_ERROR and require callers to eval us and do | ||
379 | 89 | # what they want with the warning. | ||
380 | 90 | PTDEBUG && _d($EVAL_ERROR); | ||
381 | 91 | |||
383 | 92 | # Restore old SQL mode. | 86 | # Restore old SQL mode. |
384 | 93 | PTDEBUG && _d($old_sql_mode); | 87 | PTDEBUG && _d($old_sql_mode); |
385 | 94 | $dbh->do($old_sql_mode); | 88 | $dbh->do($old_sql_mode); |
386 | 95 | 89 | ||
388 | 96 | return; | 90 | die $e; |
389 | 97 | } | 91 | } |
390 | 98 | 92 | ||
391 | 99 | # Restore old SQL mode. | 93 | # Restore old SQL mode. |
392 | 100 | 94 | ||
393 | === modified file 't/lib/SchemaIterator.t' | |||
394 | --- t/lib/SchemaIterator.t 2012-06-07 03:14:20 +0000 | |||
395 | +++ t/lib/SchemaIterator.t 2012-10-30 21:38:20 +0000 | |||
396 | @@ -9,7 +9,7 @@ | |||
397 | 9 | use strict; | 9 | use strict; |
398 | 10 | use warnings FATAL => 'all'; | 10 | use warnings FATAL => 'all'; |
399 | 11 | use English qw(-no_match_vars); | 11 | use English qw(-no_match_vars); |
401 | 12 | use Test::More tests => 30; | 12 | use Test::More; |
402 | 13 | 13 | ||
403 | 14 | use SchemaIterator; | 14 | use SchemaIterator; |
404 | 15 | use FileIterator; | 15 | use FileIterator; |
405 | @@ -407,7 +407,75 @@ | |||
406 | 407 | ); | 407 | ); |
407 | 408 | 408 | ||
408 | 409 | # ############################################################################# | 409 | # ############################################################################# |
409 | 410 | # Bug 1047335: pt-duplicate-key-checker fails when it encounters a crashed table | ||
410 | 411 | # https://bugs.launchpad.net/percona-toolkit/+bug/1047335 | ||
411 | 412 | # ############################################################################# | ||
412 | 413 | |||
413 | 414 | use File::Spec; | ||
414 | 415 | |||
415 | 416 | my $master3_port = 2900; | ||
416 | 417 | diag(`$trunk/sandbox/stop-sandbox $master3_port >/dev/null`); | ||
417 | 418 | diag(`$trunk/sandbox/start-sandbox master $master3_port >/dev/null`); | ||
418 | 419 | my $dbh3 = $sb->get_dbh_for("master3"); | ||
419 | 420 | |||
420 | 421 | $sb->load_file('master3', File::Spec->catfile(qw(t lib samples bug_1047335_crashed_table.sql))); | ||
421 | 422 | my $sth = $dbh3->prepare("INSERT INTO bug_1047335.crashed_table (trx_id, etc) VALUES(?, ?)"); | ||
422 | 423 | $sth->execute($_, $_ x 100) for 1..1000; | ||
423 | 424 | $sth->finish(); | ||
424 | 425 | |||
425 | 426 | # Create the SI object before crashing the table | ||
426 | 427 | my $tmp_si = new SchemaIterator( | ||
427 | 428 | dbh => $dbh3, | ||
428 | 429 | OptionParser => $o, | ||
429 | 430 | Quoter => $q, | ||
430 | 431 | TableParser => $tp, | ||
431 | 432 | # This is needed because the way we corrupt tables | ||
432 | 433 | # accidentally removes the database from SHOW DATABASES | ||
433 | 434 | db => 'bug_1047335', | ||
434 | 435 | ); | ||
435 | 436 | |||
436 | 437 | my $master_basedir = File::Spec->catdir(File::Spec->tmpdir(), $master3_port); | ||
437 | 438 | my $db_dir = File::Spec->catdir($master_basedir, "data", "bug_1047335"); | ||
438 | 439 | my $myi = glob(File::Spec->catfile($db_dir, "crashed_table.[Mm][Yy][Iy]")); | ||
439 | 440 | my $frm = glob(File::Spec->catfile($db_dir, "crashed_table.[Ff][Rr][Mm]")); | ||
440 | 441 | |||
441 | 442 | die "Cannot find .myi file for crashed_table" unless $myi && -f $myi; | ||
442 | 443 | |||
443 | 444 | # Truncate the .myi file to corrupt it | ||
444 | 445 | truncate($myi, 4096); | ||
445 | 446 | |||
446 | 447 | use File::Slurp qw( prepend_file append_file write_file ); | ||
447 | 448 | |||
448 | 449 | # Corrupt the .frm file | ||
449 | 450 | open my $urand_fh, q{<}, "/dev/urandom" | ||
450 | 451 | or die "Cannot open /dev/urandom"; | ||
451 | 452 | prepend_file($frm, scalar(<$urand_fh>)); | ||
452 | 453 | append_file($frm, scalar(<$urand_fh>)); | ||
453 | 454 | close $urand_fh; | ||
454 | 455 | |||
455 | 456 | $dbh3->do("FLUSH TABLES"); | ||
456 | 457 | eval { $dbh3->do("SELECT etc FROM bug_1047335.crashed_table WHERE etc LIKE '10001' ORDER BY id ASC LIMIT 1") }; | ||
457 | 458 | |||
458 | 459 | my $w = ''; | ||
459 | 460 | { | ||
460 | 461 | local $SIG{__WARN__} = sub { $w .= shift }; | ||
461 | 462 | 1 while $tmp_si->next(); | ||
462 | 463 | } | ||
463 | 464 | |||
464 | 465 | like( | ||
465 | 466 | $w, | ||
466 | 467 | qr/because SHOW CREATE TABLE failed:/, | ||
467 | 468 | "->next() gives a warning if ->get_create_table dies from a strange error", | ||
468 | 469 | ); | ||
469 | 470 | |||
470 | 471 | # This might fail. Doesn't matter -- stop_sandbox will just rm -rf the folder | ||
471 | 472 | eval { $dbh3->do("DROP DATABASE IF EXISTS bug_1047335") }; | ||
472 | 473 | |||
473 | 474 | diag(`$trunk/sandbox/stop-sandbox $master3_port >/dev/null`); | ||
474 | 475 | |||
475 | 476 | # ############################################################################# | ||
476 | 410 | # Done. | 477 | # Done. |
477 | 411 | # ############################################################################# | 478 | # ############################################################################# |
478 | 412 | ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox"); | 479 | ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox"); |
480 | 413 | exit; | 480 | |
481 | 481 | done_testing; | ||
482 | 414 | 482 | ||
483 | === modified file 't/lib/TableParser.t' | |||
484 | --- t/lib/TableParser.t 2012-10-20 23:59:28 +0000 | |||
485 | +++ t/lib/TableParser.t 2012-10-30 21:38:20 +0000 | |||
486 | @@ -9,7 +9,7 @@ | |||
487 | 9 | use strict; | 9 | use strict; |
488 | 10 | use warnings FATAL => 'all'; | 10 | use warnings FATAL => 'all'; |
489 | 11 | use English qw(-no_match_vars); | 11 | use English qw(-no_match_vars); |
491 | 12 | use Test::More tests => 40; | 12 | use Test::More; |
492 | 13 | 13 | ||
493 | 14 | use TableParser; | 14 | use TableParser; |
494 | 15 | use Quoter; | 15 | use Quoter; |
495 | @@ -32,10 +32,10 @@ | |||
496 | 32 | skip 'Sandbox master does not have the sakila database', 2 | 32 | skip 'Sandbox master does not have the sakila database', 2 |
497 | 33 | unless @{$dbh->selectcol_arrayref("SHOW DATABASES LIKE 'sakila'")}; | 33 | unless @{$dbh->selectcol_arrayref("SHOW DATABASES LIKE 'sakila'")}; |
498 | 34 | 34 | ||
503 | 35 | is( | 35 | eval { $tp->get_create_table($dbh, 'sakila', 'FOO') }; |
504 | 36 | $tp->get_create_table($dbh, 'sakila', 'FOO'), | 36 | ok( |
505 | 37 | undef, | 37 | $EVAL_ERROR, |
506 | 38 | "get_create_table(nonexistent table)" | 38 | "get_create_table(nonexistent table) dies" |
507 | 39 | ); | 39 | ); |
508 | 40 | 40 | ||
509 | 41 | my $ddl = $tp->get_create_table($dbh, 'sakila', 'actor'); | 41 | my $ddl = $tp->get_create_table($dbh, 'sakila', 'actor'); |
510 | @@ -893,8 +893,67 @@ | |||
511 | 893 | ); | 893 | ); |
512 | 894 | 894 | ||
513 | 895 | # ############################################################################# | 895 | # ############################################################################# |
514 | 896 | # Bug 1047335: pt-duplicate-key-checker fails when it encounters a crashed table | ||
515 | 897 | # https://bugs.launchpad.net/percona-toolkit/+bug/1047335 | ||
516 | 898 | # ############################################################################# | ||
517 | 899 | |||
518 | 900 | # We need to create a new server here, otherwise the whole test suite might die | ||
519 | 901 | # if the crashed table can't be dropped. | ||
520 | 902 | |||
521 | 903 | use File::Spec; | ||
522 | 904 | |||
523 | 905 | my $master3_port = 2900; | ||
524 | 906 | diag(`$trunk/sandbox/stop-sandbox $master3_port >/dev/null`); | ||
525 | 907 | diag(`$trunk/sandbox/start-sandbox master $master3_port >/dev/null`); | ||
526 | 908 | my $dbh3 = $sb->get_dbh_for("master3"); | ||
527 | 909 | |||
528 | 910 | $sb->load_file('master3', File::Spec->catfile(qw(t lib samples bug_1047335_crashed_table.sql))); | ||
529 | 911 | my $sth = $dbh3->prepare("INSERT INTO bug_1047335.crashed_table (trx_id, etc) VALUES(?, ?)"); | ||
530 | 912 | $sth->execute($_, $_ x 100) for 1..1000; | ||
531 | 913 | $sth->finish(); | ||
532 | 914 | |||
533 | 915 | |||
534 | 916 | my $master_basedir = File::Spec->catdir(File::Spec->tmpdir(), $master3_port); | ||
535 | 917 | my $db_dir = File::Spec->catdir($master_basedir, "data", "bug_1047335"); | ||
536 | 918 | my $myi = glob(File::Spec->catfile($db_dir, "crashed_table.[Mm][Yy][Iy]")); | ||
537 | 919 | my $frm = glob(File::Spec->catfile($db_dir, "crashed_table.[Ff][Rr][Mm]")); | ||
538 | 920 | |||
539 | 921 | die "Cannot find .myi file for crashed_table" unless $myi && -f $myi; | ||
540 | 922 | |||
541 | 923 | # Truncate the .myi file to corrupt it | ||
542 | 924 | truncate($myi, 4096); | ||
543 | 925 | |||
544 | 926 | # Corrupt the .frm file | ||
545 | 927 | open my $urand_fh, q{<}, "/dev/urandom" | ||
546 | 928 | or die "Cannot open /dev/urandom: $OS_ERROR"; | ||
547 | 929 | |||
548 | 930 | open my $tmp_fh, q{>}, $frm | ||
549 | 931 | or die "Cannot open $frm: $OS_ERROR"; | ||
550 | 932 | print { $tmp_fh } scalar(<$urand_fh>), slurp_file($frm), scalar(<$urand_fh>); | ||
551 | 933 | close $tmp_fh; | ||
552 | 934 | |||
553 | 935 | close $urand_fh; | ||
554 | 936 | |||
555 | 937 | $dbh3->do("FLUSH TABLES"); | ||
556 | 938 | eval { $dbh3->do("SELECT etc FROM bug_1047335.crashed_table WHERE etc LIKE '10001' ORDER BY id ASC LIMIT 1") }; | ||
557 | 939 | |||
558 | 940 | eval { $tp->get_create_table($dbh3, 'bug_1047335', 'crashed_table') }; | ||
559 | 941 | ok( | ||
560 | 942 | $EVAL_ERROR, | ||
561 | 943 | "get_create_table dies if SHOW CREATE TABLE failed", | ||
562 | 944 | ); | ||
563 | 945 | |||
564 | 946 | # This might fail. Doesn't matter -- stop_sandbox will just rm -rf the folder | ||
565 | 947 | eval { $dbh3->do("DROP DATABASE IF EXISTS bug_1047335") }; | ||
566 | 948 | |||
567 | 949 | diag(`$trunk/sandbox/stop-sandbox $master3_port >/dev/null`); | ||
568 | 950 | |||
569 | 951 | # ############################################################################# | ||
570 | 896 | # Done. | 952 | # Done. |
571 | 897 | # ############################################################################# | 953 | # ############################################################################# |
572 | 898 | $sb->wipe_clean($dbh) if $dbh; | 954 | $sb->wipe_clean($dbh) if $dbh; |
573 | 899 | ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox"); | 955 | ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox"); |
574 | 956 | |||
575 | 957 | done_testing; | ||
576 | 958 | |||
577 | 900 | exit; | 959 | exit; |
578 | 901 | 960 | ||
579 | === added file 't/lib/samples/bug_1047335_crashed_table.sql' | |||
580 | --- t/lib/samples/bug_1047335_crashed_table.sql 1970-01-01 00:00:00 +0000 | |||
581 | +++ t/lib/samples/bug_1047335_crashed_table.sql 2012-10-30 21:38:20 +0000 | |||
582 | @@ -0,0 +1,11 @@ | |||
583 | 1 | DROP DATABASE IF EXISTS bug_1047335; | ||
584 | 2 | CREATE DATABASE bug_1047335; | ||
585 | 3 | USE bug_1047335; | ||
586 | 4 | CREATE TABLE bug_1047335.crashed_table ( | ||
587 | 5 | `id` int(10) unsigned NOT NULL auto_increment, | ||
588 | 6 | `trx_id` int(10) unsigned default NULL, | ||
589 | 7 | `etc` text, | ||
590 | 8 | PRIMARY KEY (`id`), | ||
591 | 9 | KEY `idx1` (`trx_id`), | ||
592 | 10 | KEY `idx2` (`trx_id`, `etc`(128)) | ||
593 | 11 | ) ENGINE=MyISAM; |
This diff has other stuff, for MasterSlave and PXC. Can you isolate just the changes for this branch/bug?