Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print database name when logging pt-kill output to file #405

Open
wants to merge 2 commits into
base: 3.x
Choose a base branch
from

Conversation

dreamydb
Copy link

@dreamydb dreamydb commented Jul 2, 2019

With multiple dbs in a single instance, its helpful to have pt-kill print the database name to the log file.

This addresses bug: https://blueprints.launchpad.net/percona-toolkit/+spec/pt-kill-log-database

With the suggested code change, an example output would show db name in the fourth column as shown below:

pt-kill --user=<user> --password=<password> --socket=<socket> --busy-time=20 --interval=15 --print --match-command=Query --daemonize --log <logfile>

# 2019-05-30T10:30:42 KILL 23063482 skyzer (Query 41 sec) SELECT domain FROM domains_data
# 2019-05-30T10:46:57 KILL 23080285 ddb2 (Query 20 sec) SELECT option_name, option_value FROM wp_options WHERE autoload = 'yes'
# 2019-05-30T10:47:12 KILL 23080285 ddb2 (Query 35 sec) SELECT option_name, option_value FROM wp_options WHERE autoload = 'yes'
# 2019-05-30T23:18:30 KILL 24551301 skyzer (Query 27 sec) DELETE FROM domains_data WHERE completed IS NULL
# 2019-05-30T23:22:00 KILL 24559692 skyzer (Query 25 sec) optimize table domains_data
# 2019-05-30T23:23:09 KILL 24559702 alph_co (Query 27 sec) UPDATE fus_settings SET settings_value=settings_value+1 WHERE settings_name='counter'

@it-percona
Copy link
Contributor

it-percona commented Jul 2, 2019

CLA assistant check
All committers have signed the CLA.

Copy link
Collaborator

@svetasmirnova svetasmirnova left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution.

Your code fails if the default database is not set ($query->{db} is undef), it does not add additional positional formatting for the new element, and breaks tests in the t/pt-kill directory. Please fix these issues.

@svetasmirnova svetasmirnova changed the base branch from 3.0 to 3.x November 7, 2023 13:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants