pmp-check-mysql-deadlocks interval argument accepts fractions of a second but silently performs rounding at 1-minute granularity

Bug #1154774 reported by Ryan Lowe
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Percona Monitoring Plugins
Fix Released
Low
Unassigned

Bug Description

pmp-check-mysql-deadlocks interval argument accepts fractions of a second but silently performs rounding at 1-minute granularity. For example:

perl ./pmp-check-mysql-deadlocks -i 0.0000001

Executes just fine, but internally INTERVAL subtraction (and rounding) is used, which is only to the nearest minute.

(via line 62)

62 LEVEL=$(mysql_exec "SELECT COUNT(*) FROM ${OPT_TABLE} WHERE ts >= NOW() - INTERVAL ${OPT_INTERVAL} MINUTE")

Here's my example of the one-minute rounding:

mysql> select now(), now() - interval 0.6 minute;
+---------------------+-----------------------------+
| now() | now() - interval 0.6 minute |
+---------------------+-----------------------------+
| 2013-03-13 13:24:27 | 2013-03-13 13:23:27 |
+---------------------+-----------------------------+
1 row in set (0.00 sec)

mysql> select now(), now() - interval 0.5 minute;
+---------------------+-----------------------------+
| now() | now() - interval 0.5 minute |
+---------------------+-----------------------------+
| 2013-03-13 13:24:35 | 2013-03-13 13:23:35 |
+---------------------+-----------------------------+
1 row in set (0.00 sec)

mysql> select now(), now() - interval 0.4 minute;
+---------------------+-----------------------------+
| now() | now() - interval 0.4 minute |
+---------------------+-----------------------------+
| 2013-03-13 13:26:19 | 2013-03-13 13:26:19 |
+---------------------+-----------------------------+
1 row in set (0.00 sec)

Solution:

Either fix it to round to the nearest second (except in 5.6, which can be more granular) or specify this limitation in the documentation.

Tags: nagios
Revision history for this message
Roman Vynar (roman-vynar) wrote :

Will be rounding to the nearest second.

- LEVEL=$(mysql_exec "SELECT COUNT(*) FROM ${OPT_TABLE} WHERE ts >= NOW() - INTERVAL ${OPT_INTERVAL} MINUTE")
+ LEVEL=$(mysql_exec "SELECT COUNT(*) FROM ${OPT_TABLE} WHERE ts >= NOW() - INTERVAL ${OPT_INTERVAL}*60 SECOND")

Changed in percona-monitoring-plugins:
status: New → In Progress
milestone: none → 1.0.3
importance: Undecided → Low
tags: added: nagios
Changed in percona-monitoring-plugins:
status: In Progress → Fix Committed
Changed in percona-monitoring-plugins:
status: Fix Committed → 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.