Merge lp:~percona-toolkit-dev/percona-toolkit/pt-stalk-removes-non-empty-files-that-start-with-empty-line-1425478 into lp:~percona-toolkit-dev/percona-toolkit/release-2.2.14

Proposed by Frank Cizmich
Status: Merged
Approved by: Daniel Nichter
Approved revision: 614
Merged at revision: 618
Proposed branch: lp:~percona-toolkit-dev/percona-toolkit/pt-stalk-removes-non-empty-files-that-start-with-empty-line-1425478
Merge into: lp:~percona-toolkit-dev/percona-toolkit/release-2.2.14
Diff against target: 12 lines (+1/-1)
1 file modified
bin/pt-stalk (+1/-1)
To merge this branch: bzr merge lp:~percona-toolkit-dev/percona-toolkit/pt-stalk-removes-non-empty-files-that-start-with-empty-line-1425478
Reviewer Review Type Date Requested Status
Daniel Nichter Approve
Review via email: mp+254453@code.launchpad.net

Description of the change

When "SHOW INNODB STATUS" fails for some reason, pt-stalk resorts to fetching data from /proc/<mysql_pid>/fd/<N> , where N is the file descriptor that contains innodb status data.
In that case, the first line of the collected file is empty.
pt-stalk deletes files where first line is empty.

Solved by simply increasing the number of lines checked to 10.

Note: Not sure the original intent of checking only the first line instead of whether the file is empty as a whole, ... I assume it's an efficiency issue?

To post a comment you must log in.
Revision history for this message
Daniel Nichter (daniel-nichter) wrote :

Should be ok. Intent is really just to see if there's a TS line and that TS should be the first line. So that --max-count just prevents grep from going too far.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/pt-stalk'
2--- bin/pt-stalk 2015-01-23 10:19:56 +0000
3+++ bin/pt-stalk 2015-03-27 20:03:17 +0000
4@@ -1000,7 +1000,7 @@
5 wait_for_subshells $OPT_RUN_TIME
6 kill_all_subshells
7 for file in "$d/$p-"*; do
8- if [ -z "$(grep -v '^TS ' --max-count 1 "$file")" ]; then
9+ if [ -z "$(grep -v '^TS ' --max-count 10 "$file")" ]; then
10 log "Removing empty file $file";
11 rm "$file"
12 fi

Subscribers

People subscribed via source and target branches

to all changes: