Introduction of innodb_read_views_memory overwrites the InnoDB total memory allocated output in cacti

Bug #1188519 reported by Art van Scheppingen
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Percona Monitoring Plugins
Fix Released
Medium
Unassigned

Bug Description

With the innodb_read_views_memory feature introduced in the Percona-Server 5.5.31-30.3 the output of SHOW ENGINE INNODB STATUS differs slightly and this breaks the total memory allocated (total_mem_alloc) in the cacti poller.
The second line is the additional line introduced by this feature:

Total memory allocated 31173672960 in additional pool allocated 0
Total memory allocated by read views 88

As the Cacti poller only matches the first three words of the output it will match both lines. Also PHP is not croaking about a non-existent array key that also gets assigned to the additional pool allocation (additional_pool_alloc).

To reproduce I created a simple php script that shows you how it will overwrite the output:
<?php
ini_set('display_errors', '1');

function to_int ( $str ) {
   global $debug;
   preg_match('{(\d+)}', $str, $m);
   if ( isset($m[1]) ) {
      return $m[1];
   }
   elseif ( $debug ) {
      print_r(debug_backtrace());
   }
   else {
      return 0;
   }
}

// Example data. This is the actual order of fields in the SHOW ENGINE InnoDB STATUS
$lines = array(
  "Total memory allocated 31173672960 in additional pool allocated 0",
  "Total memory allocated by read views 88"
);

foreach($lines as $line) {
   //Split the line in the same manner as ss_get_mysql_stats.php does
   $row = preg_split('/ +/', $line);

   //This is the actual line we're parsing now
   print $line."\n";

   if (strpos($line, "Total memory allocated") === 0 ) {
     # Total memory allocated 29642194944; in additional pool allocated 0
     $results['total_mem_alloc'] = to_int($row[3]);
     $results['additional_pool_alloc'] = to_int($row[8]);
   }
   //And here you can see that it actually overwrites the data
   print_r($results);
}
?>

I also submitted a simple patch that only checks for the number of items in row to only match the first line. Of course in the future it might be beneficial to also capture the second line and graph this accordingly.

Tags: cacti innodb
Revision history for this message
Art van Scheppingen (4-a0t-5) wrote :
Changed in percona-monitoring-plugins:
status: New → Confirmed
importance: Undecided → Medium
Revision history for this message
Roman Vynar (roman-vynar) wrote :

Thanks for the report.

This way it should be more stable in case of future changes:
- elseif (strpos($line, "Total memory allocated") === 0 ) {
+ elseif (strpos($line, "Total memory allocated") === 0 && strpos($line, "in additional pool allocated") > 0 ) {

Changed in percona-monitoring-plugins:
status: Confirmed → Fix Committed
Changed in percona-monitoring-plugins:
milestone: none → 1.0.4
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.