pt-stalk "--config" incorrect parsing

Bug #1449998 reported by Emanuelis
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Percona Toolkit moved to https://jira.percona.com/projects/PT
Confirmed
Undecided
Unassigned

Bug Description

# strace -e open pt-stalk --config=/tmp/test.conf 2>&1 | grep \\.conf
open("/etc/percona-toolkit/pt-stalk.conf", O_RDONLY) = 3

There are two bugs:
1. Documentation (http://www.percona.com/doc/percona-toolkit/2.2/pt-stalk.html#cmdoption-pt-stalk--config) doesn't say anything about default config files:
/etc/percona-toolkit/percona-toolkit.conf
/etc/percona-toolkit/$TOOL.conf
$HOME/.percona-toolkit.conf
$HOME/.$TOOL.conf

2. --config doesn't work with a "=" (see my example).

This unclarity/bug caused a crash of whole PXC cluster :(

pt-stalk 2.2.13

Tags: pt-stalk doc
Revision history for this message
Nilnandan Joshi (nilnandan-joshi) wrote :

Hi,

For 1, there is already mentioned in documentation that where default config files can be. Check this
https://www.percona.com/doc/percona-toolkit/2.2/configuration_files.html#read-order

For 2, Unable to reproduce the error. Can you try to check with later version 2.2.14? Also is it possible for you to provide test case?

nilnandan@desktop:~$ sudo pt-stalk --no-stalk --iterations=2 --sleep=30 --config=/home/nilnandan/.my.cnf --dest=/home/nilnandan
2015_06_09_14_12_10 Starting /usr/bin/pt-stalk --function=status --variable=Threads_running --threshold=25 --match= --cycles=0 --interval=1 --iterations=2 --run-time=30 --sleep=30 --dest=/home/nilnandan --prefix= --notify-by-email= --log=/var/log/pt-stalk.log --pid=/var/run/pt-stalk.pid --plugin=
2015_06_09_14_12_10 Not stalking; collect triggered immediately
2015_06_09_14_12_10 Collect 1 triggered
2015_06_09_14_12_10 Collect 1 PID 24848
2015_06_09_14_14_01 Collect 1 done
2015_06_09_14_14_01 Sleeping 30 seconds after collect
2015_06_09_14_14_31 Not stalking; collect triggered immediately
2015_06_09_14_14_31 Collect 2 triggered
2015_06_09_14_14_31 Collect 2 PID 16965
2015_06_09_14_14_31 Collect 2 done
2015_06_09_14_14_31 Waiting up to 90 seconds for subprocesses to finish...
2015_06_09_14_15_02 Exiting because no more iterations
2015_06_09_14_15_02 /usr/bin/pt-stalk exit status 0
nilnandan@desktop:~$
nilnandan@desktop:~$ pt-stalk --version
pt-stalk 2.2.14
nilnandan@desktop:~$

Changed in percona-toolkit:
status: New → Confirmed
status: Confirmed → Incomplete
Revision history for this message
Emanuelis (emanuelis) wrote :

For 1, I meant that there is no single word about configuration files read order in _pt-stalk_ documentation page. It would be valuable to add a link to "configuration files" page somewhere in https://www.percona.com/doc/percona-toolkit/2.2/pt-stalk.html#cmdoption-pt-stalk--config section.

For 2,
/usr/bin/pt-stalk contains lines:
 249 if [ $# -ge 2 ] && [ "$1" = "--config" ]; then
 250 shift # --config
 251 local user_config_files="$1"
 252 shift # that ^
 253 local IFS=","
 254 for user_config_file in $user_config_files; do
 255 _parse_config_files "$user_config_file"
 256 done
 257 else

So, it checks if the first argument is "--config":
[ "$1" = "--config" ]

When the first argument is "--config=file.conf" this doesn't work (so your example is not loading /home/nilnandan/.my.cnf file)

Now I can see in https://www.percona.com/doc/percona-toolkit/2.2/configuration_files.html#specifying that this behavior is documented globally for Percona Toolkit. But, please, add a link on every tool's documentation page near "--config".

Revision history for this message
Nilnandan Joshi (nilnandan-joshi) wrote :

Set to confirmed as a feature request. We should specify above details on respective pages.

tags: added: doc
Changed in percona-toolkit:
status: Incomplete → Confirmed
Revision history for this message
bar down (bardown) wrote :

Are we sure this pt-stalk --config command actually parses correctly still?

Aside from the above mention of --config= not working, it seems things are still not parsed correctly (or honored) when used without the = sign.

For instance when using multiple configs, it seems that the LAST config is the only one honored:

pt-stalk --config ./deadlocks.conf,./longquery.conf,./highcnx.conf --dest=/var/lib/mysql/pt-stalk --log=/var/log/mysql/pt-stalk/pt-stalk.log --sleep=30 --defaults-file=/etc/percona-toolkit.conf

output:
2016_04_25_15_51_59 Starting /usr/bin/pt-stalk --function=status --variable=Threads_running --threshold=100 --match= --cycles=5 --interval=1 --iterations= --run-time=30 --sleep=30 --dest=/var/lib/mysql/pt-stalk --prefix= --notify-by-email= --log=/var/log/mysql/pt-stalk/pt-stalk.log --pid=/var/run/pt-stalk.pid --plugin=

In this example, my longquery.conf is not triggering, but if I put it as the last argument in the list of configs, it does:
[root@cer-lucastestl1 configs]# pt-stalk --config ./deadlocks.conf,./highcnx.conf,./longquery.conf --dest=/var/lib/mysql/pt-stalk --log=/var/log/mysql/pt-stalk/pt-stalk.log --sleep=30 --defaults-file=/etc/percona-toolkit.conf
2016_04_25_15_52_46 Starting /usr/bin/pt-stalk --function=/usr/local/jump/bin/mysql/pt-stalk/functions/longquery.sh --variable=Long_Query --threshold=0 --match= --cycles=5 --interval=1 --iterations= --run-time=30 --sleep=30 --dest=/var/lib/mysql/pt-stalk --prefix= --notify-by-email= --log=/var/log/mysql/pt-stalk/pt-stalk.log --pid=/var/run/pt-stalk.pid --plugin=
2016_04_25_15_53_52 Check results: /usr/local/jump/bin/mysql/pt-stalk/functions/longquery.sh(Long_Query)=1, matched=yes, cycles_true=1
2016_04_25_15_53_53 Check results: /usr/local/jump/bin/mysql/pt-stalk/functions/longquery.sh(Long_Query)=1, matched=yes, cycles_true=2
2016_04_25_15_53_54 Check results: /usr/local/jump/bin/mysql/pt-stalk/functions/longquery.sh(Long_Query)=1, matched=yes, cycles_true=3
2016_04_25_15_53_55 Check results: /usr/local/jump/bin/mysql/pt-stalk/functions/longquery.sh(Long_Query)=1, matched=yes, cycles_true=4
2016_04_25_15_53_56 Check results: /usr/local/jump/bin/mysql/pt-stalk/functions/longquery.sh(Long_Query)=1, matched=yes, cycles_true=5
2016_04_25_15_53_56 Collect 1 triggered
2016_04_25_15_53_56 Collect 1 PID 50385
2016_04_25_15_53_56 Collect 1 done
2016_04_25_15_53_56 Sleeping 30 seconds after collect

Version:
pt-stalk 2.2.7

Revision history for this message
Shahriyar Rzayev (rzayev-sehriyar) wrote :

Percona now uses JIRA for bug reports so this bug report is migrated to: https://jira.percona.com/browse/PT-1278

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.