pmp-check-mysql-deadlocks interval argument accepts fractions of a second but silently performs rounding at 1-minute granularity
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Percona Monitoring Plugins |
Fix Released
|
Low
|
Unassigned |
Bug Description
pmp-check-
perl ./pmp-check-
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.
Changed in percona-monitoring-plugins: | |
status: | In Progress → Fix Committed |
Changed in percona-monitoring-plugins: | |
status: | Fix Committed → Fix Released |
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")