mysqldumpslow bug— does not aggregate times

來源:互聯網
上載者:User

在使用mysqldumpslow 對慢查詢日誌進行分析時,發現有關於查詢時間,鎖住時間,檢查的行數等不能正確顯示,都是N

How to repeat:I activated the slow query log and produced some slow queries. The slow query log contains now entries like # Time: 080129 11:51:12# User@Host: root[root] @ localhost []# Query_time: 0.001565  Lock_time: 0.000051 Rows_sent: 1  Rows_examined: 1839SET timestamp=1201603872;SELECT COUNT(*) FROM city_huge, Country WHERE city_huge.CountryCode=Country.Code AND Country.Continent='Asia' AND Country.Population < 1000000;If I now run mysqldumpslow the aggregated times are always 0.00:Count: 8  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), root[root]@localhost  # Query_time: N.N  Lock_time: N.N Rows_sent: N  Rows_examined: N  SET timestamp=N;  SELECT COUNT(*) FROM city_huge, Country WHERE city_huge.CountryCode=Country.Code AND Country.Continent='S' AND Country.Population < N

這是一個bug見於mysqldumpslow bug以及mysqldumpslow bug

      Change the capturing regex to account for decimal also.modified:  scripts/mysqldumpslow.sh=== modified file 'scripts/mysqldumpslow.sh'--- a/scripts/mysqldumpslow.sh2007-12-28 00:02:28 +0000+++ b/scripts/mysqldumpslow.sh2008-07-07 22:56:53 +0000@@ -83,7 +83,7 @@ while ( defined($_ = shift @pending) or      s/^#? Time: \d{6}\s+\d+:\d+:\d+.*\n//;     my ($user,$host) = s/^#? User\@Host:\s+(\S+)\s+\@\s+(\S+).*\n// ? ($1,$2) : ('',''); -    s/^# Query_time: (\d+)  Lock_time: (\d+)  Rows_sent: (\d+).*\n//;+    s/^# Query_time: ([0-9.]+)  Lock_time: ([0-9.]+)  Rows_sent: ([0-9.]+).*\n//;     my ($t, $l, $r) = ($1, $2, $3);     $t -= $l unless $opt{l};

修複:

[root@mfsmaster ~]# locate mysqldumpslow/usr/bin/mysqldumpslow/usr/local/mysql-search/bin/mysqldumpslow

之後直接修改檔案:

vi /usr/bin/mysqldumpslow

s/^# Query_time: (\d+)  Lock_time: (\d+)  Rows_sent: (\d+).*\n//;

修改為:

s/^# Query_time: ([0-9.]+)  Lock_time: ([0-9.]+)  Rows_sent: ([0-9.]+).*\n//;

或者:

s/^# Query_time: (\d+\.?\d*)\s+Lock_time: (\d+\.?\d*)\s+Rows_sent: (\d+\.?\d*).*\n//;

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.