pt-sift loses STDIN after pt-diskstats

Bug #946707 reported by Baron Schwartz
26
This bug affects 5 people
Affects Status Importance Assigned to Milestone
Percona Toolkit moved to https://jira.percona.com/projects/PT
Fix Released
Medium
Brian Fraser

Bug Description

I am unsure of the cause, but the new pt-diskstats seems to cause the 'read' command to fail in pt-sift. The error message is 'resource temporarily unavailable' and the code in question is here:

446 # Capture and handle the interactive key-strokes.
447 KEY=""
448 read -n 1 -s KEY

Note that I have committed a patch to work around this in the fix for bug 945834 so you won't see the problem unless you invoke pt-diskstats correctly and don't catch an error in 'read'. Thus my suspicion that pt-diskstats does something with STDIN and makes it unavailable to pt-sift afterwards.

Revision history for this message
Fernando Ipar (fipar) wrote :

Should this be available already?
I have downloaded from percona.com/get (pt-sift, and let it download pt-diskstats again) and it's still not working,.
As a temporary workaround, I have redirected stdin to the keyboard just before that read -n 1 -s KEY on pt-sift.

Revision history for this message
Baron Schwartz (baron-xaprb) wrote :

This problem still exists. Fernando, how did you redirect stdin to the keyboard?

Revision history for this message
Raghavendra D Prabhu (raghavendra-prabhu) wrote :

Here is the workaround I used (based on what Fernando implied)

--- /mine/bin/site_perl/pt-sift 2012-05-01 10:35:15.008088566 +0530
+++ pt-sift.fixed 2012-05-02 19:42:14.554063131 +0530
@@ -465,6 +465,7 @@

       # Capture and handle the interactive key-strokes.
       tput sgr0
+ exec 0<$(tty)
       KEY=""
       if ! read -n 1 -s KEY 2>/dev/null; then
          echo "Error while trying to read interactive keystroke command. Exiting."

Revision history for this message
Baron Schwartz (baron-xaprb) wrote :

Another suggestion was this:

exec </dev/pts/0

Not sure what is the more portable workaround. Of course, pt-diskstats needs to be fixed too.

Revision history for this message
Raghavendra D Prabhu (raghavendra-prabhu) wrote :

The /dev/pts/0 may not work because in a master-slave multiplex mode (which is the default now), there are about 16 of them (/dev/pts/1..16), so in tmux/screen, you will have each one of them allocated different /dev/pts/x

Revision history for this message
Dave Juntgen (djuntgen) wrote :

Any news on this getting fixed before the next release?

I added "exec </dev/pts/0" line and things seem to be working, although I'm not sure how well.

Brian Fraser (fraserbn)
Changed in percona-toolkit:
status: Confirmed → In Progress
Brian Fraser (fraserbn)
Changed in percona-toolkit:
milestone: none → 2.1.2
status: In Progress → Fix Committed
Changed in percona-toolkit:
status: Fix Committed → Fix Released
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-492

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.