mytop wrap problem with high thread ids

Bug #303960 reported by Troy Jendra
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
mytop (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

Binary package hint: mytop

When mysql has been running for a while, and the thread ids get above 99999999, mytop becomes unusable, because every line wraps, eg on an 80 column terminal

      Id User Host/IP DB Time Cmd Query or State
      -- ---- ------- -- ---- --- ----------
121417123 adaggrega adagcluster1 adaggregat 0 Query UPDATE `table_st
u

This is because mytop uses a fixed width of 8 characters for thread id, but doesn't enforce it.

I've added a bit of code to truncate the output string to the width of the display. Here is a diff:

$ diff -u mytop.orig mytop
--- mytop.orig 2008-12-01 11:12:49.000000000 +0000
+++ mytop 2008-12-01 11:13:15.000000000 +0000
@@ -1047,9 +1047,11 @@
             print GREEN() if $thread->{Command} eq 'Connect';
         }

- printf "%8d %9.9s %15.15s %10.10s %9d %6.6s %-${free}.${free}s\n",
+ # truncate output to $width characters to prevent wrapping
+ my $output = sprintf "%8d %9.9s %15.15s %10.10s %9d %6.6s %-${free}.${free}s",
             $thread->{Id}, $thread->{User}, $thread->{Host}, $thread->{db},
             $thread->{Time}, $thread->{Command}, $smInfo;
+ printf "%s\n", substr($output, 0, $width);

         print RESET() if $HAS_COLOR;

Version of Ubuntu
# lsb_release -rd
Description: Ubuntu 8.04.1
Release: 8.04

Verion of mytop
# apt-cache policy mytop
mytop:
  Installed: 1.6-1
  Candidate: 1.6-1

Revision history for this message
Troy Jendra (troyjendra) wrote :

A change has been made for the latest LTS release which gives another two columns for the id, which means that it might be still broken if you use 100 times as many threads again, but I'm not about to test that case.

Please close.

Troy Jendra (troyjendra)
Changed in mytop (Ubuntu):
status: New → Fix Released
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.