Merge lp:~sergei.glushchenko/percona-xtrabackup/BT30559-kill-long-selects into lp:percona-xtrabackup/2.1
- BT30559-kill-long-selects
- Merge into 2.1
Status: | Merged |
---|---|
Approved by: | Alexey Kopytov |
Approved revision: | no longer in the source branch. |
Merged at revision: | 613 |
Proposed branch: | lp:~sergei.glushchenko/percona-xtrabackup/BT30559-kill-long-selects |
Merge into: | lp:percona-xtrabackup/2.1 |
Diff against target: |
514 lines (+421/-3) 2 files modified
innobackupex (+240/-3) test/t/kill_long_selects.sh (+181/-0) |
To merge this branch: | bzr merge lp:~sergei.glushchenko/percona-xtrabackup/BT30559-kill-long-selects |
Related bugs: | |
Related blueprints: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Alexey Kopytov (community) | Approve | ||
Review via email: mp+164748@code.launchpad.net |
Commit message
Description of the change
Blueprint https:/
Try to catch the moment when no long queries are running.
Try to kill all the queries which block the global lock.
To determine a good moment, innobackupex analyses
SHOW FULL PROCESSLIST output, particularly looking into
Time field. If there is no process with Time greater than
specified threshold, the moment is considered to be good.
If no good moment been chatched during specified time,
innobackupex bail out.
After the global lock issued, spawn child process to kill
the queries which bloc the global lock.
There is a lot of Jenkins failures, most of them are unrelated.
There are potential issues with test case as it rely heavily on timings. Suggestions to improve are welcome.
http://
Sergei Glushchenko (sergei.glushchenko) wrote : | # |
Conflicts resolved.
Jenkins build: http://
Alexey Kopytov (akopytov) wrote : | # |
Sergei,
Thanks. I would like the following things in user-visible text to be fixed before it is merged. Otherwise approved.
- s/enales/enables/
- s/"before start "FLUSH TABLE WITH READ LOCK"/before FLUSH TABLES
WITH READ LOCK is started by innobackupex/
- s/time in seconds to wait moment when there are no.../time in
seconds to wait until there are no.../
- s/This option specifies number of seconds innobackupex will wait
after it issued the global lock and before it start to kill
queries/This option specifies the number of seconds innobackupex
waits between starting FLUSH TABLES WITH READ LOCK and killing
those queries that block it./
- s/which means no query killing/which means innobackupex will not
attempt to kill any queries/
- s/If value is not 0, innobackupex will wait not longer than
specified amount of seconds for a good moment to issue the global
lock. If no good moment being catched, innobackupex will bail out./
This option specifies time in seconds that innobackupex should
wait for queries that would block FTWRL before running it. If
there are still such queries when the timeout expires,
innobackupex terminates with an error.
- s/Default is 0 which means no waiting for a good moment, just issue
the global lock mandatory./Default is 0, in which case
innobackupex does not wait for queries to complete and starts FTWRL
immediately./
- s/This option specifes the minimum age of a query to be considered as
"long running" and potentially a blocker of the global lock. Such a
queries will prevent the global lock from being issued (see
--
--
This option specifies the query run time threshold which is used by
innobackupex to detect long-running queries with a non-zero value
of --lock-
long-running queries exist. This option has no effect if
--
Sergei Glushchenko (sergei.glushchenko) wrote : | # |
Alexey,
I made required changes. Also I removed two documentation items, which turned out to be a garbage.
=item --ftwrl-wait
and
=item --ftwrl-
I run test locally and, re-pushed the branch, but did not start Jenkins build.
Thanks,
Sergei.
Alexey Kopytov (akopytov) : | # |
Preview Diff
1 | === modified file 'innobackupex' | |||
2 | --- innobackupex 2013-05-22 10:25:21 +0000 | |||
3 | +++ innobackupex 2013-05-26 07:22:28 +0000 | |||
4 | @@ -202,6 +202,26 @@ | |||
5 | 202 | # process id of ibbackup program (runs as a child process of this script) | 202 | # process id of ibbackup program (runs as a child process of this script) |
6 | 203 | my $ibbackup_pid = ''; | 203 | my $ibbackup_pid = ''; |
7 | 204 | 204 | ||
8 | 205 | # process id of long queries killer | ||
9 | 206 | my $query_killer_pid; | ||
10 | 207 | |||
11 | 208 | # set kill long queries timeout in seconds | ||
12 | 209 | my $option_kill_long_queries_timeout = 0; | ||
13 | 210 | |||
14 | 211 | # waiting for an appropriate time to start FTWRL timeout | ||
15 | 212 | my $option_lock_wait_timeout = 0; | ||
16 | 213 | |||
17 | 214 | # how old should be query to be waited for | ||
18 | 215 | my $option_lock_wait_threshold = 60; | ||
19 | 216 | |||
20 | 217 | # which type of queries we are waiting for during the pre-FTWRL phase | ||
21 | 218 | # possible values are "update" and "all" | ||
22 | 219 | my $option_lock_wait_query_type = "all"; | ||
23 | 220 | |||
24 | 221 | # which type of queries wa are waiting when clearing the way for FTWRL | ||
25 | 222 | # by killing; possible values are "select" and "all" | ||
26 | 223 | my $option_kill_long_query_type = "all"; | ||
27 | 224 | |||
28 | 205 | # a counter for numbering mysql connection checks | 225 | # a counter for numbering mysql connection checks |
29 | 206 | my $hello_id = 0; | 226 | my $hello_id = 0; |
30 | 207 | 227 | ||
31 | @@ -277,7 +297,7 @@ | |||
32 | 277 | if ($mysql{dbh}) { | 297 | if ($mysql{dbh}) { |
33 | 278 | print STDERR "Connected successfully\n"; | 298 | print STDERR "Connected successfully\n"; |
34 | 279 | $option_ibbackup_binary = set_xtrabackup_version(); | 299 | $option_ibbackup_binary = set_xtrabackup_version(); |
36 | 280 | mysql_close(); | 300 | mysql_close(\%mysql); |
37 | 281 | } else { | 301 | } else { |
38 | 282 | die "Failed to connect to MySQL server to detect version.\nYou must set xtrabackup version to use with --ibbackup option.\nPossible values are xtrabackup_55 (for MySQL 5.5), xtrabackup_56 (for MySQL or Percona Server 5.6, or xtrabackup (for MySQL 5.1 with InnoDB plugin or Percona Server)\n"; | 302 | die "Failed to connect to MySQL server to detect version.\nYou must set xtrabackup version to use with --ibbackup option.\nPossible values are xtrabackup_55 (for MySQL 5.5), xtrabackup_56 (for MySQL or Percona Server 5.6, or xtrabackup (for MySQL 5.1 with InnoDB plugin or Percona Server)\n"; |
39 | 283 | } | 303 | } |
40 | @@ -1417,6 +1437,7 @@ | |||
41 | 1417 | # | 1437 | # |
42 | 1418 | # mysql_query subroutine send a query to MySQL server child process. | 1438 | # mysql_query subroutine send a query to MySQL server child process. |
43 | 1419 | # Parameters: | 1439 | # Parameters: |
44 | 1440 | # con mysql connection | ||
45 | 1420 | # query query to execute | 1441 | # query query to execute |
46 | 1421 | # | 1442 | # |
47 | 1422 | sub mysql_query { | 1443 | sub mysql_query { |
48 | @@ -1439,6 +1460,10 @@ | |||
49 | 1439 | } elsif ($query eq 'SHOW SLAVE STATUS') { | 1460 | } elsif ($query eq 'SHOW SLAVE STATUS') { |
50 | 1440 | $con->{slave_status} = | 1461 | $con->{slave_status} = |
51 | 1441 | $con->{dbh}->selectrow_hashref("SHOW SLAVE STATUS"); | 1462 | $con->{dbh}->selectrow_hashref("SHOW SLAVE STATUS"); |
52 | 1463 | } elsif ($query eq 'SHOW PROCESSLIST' or | ||
53 | 1464 | $query eq "SHOW FULL PROCESSLIST") { | ||
54 | 1465 | $con->{processlist} = | ||
55 | 1466 | $con->{dbh}->selectall_hashref($query, "Id"); | ||
56 | 1442 | } else { | 1467 | } else { |
57 | 1443 | $con->{dbh}->do($query); | 1468 | $con->{dbh}->do($query); |
58 | 1444 | } | 1469 | } |
59 | @@ -1602,16 +1627,183 @@ | |||
60 | 1602 | $mysql_slave_position = "master host '$master', filename '$filename', position $position"; | 1627 | $mysql_slave_position = "master host '$master', filename '$filename', position $position"; |
61 | 1603 | } | 1628 | } |
62 | 1604 | 1629 | ||
63 | 1630 | sub eat_sql_whitespace { | ||
64 | 1631 | my ($query) = @_; | ||
65 | 1632 | |||
66 | 1633 | while (1) { | ||
67 | 1634 | if ($query =~ m/^\/\*/) { | ||
68 | 1635 | $query =~ s/^\/\*.*?\*\///s; | ||
69 | 1636 | } elsif ($query =~ m/^[ \t\n\r]/s) { | ||
70 | 1637 | $query =~ s/^[ \t\n\r]+//s; | ||
71 | 1638 | } elsif ($query =~ m/^\(/) { | ||
72 | 1639 | $query =~ s/^\(//; | ||
73 | 1640 | } else { | ||
74 | 1641 | return $query; | ||
75 | 1642 | } | ||
76 | 1643 | } | ||
77 | 1644 | |||
78 | 1645 | } | ||
79 | 1646 | |||
80 | 1647 | |||
81 | 1648 | sub is_query { | ||
82 | 1649 | my ($query) = @_; | ||
83 | 1650 | |||
84 | 1651 | $query = eat_sql_whitespace($query); | ||
85 | 1652 | if ($query =~ | ||
86 | 1653 | m/^(insert|update|delete|replace|alter|load|select|do|handler|call|execute|begin)/i) { | ||
87 | 1654 | return 1; | ||
88 | 1655 | } | ||
89 | 1656 | |||
90 | 1657 | return 0; | ||
91 | 1658 | } | ||
92 | 1659 | |||
93 | 1660 | |||
94 | 1661 | sub is_select_query { | ||
95 | 1662 | my ($query) = @_; | ||
96 | 1663 | |||
97 | 1664 | $query = eat_sql_whitespace($query); | ||
98 | 1665 | if ($query =~ m/^select/i) { | ||
99 | 1666 | return 1; | ||
100 | 1667 | } | ||
101 | 1668 | |||
102 | 1669 | return 0; | ||
103 | 1670 | } | ||
104 | 1671 | |||
105 | 1672 | |||
106 | 1673 | sub is_update_query { | ||
107 | 1674 | my ($query) = @_; | ||
108 | 1675 | |||
109 | 1676 | $query = eat_sql_whitespace($query); | ||
110 | 1677 | if ($query =~ m/^(insert|update|delete|replace|alter|load)/i) { | ||
111 | 1678 | return 1; | ||
112 | 1679 | } | ||
113 | 1680 | |||
114 | 1681 | return 0; | ||
115 | 1682 | } | ||
116 | 1683 | |||
117 | 1684 | |||
118 | 1685 | sub have_queries_to_wait_for { | ||
119 | 1686 | my ($con, $threshold) = @_; | ||
120 | 1687 | |||
121 | 1688 | $now = current_time(); | ||
122 | 1689 | |||
123 | 1690 | mysql_query($con, "SHOW FULL PROCESSLIST"); | ||
124 | 1691 | |||
125 | 1692 | my $processlist = $con->{processlist}; | ||
126 | 1693 | |||
127 | 1694 | while (my ($id, $process) = each %$processlist) { | ||
128 | 1695 | if (defined($process->{Info}) && | ||
129 | 1696 | $process->{Time} >= $threshold && | ||
130 | 1697 | (($option_lock_wait_query_type eq "all" && | ||
131 | 1698 | is_query($process->{Info})) || | ||
132 | 1699 | is_update_query($process->{Info}))) { | ||
133 | 1700 | print STDERR "\n$now $prefix Waiting for query $id (duration " . | ||
134 | 1701 | "$process->{Time} sec): $process->{Info}\n"; | ||
135 | 1702 | return 1; | ||
136 | 1703 | } | ||
137 | 1704 | } | ||
138 | 1705 | |||
139 | 1706 | return 0; | ||
140 | 1707 | } | ||
141 | 1708 | |||
142 | 1709 | |||
143 | 1710 | sub kill_long_queries { | ||
144 | 1711 | my ($con, $timeout) = @_; | ||
145 | 1712 | |||
146 | 1713 | $now = current_time(); | ||
147 | 1714 | |||
148 | 1715 | mysql_query($con, "SHOW FULL PROCESSLIST"); | ||
149 | 1716 | |||
150 | 1717 | my $processlist = $con->{processlist}; | ||
151 | 1718 | |||
152 | 1719 | while (my ($id, $process) = each %$processlist) { | ||
153 | 1720 | if (defined($process->{Info}) && | ||
154 | 1721 | $process->{Time} >= $timeout && | ||
155 | 1722 | (($option_kill_long_query_type eq "all" && | ||
156 | 1723 | is_query($process->{Info})) || | ||
157 | 1724 | is_select_query($process->{Info}))) { | ||
158 | 1725 | print STDERR "\n$now $prefix Killing query $id (duration " . | ||
159 | 1726 | "$process->{Time} sec): $process->{Info}\n"; | ||
160 | 1727 | mysql_query($con, "KILL $id"); | ||
161 | 1728 | } | ||
162 | 1729 | } | ||
163 | 1730 | } | ||
164 | 1731 | |||
165 | 1732 | |||
166 | 1733 | sub wait_for_no_updates { | ||
167 | 1734 | my ($con, $timeout, $threshold) = @_; | ||
168 | 1735 | my $start_time = time(); | ||
169 | 1736 | |||
170 | 1737 | while (time() <= $start_time + $timeout) { | ||
171 | 1738 | if (!(have_queries_to_wait_for($con, $threshold))) { | ||
172 | 1739 | return; | ||
173 | 1740 | } | ||
174 | 1741 | sleep(1); | ||
175 | 1742 | } | ||
176 | 1743 | |||
177 | 1744 | Die "Unable to obtain lock. Please try again."; | ||
178 | 1745 | } | ||
179 | 1746 | |||
180 | 1747 | |||
181 | 1748 | sub start_query_killer { | ||
182 | 1749 | |||
183 | 1750 | my ($kill_timeout, $pcon) = @_; | ||
184 | 1751 | my $start_time = time(); | ||
185 | 1752 | my $pid = fork(); | ||
186 | 1753 | |||
187 | 1754 | if ($pid) { | ||
188 | 1755 | # parent process | ||
189 | 1756 | $query_killer_pid = $pid; | ||
190 | 1757 | } else { | ||
191 | 1758 | # child process | ||
192 | 1759 | my $end = 0; | ||
193 | 1760 | local $SIG{HUP} = sub { $end = 1 }; | ||
194 | 1761 | |||
195 | 1762 | $pcon->{dbh}->{InactiveDestroy} = 1; | ||
196 | 1763 | |||
197 | 1764 | sleep($kill_timeout); | ||
198 | 1765 | |||
199 | 1766 | my %con = mysql_connect(abort_on_error => 1, keepalives => 0); | ||
200 | 1767 | |||
201 | 1768 | while (!$end) { | ||
202 | 1769 | kill_long_queries(\%con, time() - $start_time); | ||
203 | 1770 | sleep(1); | ||
204 | 1771 | } | ||
205 | 1772 | |||
206 | 1773 | mysql_close(\%con); | ||
207 | 1774 | |||
208 | 1775 | exit(0); | ||
209 | 1776 | } | ||
210 | 1777 | } | ||
211 | 1778 | |||
212 | 1779 | sub stop_query_killer { | ||
213 | 1780 | if (defined($query_killer_pid)) { | ||
214 | 1781 | kill 'HUP' => $query_killer_pid; | ||
215 | 1782 | waitpid($query_killer_pid, 0); | ||
216 | 1783 | print STDERR "Query killing process is finished\n"; | ||
217 | 1784 | } | ||
218 | 1785 | } | ||
219 | 1786 | |||
220 | 1605 | 1787 | ||
221 | 1606 | # | 1788 | # |
222 | 1607 | # mysql_lockall subroutine puts a read lock on all tables in all databases. | 1789 | # mysql_lockall subroutine puts a read lock on all tables in all databases. |
223 | 1608 | # | 1790 | # |
224 | 1609 | sub mysql_lockall { | 1791 | sub mysql_lockall { |
225 | 1610 | my $con = shift; | 1792 | my $con = shift; |
226 | 1793 | my $queries_hash_ref; | ||
227 | 1794 | |||
228 | 1795 | if ($option_lock_wait_timeout) { | ||
229 | 1796 | wait_for_no_updates($con, $option_lock_wait_timeout, | ||
230 | 1797 | $option_lock_wait_threshold); | ||
231 | 1798 | } | ||
232 | 1611 | 1799 | ||
233 | 1612 | $now = current_time(); | 1800 | $now = current_time(); |
234 | 1613 | print STDERR "$now $prefix Starting to lock all tables...\n"; | 1801 | print STDERR "$now $prefix Starting to lock all tables...\n"; |
235 | 1614 | 1802 | ||
236 | 1803 | # start query killer process | ||
237 | 1804 | if ($option_kill_long_queries_timeout) { | ||
238 | 1805 | start_query_killer($option_kill_long_queries_timeout, $con); | ||
239 | 1806 | } | ||
240 | 1615 | if (compare_versions($mysql_server_version, '4.0.22') == 0 | 1807 | if (compare_versions($mysql_server_version, '4.0.22') == 0 |
241 | 1616 | || compare_versions($mysql_server_version, '4.1.7') == 0) { | 1808 | || compare_versions($mysql_server_version, '4.1.7') == 0) { |
242 | 1617 | # MySQL server version is 4.0.22 or 4.1.7 | 1809 | # MySQL server version is 4.0.22 or 4.1.7 |
243 | @@ -1622,9 +1814,12 @@ | |||
244 | 1622 | mysql_query($con, "FLUSH TABLES WITH READ LOCK"); | 1814 | mysql_query($con, "FLUSH TABLES WITH READ LOCK"); |
245 | 1623 | mysql_query($con, "COMMIT"); | 1815 | mysql_query($con, "COMMIT"); |
246 | 1624 | } | 1816 | } |
247 | 1817 | # stop query killer process | ||
248 | 1818 | if ($option_kill_long_queries_timeout) { | ||
249 | 1819 | stop_query_killer(); | ||
250 | 1820 | } | ||
251 | 1625 | write_binlog_info($con); | 1821 | write_binlog_info($con); |
252 | 1626 | write_galera_info($con) if $option_galera_info; | 1822 | write_galera_info($con) if $option_galera_info; |
253 | 1627 | |||
254 | 1628 | $now = current_time(); | 1823 | $now = current_time(); |
255 | 1629 | print STDERR "$now $prefix All tables locked and flushed to disk\n"; | 1824 | print STDERR "$now $prefix All tables locked and flushed to disk\n"; |
256 | 1630 | } | 1825 | } |
257 | @@ -1657,6 +1852,7 @@ | |||
258 | 1657 | kill($kill_signal, $ibbackup_pid); | 1852 | kill($kill_signal, $ibbackup_pid); |
259 | 1658 | $ibbackup_pid = ''; | 1853 | $ibbackup_pid = ''; |
260 | 1659 | } | 1854 | } |
261 | 1855 | stop_query_killer(); | ||
262 | 1660 | } | 1856 | } |
263 | 1661 | 1857 | ||
264 | 1662 | 1858 | ||
265 | @@ -1996,7 +2192,15 @@ | |||
266 | 1996 | 'rebuild-indexes' => \$option_rebuild_indexes, | 2192 | 'rebuild-indexes' => \$option_rebuild_indexes, |
267 | 1997 | 'rebuild-threads=i' => \$option_rebuild_threads, | 2193 | 'rebuild-threads=i' => \$option_rebuild_threads, |
268 | 1998 | 'debug-sleep-before-unlock=i' => | 2194 | 'debug-sleep-before-unlock=i' => |
270 | 1999 | \$option_debug_sleep_before_unlock | 2195 | \$option_debug_sleep_before_unlock, |
271 | 2196 | 'kill-long-queries-timeout=i' => | ||
272 | 2197 | \$option_kill_long_queries_timeout, | ||
273 | 2198 | 'kill-long-query-type=s' => | ||
274 | 2199 | \$option_kill_long_query_type, | ||
275 | 2200 | 'lock-wait-timeout=i' => \$option_lock_wait_timeout, | ||
276 | 2201 | 'lock-wait-threshold=i' => \$option_lock_wait_threshold, | ||
277 | 2202 | 'lock-wait-query-type=s' => | ||
278 | 2203 | \$option_lock_wait_query_type | ||
279 | 2000 | ); | 2204 | ); |
280 | 2001 | 2205 | ||
281 | 2002 | if (!$rcode) { | 2206 | if (!$rcode) { |
282 | @@ -2036,6 +2240,18 @@ | |||
283 | 2036 | $option_compress = 0; | 2240 | $option_compress = 0; |
284 | 2037 | } | 2241 | } |
285 | 2038 | 2242 | ||
286 | 2243 | # validate lock-wait-query-type and kill-long-query-type values | ||
287 | 2244 | if (!(grep {$_ eq $option_lock_wait_query_type} qw/all update/)) { | ||
288 | 2245 | Die "Wrong value of lock-wait-query-type. ". | ||
289 | 2246 | "Possible values are all|update, but $option_lock_wait_query_type ". | ||
290 | 2247 | "is specified."; | ||
291 | 2248 | } | ||
292 | 2249 | if (!(grep {$_ eq $option_kill_long_query_type} qw/all select/)) { | ||
293 | 2250 | Die "Wrong value of kill-long-query-type. ". | ||
294 | 2251 | "Possible values are all|select, but $option_kill_long_query_type ". | ||
295 | 2252 | "is specified."; | ||
296 | 2253 | } | ||
297 | 2254 | |||
298 | 2039 | if ($option_stream eq 'tar') { | 2255 | if ($option_stream eq 'tar') { |
299 | 2040 | $stream_cmd = 'tar chf -'; | 2256 | $stream_cmd = 'tar chf -'; |
300 | 2041 | } elsif ($option_stream eq 'xbstream') { | 2257 | } elsif ($option_stream eq 'xbstream') { |
301 | @@ -3148,6 +3364,27 @@ | |||
302 | 3148 | 3364 | ||
303 | 3149 | This option specifies the log sequence number (LSN) to use for the incremental backup. The option accepts a string argument. It is used with the --incremental option. It is used instead of specifying --incremental-basedir. For databases created by MySQL and Percona Server 5.0-series versions, specify the LSN as two 32-bit integers in high:low format. For databases created in 5.1 and later, specify the LSN as a single 64-bit integer. | 3365 | This option specifies the log sequence number (LSN) to use for the incremental backup. The option accepts a string argument. It is used with the --incremental option. It is used instead of specifying --incremental-basedir. For databases created by MySQL and Percona Server 5.0-series versions, specify the LSN as two 32-bit integers in high:low format. For databases created in 5.1 and later, specify the LSN as a single 64-bit integer. |
304 | 3150 | 3366 | ||
305 | 3367 | =item --kill-long-queries-timeout=SECONDS | ||
306 | 3368 | |||
307 | 3369 | This option specifies the number of seconds innobackupex waits between starting FLUSH TABLES WITH READ LOCK and killing those queries that block it. Default is 0 seconds, which means innobackupex will not attempt to kill any queries. | ||
308 | 3370 | |||
309 | 3371 | =item --kill-long-query-type=all|update | ||
310 | 3372 | |||
311 | 3373 | This option specifies which types of queries should be killed to unblock the global lock. Default is "all". | ||
312 | 3374 | |||
313 | 3375 | =item --lock-wait-timeout=SECONDS | ||
314 | 3376 | |||
315 | 3377 | This option specifies time in seconds that innobackupex should wait for queries that would block FTWRL before running it. If there are still such queries when the timeout expires, innobackupex terminates with an error. | ||
316 | 3378 | Default is 0, in which case innobackupex does not wait for queries to complete and starts FTWRL immediately. | ||
317 | 3379 | |||
318 | 3380 | =item --lock-wait-threshold=SECONDS | ||
319 | 3381 | |||
320 | 3382 | This option specifies the query run time threshold which is used by innobackupex to detect long-running queries with a non-zero value of --lock-wait-timeout. FTWRL is not started until such long-running queries exist. This option has no effect if --lock-wait-timeout is 0. Default value is 60 seconds. | ||
321 | 3383 | |||
322 | 3384 | =item --lock-wait-query-type=all|update | ||
323 | 3385 | |||
324 | 3386 | This option specifies which types of queries are allowed to complete before innobackuped will issue the global lock. Default is all. | ||
325 | 3387 | |||
326 | 3151 | =item --move-back | 3388 | =item --move-back |
327 | 3152 | 3389 | ||
328 | 3153 | Move all the files in a previously made backup from the backup directory to the actual datadir location. Use with caution, as it removes backup files. | 3390 | Move all the files in a previously made backup from the backup directory to the actual datadir location. Use with caution, as it removes backup files. |
329 | 3154 | 3391 | ||
330 | === added file 'test/t/kill_long_selects.sh' | |||
331 | --- test/t/kill_long_selects.sh 1970-01-01 00:00:00 +0000 | |||
332 | +++ test/t/kill_long_selects.sh 2013-05-26 07:22:28 +0000 | |||
333 | @@ -0,0 +1,181 @@ | |||
334 | 1 | ############################################################################ | ||
335 | 2 | # Test kill-long-queries and kill-long-queries-timeout optins | ||
336 | 3 | ############################################################################ | ||
337 | 4 | |||
338 | 5 | . inc/common.sh | ||
339 | 6 | |||
340 | 7 | function bg_run() | ||
341 | 8 | { | ||
342 | 9 | local varname=$1 | ||
343 | 10 | |||
344 | 11 | shift | ||
345 | 12 | |||
346 | 13 | ( for cmd in "$@" | ||
347 | 14 | do | ||
348 | 15 | eval "$cmd" | ||
349 | 16 | done ) & | ||
350 | 17 | |||
351 | 18 | local pid=$! | ||
352 | 19 | |||
353 | 20 | eval "$varname=$pid" | ||
354 | 21 | |||
355 | 22 | } | ||
356 | 23 | |||
357 | 24 | function mysql_select() | ||
358 | 25 | { | ||
359 | 26 | vlog "Run select query with duration $1 seconds" | ||
360 | 27 | ${MYSQL} ${MYSQL_ARGS} -c test 2> /dev/null <<EOF | ||
361 | 28 | /* Run background /*SELECT*\ */ | ||
362 | 29 | ( | ||
363 | 30 | SELECT SLEEP($1) FROM t1 FOR UPDATE | ||
364 | 31 | ) UNION ALL | ||
365 | 32 | ( | ||
366 | 33 | SELECT 1 | ||
367 | 34 | ); | ||
368 | 35 | EOF | ||
369 | 36 | } | ||
370 | 37 | |||
371 | 38 | function mysql_update() | ||
372 | 39 | { | ||
373 | 40 | vlog "Run update query with duration $1 seconds" | ||
374 | 41 | ${MYSQL} ${MYSQL_ARGS} -c test 2> /dev/null <<EOF | ||
375 | 42 | /* This is not SELECT but rather an /*UPDATE*\ | ||
376 | 43 | query */ | ||
377 | 44 | UPDATE t1 SET a = SLEEP($1); | ||
378 | 45 | EOF | ||
379 | 46 | } | ||
380 | 47 | |||
381 | 48 | |||
382 | 49 | function bg_kill_ok() | ||
383 | 50 | { | ||
384 | 51 | vlog "Killing $1, expecting it is alive" | ||
385 | 52 | run_cmd kill $1 | ||
386 | 53 | } | ||
387 | 54 | |||
388 | 55 | |||
389 | 56 | function bg_wait_ok() | ||
390 | 57 | { | ||
391 | 58 | vlog "Waiting for $1, expecting it's success" | ||
392 | 59 | run_cmd wait $1 | ||
393 | 60 | } | ||
394 | 61 | |||
395 | 62 | |||
396 | 63 | function bg_wait_fail() | ||
397 | 64 | { | ||
398 | 65 | vlog "Waiting for $1, expecting it would fail" | ||
399 | 66 | run_cmd_expect_failure wait $1 | ||
400 | 67 | } | ||
401 | 68 | |||
402 | 69 | function kill_all_queries() | ||
403 | 70 | { | ||
404 | 71 | run_cmd $MYSQL $MYSQL_ARGS test <<EOF | ||
405 | 72 | select concat('KILL ',id,';') from information_schema.processlist | ||
406 | 73 | where user='root' and time > 2 into outfile '$MYSQLD_TMPDIR/killall.sql'; | ||
407 | 74 | source $MYSQLD_TMPDIR/killall.sql; | ||
408 | 75 | EOF | ||
409 | 76 | rm -f $MYSQLD_TMPDIR/killall.sql | ||
410 | 77 | } | ||
411 | 78 | |||
412 | 79 | start_server --innodb_file_per_table | ||
413 | 80 | |||
414 | 81 | run_cmd $MYSQL $MYSQL_ARGS test <<EOF | ||
415 | 82 | CREATE TABLE t1(a INT) ENGINE=InnoDB; | ||
416 | 83 | INSERT INTO t1 VALUES (1); | ||
417 | 84 | EOF | ||
418 | 85 | |||
419 | 86 | mkdir $topdir/full | ||
420 | 87 | |||
421 | 88 | # ============================================================== | ||
422 | 89 | vlog "===================== case 1 =====================" | ||
423 | 90 | bg_run bg_select_pid "mysql_select 3" | ||
424 | 91 | bg_run bg_update_pid "sleep 1" "mysql_update 3" | ||
425 | 92 | |||
426 | 93 | innobackupex $topdir/full --kill-long-queries-timeout=5 \ | ||
427 | 94 | --kill-long-query-type=all | ||
428 | 95 | |||
429 | 96 | bg_wait_ok $bg_select_pid | ||
430 | 97 | bg_wait_ok $bg_update_pid | ||
431 | 98 | kill_all_queries | ||
432 | 99 | |||
433 | 100 | |||
434 | 101 | # ============================================================== | ||
435 | 102 | vlog "===================== case 2 =====================" | ||
436 | 103 | bg_run bg_select_pid "mysql_select 200" | ||
437 | 104 | bg_run bg_update_pid "sleep 1" "mysql_update 5" | ||
438 | 105 | |||
439 | 106 | innobackupex $topdir/full --kill-long-queries-timeout=3 \ | ||
440 | 107 | --kill-long-query-type=select | ||
441 | 108 | |||
442 | 109 | bg_wait_fail $bg_select_pid | ||
443 | 110 | bg_wait_ok $bg_update_pid | ||
444 | 111 | kill_all_queries | ||
445 | 112 | |||
446 | 113 | |||
447 | 114 | # ============================================================== | ||
448 | 115 | vlog "===================== case 3 =====================" | ||
449 | 116 | bg_run bg_select_pid "mysql_select 200" | ||
450 | 117 | bg_run bg_update_pid "mysql_update 200" | ||
451 | 118 | |||
452 | 119 | innobackupex $topdir/full --kill-long-queries-timeout=3 \ | ||
453 | 120 | --kill-long-query-type=all | ||
454 | 121 | |||
455 | 122 | bg_wait_fail $bg_select_pid | ||
456 | 123 | bg_wait_fail $bg_update_pid | ||
457 | 124 | kill_all_queries | ||
458 | 125 | |||
459 | 126 | |||
460 | 127 | # ============================================================== | ||
461 | 128 | vlog "===================== case 4 =====================" | ||
462 | 129 | bg_run bg_select_pid "mysql_select 200" | ||
463 | 130 | bg_run bg_update_pid "mysql_update 200" | ||
464 | 131 | |||
465 | 132 | sleep 1 | ||
466 | 133 | |||
467 | 134 | run_cmd_expect_failure ${IB_BIN} ${IB_ARGS} $topdir/full \ | ||
468 | 135 | --lock-wait-timeout=3 \ | ||
469 | 136 | --lock-wait-query-type=all \ | ||
470 | 137 | --lock-wait-threshold=1 \ | ||
471 | 138 | --kill-long-queries-timeout=1 \ | ||
472 | 139 | --kill-long-query-type=all | ||
473 | 140 | |||
474 | 141 | bg_kill_ok $bg_select_pid | ||
475 | 142 | bg_kill_ok $bg_update_pid | ||
476 | 143 | kill_all_queries | ||
477 | 144 | |||
478 | 145 | |||
479 | 146 | # ============================================================== | ||
480 | 147 | vlog "===================== case 5 =====================" | ||
481 | 148 | bg_run bg_select_pid "mysql_select 200" | ||
482 | 149 | bg_run bg_update_pid "mysql_update 200" | ||
483 | 150 | |||
484 | 151 | sleep 2 | ||
485 | 152 | |||
486 | 153 | run_cmd_expect_failure ${IB_BIN} ${IB_ARGS} $topdir/full \ | ||
487 | 154 | --lock-wait-timeout=3 \ | ||
488 | 155 | --lock-wait-query-type=update \ | ||
489 | 156 | --lock-wait-threshold=2 \ | ||
490 | 157 | --kill-long-queries-timeout=1 \ | ||
491 | 158 | --kill-long-query-type=all | ||
492 | 159 | |||
493 | 160 | bg_kill_ok $bg_select_pid | ||
494 | 161 | bg_kill_ok $bg_update_pid | ||
495 | 162 | kill_all_queries | ||
496 | 163 | |||
497 | 164 | |||
498 | 165 | # ============================================================== | ||
499 | 166 | vlog "===================== case 6 =====================" | ||
500 | 167 | bg_run bg_update_pid "mysql_update 5" | ||
501 | 168 | bg_run bg_select_pid "sleep 1" "mysql_select 200" | ||
502 | 169 | |||
503 | 170 | sleep 2 | ||
504 | 171 | |||
505 | 172 | innobackupex $topdir/full \ | ||
506 | 173 | --lock-wait-timeout=6 \ | ||
507 | 174 | --lock-wait-query-type=update \ | ||
508 | 175 | --lock-wait-threshold=2 \ | ||
509 | 176 | --kill-long-queries-timeout=1 \ | ||
510 | 177 | --kill-long-query-type=all | ||
511 | 178 | |||
512 | 179 | bg_wait_fail $bg_select_pid | ||
513 | 180 | bg_wait_ok $bg_update_pid | ||
514 | 181 | kill_all_queries |
Sergei,
There are conflicts in innobackupex. Please also re-run Jenkins tests with exactly the same branch as has been submitted for reviews.