~percona-toolkit-dev/percona-toolkit/docu-ptc-rbr-limitation

« back to all changes in this revision

Viewing changes to docs/user/pt-kill.rst

  • Committer: Daniel Nichter
  • Date: 2011-07-14 19:08:47 UTC
  • Revision ID: daniel@percona.com-20110714190847-lggalkuvdrh7c4jp
Add standard pkg files (COPYING, README, etc.), percona-toolkit.pod, and user docs.  Remove dev/docs/html.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
#######
 
3
pt-kill
 
4
#######
 
5
 
 
6
.. highlight:: perl
 
7
 
 
8
 
 
9
****
 
10
NAME
 
11
****
 
12
 
 
13
 
 
14
pt-kill - Kill MySQL queries that match certain criteria.
 
15
 
 
16
 
 
17
********
 
18
SYNOPSIS
 
19
********
 
20
 
 
21
 
 
22
Usage: pt-kill [OPTION]... [FILE...]
 
23
 
 
24
pt-kill kills MySQL connections.  pt-kill connects to MySQL and gets queries
 
25
from SHOW PROCESSLIST if no FILE is given.  Else, it reads queries from one
 
26
or more FILE which contains the output of SHOW PROCESSLIST.  If FILE is -,
 
27
pt-kill reads from STDIN.
 
28
 
 
29
Kill queries running longer than 60s:
 
30
 
 
31
 
 
32
.. code-block:: perl
 
33
 
 
34
   pt-kill --busy-time 60 --kill
 
35
 
 
36
 
 
37
Print, do not kill, queries running longer than 60s:
 
38
 
 
39
 
 
40
.. code-block:: perl
 
41
 
 
42
   pt-kill --busy-time 60 --print
 
43
 
 
44
 
 
45
Check for sleeping processes and kill them all every 10s:
 
46
 
 
47
 
 
48
.. code-block:: perl
 
49
 
 
50
   pt-kill --match-command Sleep --kill --victims all --interval 10
 
51
 
 
52
 
 
53
Print all login processes:
 
54
 
 
55
 
 
56
.. code-block:: perl
 
57
 
 
58
   pt-kill --match-state login --print --victims all
 
59
 
 
60
 
 
61
See which queries in the processlist right now would match:
 
62
 
 
63
 
 
64
.. code-block:: perl
 
65
 
 
66
    mysql -e "SHOW PROCESSLIST" | pt-kill --busy-time 60 --print
 
67
 
 
68
 
 
69
 
 
70
*****
 
71
RISKS
 
72
*****
 
73
 
 
74
 
 
75
The following section is included to inform users about the potential risks,
 
76
whether known or unknown, of using this tool.  The two main categories of risks
 
77
are those created by the nature of the tool (e.g. read-only tools vs. read-write
 
78
tools) and those created by bugs.
 
79
 
 
80
pt-kill is designed to kill queries if you use the "--kill" option is given,
 
81
and that might disrupt your database's users, of course.  You should test with
 
82
the <"--print"> option, which is safe, if you're unsure what the tool will do.
 
83
 
 
84
At the time of this release, we know of no bugs that could cause serious harm to
 
85
users.
 
86
 
 
87
The authoritative source for updated information is always the online issue
 
88
tracking system.  Issues that affect this tool will be marked as such.  You can
 
89
see a list of such issues at the following URL:
 
90
`http://www.percona.com/bugs/pt-kill <http://www.percona.com/bugs/pt-kill>`_.
 
91
 
 
92
See also "BUGS" for more information on filing bugs and getting help.
 
93
 
 
94
 
 
95
***********
 
96
DESCRIPTION
 
97
***********
 
98
 
 
99
 
 
100
pt-kill captures queries from SHOW PROCESSLIST, filters them, and then either
 
101
kills or prints them.  This is also known as a "slow query sniper" in some
 
102
circles.  The idea is to watch for queries that might be consuming too many
 
103
resources, and kill them.
 
104
 
 
105
For brevity, we talk about killing queries, but they may just be printed
 
106
(or some other future action) depending on what options are given.
 
107
 
 
108
Normally pt-kill connects to MySQL to get queries from SHOW PROCESSLIST.
 
109
Alternatively, it can read SHOW PROCESSLIST output from files.  In this case,
 
110
pt-kill does not connect to MySQL and "--kill" has no effect.  You should
 
111
use "--print" instead when reading files.  The ability to read a file (or
 
112
- for STDIN) allows you to capture SHOW PROCESSLIST and test it later with
 
113
pt-kill to make sure that your matches kill the proper queries.  There are a
 
114
lot of special rules to follow, such as "don't kill replication threads,"
 
115
so be careful to not kill something important!
 
116
 
 
117
Two important options to know are "--busy-time" and "--victims".
 
118
First, whereas most match/filter options match their corresponding value from
 
119
SHOW PROCESSLIST (e.g. "--match-command" matches a query's Command value),
 
120
the Time value is matched by "--busy-time".  See also "--interval".
 
121
 
 
122
Second, "--victims" controls which matching queries from each class are
 
123
killed.  By default, the matching query with the highest Time value is killed
 
124
(the oldest query).  See the next section, "GROUP, MATCH AND KILL",
 
125
for more details.
 
126
 
 
127
Usually you need to specify at least one \ ``--match``\  option, else no
 
128
queries will match.  Or, you can specify "--match-all" to match all queries
 
129
that aren't ignored by an \ ``--ignore``\  option.
 
130
 
 
131
pt-kill is a work in progress, and there is much more it could do.
 
132
 
 
133
 
 
134
*********************
 
135
GROUP, MATCH AND KILL
 
136
*********************
 
137
 
 
138
 
 
139
Queries pass through several steps to determine which exactly will be killed
 
140
(or printed--whatever action is specified).  Understanding these steps will
 
141
help you match precisely the queries you want.
 
142
 
 
143
The first step is grouping queries into classes.  The "--group-by" option
 
144
controls grouping.  By default, this option has no value so all queries are
 
145
grouped into one, big default class.  All types of matching and filtering
 
146
(the next step) are applied per-class.  Therefore, you may need to group
 
147
queries in order to match/filter some classes but not others.
 
148
 
 
149
The second step is matching.  Matching implies filtering since if a query
 
150
doesn't match some criteria, it is removed from its class.
 
151
Matching happens for each class.  First, queries are filtered from their
 
152
class by the various \ ``Query Matches``\  options like "--match-user".
 
153
Then, entire classes are filtered by the various \ ``Class Matches``\  options
 
154
like "--query-count".
 
155
 
 
156
The third step is victim selection, that is, which matching queries in each
 
157
class to kill.  This is controlled by the "--victims" option.  Although
 
158
many queries in a class may match, you may only want to kill the oldest
 
159
query, or all queries, etc.
 
160
 
 
161
The forth and final step is to take some action on all matching queries
 
162
from all classes.  The \ ``Actions``\  options specify which actions will be
 
163
taken.  At this step, there are no more classes, just a single list of
 
164
queries to kill, print, etc.
 
165
 
 
166
 
 
167
******
 
168
OUTPUT
 
169
******
 
170
 
 
171
 
 
172
If only "--kill" then there is no output.  If only "--print" then a
 
173
timestamped KILL statement if printed for every query that would have
 
174
been killed, like:
 
175
 
 
176
 
 
177
.. code-block:: perl
 
178
 
 
179
   # 2009-07-15T15:04:01 KILL 8 (Query 42 sec) SELECT * FROM huge_table
 
180
 
 
181
 
 
182
The line shows a timestamp, the query's Id (8), its Time (42 sec) and its
 
183
Info (usually the query SQL).
 
184
 
 
185
If both "--kill" and "--print" are given, then matching queries are
 
186
killed and a line for each like the one above is printed.
 
187
 
 
188
Any command executed by "--execute-command" is responsible for its own
 
189
output and logging.  After being executed, pt-kill has no control or interaction
 
190
with the command.
 
191
 
 
192
 
 
193
*******
 
194
OPTIONS
 
195
*******
 
196
 
 
197
 
 
198
Specify at least one of "--kill", "--kill-query", "--print", "--execute-command" or "--stop".
 
199
 
 
200
"--any-busy-time" and "--each-busy-time" are mutually exclusive.
 
201
 
 
202
"--kill" and "--kill-query" are mutually exclusive.
 
203
 
 
204
This tool accepts additional command-line arguments.  Refer to the
 
205
"SYNOPSIS" and usage information for details.
 
206
 
 
207
 
 
208
--ask-pass
 
209
 
 
210
 Prompt for a password when connecting to MySQL.
 
211
 
 
212
 
 
213
 
 
214
--charset
 
215
 
 
216
 short form: -A; type: string
 
217
 
 
218
 Default character set.  If the value is utf8, sets Perl's binmode on
 
219
 STDOUT to utf8, passes the mysql_enable_utf8 option to DBD::mysql, and runs SET
 
220
 NAMES UTF8 after connecting to MySQL.  Any other value sets binmode on STDOUT
 
221
 without the utf8 layer, and runs SET NAMES after connecting to MySQL.
 
222
 
 
223
 
 
224
 
 
225
--config
 
226
 
 
227
 type: Array
 
228
 
 
229
 Read this comma-separated list of config files; if specified, this must be the
 
230
 first option on the command line.
 
231
 
 
232
 
 
233
 
 
234
--daemonize
 
235
 
 
236
 Fork to the background and detach from the shell.  POSIX operating systems
 
237
 only.
 
238
 
 
239
 
 
240
 
 
241
--defaults-file
 
242
 
 
243
 short form: -F; type: string
 
244
 
 
245
 Only read mysql options from the given file.  You must give an absolute
 
246
 pathname.
 
247
 
 
248
 
 
249
 
 
250
--group-by
 
251
 
 
252
 type: string
 
253
 
 
254
 Apply matches to each class of queries grouped by this SHOW PROCESSLIST column.
 
255
 In addition to the basic columns of SHOW PROCESSLIST (user, host, command,
 
256
 state, etc.), queries can be matched by \ ``fingerprint``\  which abstracts the
 
257
 SQL query in the \ ``Info``\  column.
 
258
 
 
259
 By default, queries are not grouped, so matches and actions apply to all
 
260
 queries.  Grouping allows matches and actions to apply to classes of
 
261
 similar queries, if any queries in the class match.
 
262
 
 
263
 For example, detecting cache stampedes (see \ ``all-but-oldest``\  under
 
264
 "--victims" for an explanation of that term) requires that queries are
 
265
 grouped by the \ ``arg``\  attribute.  This creates classes of identical queries
 
266
 (stripped of comments).  So queries \ ``"SELECT c FROM t WHERE id=1"``\  and
 
267
 \ ``"SELECT c FROM t WHERE id=1"``\  are grouped into the same class, but
 
268
 query c<"SELECT c FROM t WHERE id=3"> is not identical to the first two
 
269
 queries so it is grouped into another class. Then when "--victims"
 
270
 \ ``all-but-oldest``\  is specified, all but the oldest query in each class is
 
271
 killed for each class of queries that matches the match criteria.
 
272
 
 
273
 
 
274
 
 
275
--help
 
276
 
 
277
 Show help and exit.
 
278
 
 
279
 
 
280
 
 
281
--host
 
282
 
 
283
 short form: -h; type: string; default: localhost
 
284
 
 
285
 Connect to host.
 
286
 
 
287
 
 
288
 
 
289
--interval
 
290
 
 
291
 type: time
 
292
 
 
293
 How often to check for queries to kill.  If "--busy-time" is not given,
 
294
 then the default interval is 30 seconds.  Else the default is half as often
 
295
 as "--busy-time".  If both "--interval" and "--busy-time" are given,
 
296
 then the explicit "--interval" value is used.
 
297
 
 
298
 See also "--run-time".
 
299
 
 
300
 
 
301
 
 
302
--log
 
303
 
 
304
 type: string
 
305
 
 
306
 Print all output to this file when daemonized.
 
307
 
 
308
 
 
309
 
 
310
--password
 
311
 
 
312
 short form: -p; type: string
 
313
 
 
314
 Password to use when connecting.
 
315
 
 
316
 
 
317
 
 
318
--pid
 
319
 
 
320
 type: string
 
321
 
 
322
 Create the given PID file when daemonized.  The file contains the process ID of
 
323
 the daemonized instance.  The PID file is removed when the daemonized instance
 
324
 exits.  The program checks for the existence of the PID file when starting; if
 
325
 it exists and the process with the matching PID exists, the program exits.
 
326
 
 
327
 
 
328
 
 
329
--port
 
330
 
 
331
 short form: -P; type: int
 
332
 
 
333
 Port number to use for connection.
 
334
 
 
335
 
 
336
 
 
337
--[no]strip-comments
 
338
 
 
339
 default: yes
 
340
 
 
341
 Remove SQL comments from queries in the Info column of the PROCESSLIST.
 
342
 
 
343
 
 
344
 
 
345
--run-time
 
346
 
 
347
 type: time
 
348
 
 
349
 How long to run before exiting.  By default pt-kill runs forever, or until
 
350
 its process is killed or stopped by the creation of a "--sentinel" file.
 
351
 If this option is specified, pt-kill runs for the specified amount of time
 
352
 and sleeps "--interval" seconds between each check of the PROCESSLIST.
 
353
 
 
354
 
 
355
 
 
356
--sentinel
 
357
 
 
358
 type: string; default: /tmp/pt-kill-sentinel
 
359
 
 
360
 Exit if this file exists.
 
361
 
 
362
 The presence of the file specified by "--sentinel" will cause all
 
363
 running instances of pt-kill to exit.  You might find this handy to stop cron
 
364
 jobs gracefully if necessary.  See also "--stop".
 
365
 
 
366
 
 
367
 
 
368
--set-vars
 
369
 
 
370
 type: string; default: wait_timeout=10000
 
371
 
 
372
 Set these MySQL variables.  Immediately after connecting to MySQL, this string
 
373
 will be appended to SET and executed.
 
374
 
 
375
 
 
376
 
 
377
--socket
 
378
 
 
379
 short form: -S; type: string
 
380
 
 
381
 Socket file to use for connection.
 
382
 
 
383
 
 
384
 
 
385
--stop
 
386
 
 
387
 Stop running instances by creating the "--sentinel" file.
 
388
 
 
389
 Causes pt-kill to create the sentinel file specified by "--sentinel" and
 
390
 exit.  This should have the effect of stopping all running instances which are
 
391
 watching the same sentinel file.
 
392
 
 
393
 
 
394
 
 
395
--user
 
396
 
 
397
 short form: -u; type: string
 
398
 
 
399
 User for login if not current user.
 
400
 
 
401
 
 
402
 
 
403
--version
 
404
 
 
405
 Show version and exit.
 
406
 
 
407
 
 
408
 
 
409
--victims
 
410
 
 
411
 type: string; default: oldest
 
412
 
 
413
 Which of the matching queries in each class will be killed.  After classes
 
414
 have been matched/filtered, this option specifies which of the matching
 
415
 queries in each class will be killed (or printed, etc.).  The following
 
416
 values are possible:
 
417
 
 
418
 
 
419
 oldest
 
420
  
 
421
  Only kill the single oldest query.  This is to prevent killing queries that
 
422
  aren't really long-running, they're just long-waiting.  This sorts matching
 
423
  queries by Time and kills the one with the highest Time value.
 
424
  
 
425
 
 
426
 
 
427
 all
 
428
  
 
429
  Kill all queries in the class.
 
430
  
 
431
 
 
432
 
 
433
 all-but-oldest
 
434
  
 
435
  Kill all but the oldest query.  This is the inverse of the \ ``oldest``\  value.
 
436
  
 
437
  This value can be used to prevent "cache stampedes", the condition where
 
438
  several identical queries are executed and create a backlog while the first
 
439
  query attempts to finish.  Since all queries are identical, all but the first
 
440
  query are killed so that it can complete and populate the cache.
 
441
  
 
442
 
 
443
 
 
444
 
 
445
 
 
446
--wait-after-kill
 
447
 
 
448
 type: time
 
449
 
 
450
 Wait after killing a query, before looking for more to kill.  The purpose of
 
451
 this is to give blocked queries a chance to execute, so we don't kill a query
 
452
 that's blocking a bunch of others, and then kill the others immediately
 
453
 afterwards.
 
454
 
 
455
 
 
456
 
 
457
--wait-before-kill
 
458
 
 
459
 type: time
 
460
 
 
461
 Wait before killing a query.  The purpose of this is to give
 
462
 "--execute-command" a chance to see the matching query and gather other
 
463
 MySQL or system information before it's killed.
 
464
 
 
465
 
 
466
 
 
467
QUERY MATCHES
 
468
=============
 
469
 
 
470
 
 
471
These options filter queries from their classes.  If a query does not
 
472
match, it is removed from its class.  The \ ``--ignore``\  options take precedence.
 
473
The matches for command, db, host, etc. correspond to the columns returned
 
474
by SHOW PROCESSLIST: Command, db, Host, etc.  All pattern matches are
 
475
case-sensitive by default, but they can be made case-insensitive by specifying
 
476
a regex pattern like \ ``(?i-xsm:select)``\ .
 
477
 
 
478
See also "GROUP, MATCH AND KILL".
 
479
 
 
480
 
 
481
--match-all
 
482
 
 
483
 group: Query Matches
 
484
 
 
485
 Match all queries that are not ignored.  If no ignore options are specified,
 
486
 then every query matches (except replication threads, unless
 
487
 "--replication-threads" is also specified).  This option allows you to
 
488
 specify negative matches, i.e. "match every query \ *except*\ ..." where the
 
489
 exceptions are defined by specifying various \ ``--ignore``\  options.
 
490
 
 
491
 This option is \ *not*\  the same as "--victims" \ ``all``\ .  This option matches
 
492
 all queries within a class, whereas "--victims" \ ``all``\  specifies that all
 
493
 matching queries in a class (however they matched) will be killed.  Normally,
 
494
 however, the two are used together because if, for example, you specify
 
495
 "--victims" \ ``oldest``\ , then although all queries may match, only the oldest
 
496
 will be killed.
 
497
 
 
498
 
 
499
 
 
500
--busy-time
 
501
 
 
502
 type: time; group: Query Matches
 
503
 
 
504
 Match queries that have been running for longer than this time.  The queries
 
505
 must be in Command=Query status.  This matches a query's Time value as
 
506
 reported by SHOW PROCESSLIST.
 
507
 
 
508
 
 
509
 
 
510
--idle-time
 
511
 
 
512
 type: time; group: Query Matches
 
513
 
 
514
 Match queries that have been idle/sleeping for longer than this time.
 
515
 The queries must be in Command=Sleep status.  This matches a query's Time
 
516
 value as reported by SHOW PROCESSLIST.
 
517
 
 
518
 
 
519
 
 
520
--ignore-command
 
521
 
 
522
 type: string; group: Query Matches
 
523
 
 
524
 Ignore queries whose Command matches this Perl regex.
 
525
 
 
526
 See "--match-command".
 
527
 
 
528
 
 
529
 
 
530
--ignore-db
 
531
 
 
532
 type: string; group: Query Matches
 
533
 
 
534
 Ignore queries whose db (database) matches this Perl regex.
 
535
 
 
536
 See "--match-db".
 
537
 
 
538
 
 
539
 
 
540
--ignore-host
 
541
 
 
542
 type: string; group: Query Matches
 
543
 
 
544
 Ignore queries whose Host matches this Perl regex.
 
545
 
 
546
 See "--match-host".
 
547
 
 
548
 
 
549
 
 
550
--ignore-info
 
551
 
 
552
 type: string; group: Query Matches
 
553
 
 
554
 Ignore queries whose Info (query) matches this Perl regex.
 
555
 
 
556
 See "--match-info".
 
557
 
 
558
 
 
559
 
 
560
--[no]ignore-self
 
561
 
 
562
 default: yes; group: Query Matches
 
563
 
 
564
 Don't kill pt-kill's own connection.
 
565
 
 
566
 
 
567
 
 
568
--ignore-state
 
569
 
 
570
 type: string; group: Query Matches; default: Locked
 
571
 
 
572
 Ignore queries whose State matches this Perl regex.  The default is to keep
 
573
 threads from being killed if they are locked waiting for another thread.
 
574
 
 
575
 See "--match-state".
 
576
 
 
577
 
 
578
 
 
579
--ignore-user
 
580
 
 
581
 type: string; group: Query Matches
 
582
 
 
583
 Ignore queries whose user matches this Perl regex.
 
584
 
 
585
 See "--match-user".
 
586
 
 
587
 
 
588
 
 
589
--match-command
 
590
 
 
591
 type: string; group: Query Matches
 
592
 
 
593
 Match only queries whose Command matches this Perl regex.
 
594
 
 
595
 Common Command values are:
 
596
 
 
597
 
 
598
 .. code-block:: perl
 
599
 
 
600
    Query
 
601
    Sleep
 
602
    Binlog Dump
 
603
    Connect
 
604
    Delayed insert
 
605
    Execute
 
606
    Fetch
 
607
    Init DB
 
608
    Kill
 
609
    Prepare
 
610
    Processlist
 
611
    Quit
 
612
    Reset stmt
 
613
    Table Dump
 
614
 
 
615
 
 
616
 See `http://dev.mysql.com/doc/refman/5.1/en/thread-commands.html <http://dev.mysql.com/doc/refman/5.1/en/thread-commands.html>`_ for a full
 
617
 list and description of Command values.
 
618
 
 
619
 
 
620
 
 
621
--match-db
 
622
 
 
623
 type: string; group: Query Matches
 
624
 
 
625
 Match only queries whose db (database) matches this Perl regex.
 
626
 
 
627
 
 
628
 
 
629
--match-host
 
630
 
 
631
 type: string; group: Query Matches
 
632
 
 
633
 Match only queries whose Host matches this Perl regex.
 
634
 
 
635
 The Host value often time includes the port like "host:port".
 
636
 
 
637
 
 
638
 
 
639
--match-info
 
640
 
 
641
 type: string; group: Query Matches
 
642
 
 
643
 Match only queries whose Info (query) matches this Perl regex.
 
644
 
 
645
 The Info column of the processlist shows the query that is being executed
 
646
 or NULL if no query is being executed.
 
647
 
 
648
 
 
649
 
 
650
--match-state
 
651
 
 
652
 type: string; group: Query Matches
 
653
 
 
654
 Match only queries whose State matches this Perl regex.
 
655
 
 
656
 Common State values are:
 
657
 
 
658
 
 
659
 .. code-block:: perl
 
660
 
 
661
    Locked
 
662
    login
 
663
    copy to tmp table
 
664
    Copying to tmp table
 
665
    Copying to tmp table on disk
 
666
    Creating tmp table
 
667
    executing
 
668
    Reading from net
 
669
    Sending data
 
670
    Sorting for order
 
671
    Sorting result
 
672
    Table lock
 
673
    Updating
 
674
 
 
675
 
 
676
 See `http://dev.mysql.com/doc/refman/5.1/en/general-thread-states.html <http://dev.mysql.com/doc/refman/5.1/en/general-thread-states.html>`_ for
 
677
 a full list and description of State values.
 
678
 
 
679
 
 
680
 
 
681
--match-user
 
682
 
 
683
 type: string; group: Query Matches
 
684
 
 
685
 Match only queries whose User matches this Perl regex.
 
686
 
 
687
 
 
688
 
 
689
--replication-threads
 
690
 
 
691
 group: Query Matches
 
692
 
 
693
 Allow matching and killing replication threads.
 
694
 
 
695
 By default, matches do not apply to replication threads; i.e. replication
 
696
 threads are completely ignored.  Specifying this option allows matches to
 
697
 match (and potentially kill) replication threads on masters and slaves.
 
698
 
 
699
 
 
700
 
 
701
 
 
702
CLASS MATCHES
 
703
=============
 
704
 
 
705
 
 
706
These matches apply to entire query classes.  Classes are created by specifying
 
707
the "--group-by" option, else all queries are members of a single, default
 
708
class.
 
709
 
 
710
See also "GROUP, MATCH AND KILL".
 
711
 
 
712
 
 
713
--any-busy-time
 
714
 
 
715
 type: time; group: Class Matches
 
716
 
 
717
 Match query class if any query has been running for longer than this time.
 
718
 "Longer than" means that if you specify \ ``10``\ , for example, the class will
 
719
 only match if there's at least one query that has been running for greater
 
720
 than 10 seconds.
 
721
 
 
722
 See "--each-busy-time" for more details.
 
723
 
 
724
 
 
725
 
 
726
--each-busy-time
 
727
 
 
728
 type: time; group: Class Matches
 
729
 
 
730
 Match query class if each query has been running for longer than this time.
 
731
 "Longer than" means that if you specify \ ``10``\ , for example, the class will
 
732
 only match if each and every query has been running for greater than 10
 
733
 seconds.
 
734
 
 
735
 See also "--any-busy-time" (to match a class if ANY query has been running
 
736
 longer than the specified time) and "--busy-time".
 
737
 
 
738
 
 
739
 
 
740
--query-count
 
741
 
 
742
 type: int; group: Class Matches
 
743
 
 
744
 Match query class if it has at least this many queries.  When queries are
 
745
 grouped into classes by specifying "--group-by", this option causes matches
 
746
 to apply only to classes with at least this many queries.  If "--group-by"
 
747
 is not specified then this option causes matches to apply only if there
 
748
 are at least this many queries in the entire SHOW PROCESSLIST.
 
749
 
 
750
 
 
751
 
 
752
--verbose
 
753
 
 
754
 short form: -v
 
755
 
 
756
 Print information to STDOUT about what is being done.
 
757
 
 
758
 
 
759
 
 
760
 
 
761
ACTIONS
 
762
=======
 
763
 
 
764
 
 
765
These actions are taken for every matching query from all classes.
 
766
The actions are taken in this order: "--print", "--execute-command",
 
767
"--kill"/"--kill-query".  This order allows "--execute-command"
 
768
to see the output of "--print" and the query before
 
769
"--kill"/"--kill-query".  This may be helpful because pt-kill does
 
770
not pass any information to "--execute-command".
 
771
 
 
772
See also "GROUP, MATCH AND KILL".
 
773
 
 
774
 
 
775
--execute-command
 
776
 
 
777
 type: string; group: Actions
 
778
 
 
779
 Execute this command when a query matches.
 
780
 
 
781
 After the command is executed, pt-kill has no control over it, so the command
 
782
 is responsible for its own info gathering, logging, interval, etc.  The
 
783
 command is executed each time a query matches, so be careful that the command
 
784
 behaves well when multiple instances are ran.  No information from pt-kill is
 
785
 passed to the command.
 
786
 
 
787
 See also "--wait-before-kill".
 
788
 
 
789
 
 
790
 
 
791
--kill
 
792
 
 
793
 group: Actions
 
794
 
 
795
 Kill the connection for matching queries.
 
796
 
 
797
 This option makes pt-kill kill the connections (a.k.a. processes, threads) that
 
798
 have matching queries.  Use "--kill-query" if you only want to kill
 
799
 individual queries and not their connections.
 
800
 
 
801
 Unless "--print" is also given, no other information is printed that shows
 
802
 that pt-kill matched and killed a query.
 
803
 
 
804
 See also "--wait-before-kill" and "--wait-after-kill".
 
805
 
 
806
 
 
807
 
 
808
--kill-query
 
809
 
 
810
 group: Actions
 
811
 
 
812
 Kill matching queries.
 
813
 
 
814
 This option makes pt-kill kill matching queries.  This requires MySQL 5.0 or
 
815
 newer.  Unlike "--kill" which kills the connection for matching queries,
 
816
 this option only kills the query, not its connection.
 
817
 
 
818
 
 
819
 
 
820
--print
 
821
 
 
822
 group: Actions
 
823
 
 
824
 Print a KILL statement for matching queries; does not actually kill queries.
 
825
 
 
826
 If you just want to see which queries match and would be killed without
 
827
 actually killing them, specify "--print".  To both kill and print
 
828
 matching queries, specify both "--kill" and "--print".
 
829
 
 
830
 
 
831
 
 
832
 
 
833
 
 
834
***********
 
835
DSN OPTIONS
 
836
***********
 
837
 
 
838
 
 
839
These DSN options are used to create a DSN.  Each option is given like
 
840
\ ``option=value``\ .  The options are case-sensitive, so P and p are not the
 
841
same option.  There cannot be whitespace before or after the \ ``=``\  and
 
842
if the value contains whitespace it must be quoted.  DSN options are
 
843
comma-separated.  See the percona-toolkit manpage for full details.
 
844
 
 
845
 
 
846
\* A
 
847
 
 
848
 dsn: charset; copy: yes
 
849
 
 
850
 Default character set.
 
851
 
 
852
 
 
853
 
 
854
\* D
 
855
 
 
856
 dsn: database; copy: yes
 
857
 
 
858
 Default database.
 
859
 
 
860
 
 
861
 
 
862
\* F
 
863
 
 
864
 dsn: mysql_read_default_file; copy: yes
 
865
 
 
866
 Only read default options from the given file
 
867
 
 
868
 
 
869
 
 
870
\* h
 
871
 
 
872
 dsn: host; copy: yes
 
873
 
 
874
 Connect to host.
 
875
 
 
876
 
 
877
 
 
878
\* p
 
879
 
 
880
 dsn: password; copy: yes
 
881
 
 
882
 Password to use when connecting.
 
883
 
 
884
 
 
885
 
 
886
\* P
 
887
 
 
888
 dsn: port; copy: yes
 
889
 
 
890
 Port number to use for connection.
 
891
 
 
892
 
 
893
 
 
894
\* S
 
895
 
 
896
 dsn: mysql_socket; copy: yes
 
897
 
 
898
 Socket file to use for connection.
 
899
 
 
900
 
 
901
 
 
902
\* u
 
903
 
 
904
 dsn: user; copy: yes
 
905
 
 
906
 User for login if not current user.
 
907
 
 
908
 
 
909
 
 
910
 
 
911
***********
 
912
DOWNLOADING
 
913
***********
 
914
 
 
915
 
 
916
Visit `http://www.percona.com/software/ <http://www.percona.com/software/>`_ to download the latest release of
 
917
Percona Toolkit.  Or, to get the latest release from the command line:
 
918
 
 
919
 
 
920
.. code-block:: perl
 
921
 
 
922
    wget percona.com/latest/percona-toolkit/PKG
 
923
 
 
924
 
 
925
Replace \ ``PKG``\  with \ ``tar``\ , \ ``rpm``\ , or \ ``deb``\  to download the package in that
 
926
format.  You can also get individual tools from the latest release:
 
927
 
 
928
 
 
929
.. code-block:: perl
 
930
 
 
931
    wget percona.com/latest/percona-toolkit/TOOL
 
932
 
 
933
 
 
934
Replace \ ``TOOL``\  with the name of any tool.
 
935
 
 
936
 
 
937
***********
 
938
ENVIRONMENT
 
939
***********
 
940
 
 
941
 
 
942
The environment variable \ ``PTDEBUG``\  enables verbose debugging output to STDERR.
 
943
To enable debugging and capture all output to a file, run the tool like:
 
944
 
 
945
 
 
946
.. code-block:: perl
 
947
 
 
948
    PTDEBUG=1 pt-kill ... > FILE 2>&1
 
949
 
 
950
 
 
951
Be careful: debugging output is voluminous and can generate several megabytes
 
952
of output.
 
953
 
 
954
 
 
955
*******************
 
956
SYSTEM REQUIREMENTS
 
957
*******************
 
958
 
 
959
 
 
960
You need Perl, DBI, DBD::mysql, and some core packages that ought to be
 
961
installed in any reasonably new version of Perl.
 
962
 
 
963
 
 
964
****
 
965
BUGS
 
966
****
 
967
 
 
968
 
 
969
For a list of known bugs, see `http://www.percona.com/bugs/pt-kill <http://www.percona.com/bugs/pt-kill>`_.
 
970
 
 
971
Please report bugs at `https://bugs.launchpad.net/percona-toolkit <https://bugs.launchpad.net/percona-toolkit>`_.
 
972
Include the following information in your bug report:
 
973
 
 
974
 
 
975
\* Complete command-line used to run the tool
 
976
 
 
977
 
 
978
 
 
979
\* Tool "--version"
 
980
 
 
981
 
 
982
 
 
983
\* MySQL version of all servers involved
 
984
 
 
985
 
 
986
 
 
987
\* Output from the tool including STDERR
 
988
 
 
989
 
 
990
 
 
991
\* Input files (log/dump/config files, etc.)
 
992
 
 
993
 
 
994
 
 
995
If possible, include debugging output by running the tool with \ ``PTDEBUG``\ ;
 
996
see "ENVIRONMENT".
 
997
 
 
998
 
 
999
*******
 
1000
AUTHORS
 
1001
*******
 
1002
 
 
1003
 
 
1004
Baron Schwartz and Daniel Nichter
 
1005
 
 
1006
 
 
1007
*********************
 
1008
ABOUT PERCONA TOOLKIT
 
1009
*********************
 
1010
 
 
1011
 
 
1012
This tool is part of Percona Toolkit, a collection of advanced command-line
 
1013
tools developed by Percona for MySQL support and consulting.  Percona Toolkit
 
1014
was forked from two projects in June, 2011: Maatkit and Aspersa.  Those
 
1015
projects were created by Baron Schwartz and developed primarily by him and
 
1016
Daniel Nichter, both of whom are employed by Percona.  Visit
 
1017
`http://www.percona.com/software/ <http://www.percona.com/software/>`_ for more software developed by Percona.
 
1018
 
 
1019
 
 
1020
********************************
 
1021
COPYRIGHT, LICENSE, AND WARRANTY
 
1022
********************************
 
1023
 
 
1024
 
 
1025
This program is copyright 2009-2011 Baron Schwartz, 2011 Percona Inc.
 
1026
Feedback and improvements are welcome.
 
1027
 
 
1028
THIS PROGRAM IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
 
1029
WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
 
1030
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 
1031
 
 
1032
This program is free software; you can redistribute it and/or modify it under
 
1033
the terms of the GNU General Public License as published by the Free Software
 
1034
Foundation, version 2; OR the Perl Artistic License.  On UNIX and similar
 
1035
systems, you can issue \`man perlgpl' or \`man perlartistic' to read these
 
1036
licenses.
 
1037
 
 
1038
You should have received a copy of the GNU General Public License along with
 
1039
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
 
1040
Place, Suite 330, Boston, MA  02111-1307  USA.
 
1041
 
 
1042
 
 
1043
*******
 
1044
VERSION
 
1045
*******
 
1046
 
 
1047
 
 
1048
Percona Toolkit v1.0.0 released 2011-08-01
 
1049