LP #1425478: pt-stalk removes non-empty files that start with empty line

Description

**Reported in Launchpad by Robert Wunderer last update 15-04-2015 15:41:18

pt-stalk 2.2.13
Percona Server version 5.6.21-70.0-log

The code for removing empty files also deletes files that are not empty, but start with an empty line. The behaviour does not depend on any command line options or user settings.

E.g: The output produced by pt-stalk and written to the files

*-innodbstatus[12]

starts with an empty line:

-------------------------------
=====================================
2015-02-24 17:27:52 7eb6d3fc2700 INNODB MONITOR OUTPUT
=====================================
Per second averages calculated from the last 31 seconds
...
-------------------------------

Thus the expression in line 1003

-z "$(grep -v '^TS ' --max-count 1 "$file")"

holds true and the files get deleted even though it holds useful information.

Environment

None

Smart Checklist

Activity

Show:

lpjirasync January 24, 2018 at 4:38 PM

**Comment from Launchpad by: Frank Cizmich on: 09-04-2015 20:26:50

Fixed as mentioned in above.

lpjirasync January 24, 2018 at 4:38 PM

**Comment from Launchpad by: Frank Cizmich on: 26-02-2015 18:50:19

Could only partially reproduce but the code seems clear.

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 is indeed empty.

Simplest fix is to increase --max-count to a higher number.

Done

Details

Assignee

Reporter

Priority

Smart Checklist

Created January 24, 2018 at 4:37 PM
Updated January 24, 2018 at 4:38 PM
Resolved January 24, 2018 at 4:38 PM