Bug #81681 ndbinfo.ndb$cpustat_% tables do not match in SQL vs NDBD
Submitted: 1 Jun 2016 22:13 Modified: 13 Jun 2016 17:34
Reporter: Matthew Montgomery Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Cluster: Cluster (NDB) storage engine Severity:S3 (Non-critical)
Version: OS:Any
Assigned to: CPU Architecture:Any

[1 Jun 2016 22:13] Matthew Montgomery
Description:
The first time you read from any of the ndbinfo.cpustat(_1sec,_20sec, or _50ms) tables after restart, there is a warning raised saying that the table definition does not match what is in ndb. 
In each case the thread_spinning or spin_time column is missing from the table definition in ndb.

How to repeat:
mysql> select * from cpuinfo; 
ERROR 1146 (42S02): Table 'ndbinfo.cpuinfo' doesn't exist
mysql> select * from cpustat; 
+---------+--------+---------+-----------+---------+-------------+-----------------+-------------+--------------------+--------------+
| node_id | thr_no | OS_user | OS_system | OS_idle | thread_exec | thread_sleeping | thread_send | thread_buffer_full | elapsed_time |
+---------+--------+---------+-----------+---------+-------------+-----------------+-------------+--------------------+--------------+
|       1 |      0 |       1 |         1 |      98 |           3 |              97 |           0 |                  0 |      1026385 |
|       1 |      1 |       1 |         1 |      98 |           1 |              99 |           0 |                  0 |      1019156 |
|       1 |      2 |       1 |         0 |      99 |           0 |             100 |           0 |                  0 |      1026552 |
|       1 |      3 |       1 |         0 |      99 |           0 |             100 |           0 |                  0 |      1025752 |
|       1 |      4 |       2 |         0 |      98 |           1 |              99 |           0 |                  0 |      1036239 |
|       1 |      5 |       1 |         0 |      98 |           0 |             100 |           0 |                  0 |      1012829 |
|       1 |      6 |       6 |         4 |      90 |           3 |              97 |           0 |                  0 |      1011222 |
|       2 |      0 |       1 |         0 |      98 |           1 |              99 |           0 |                  0 |      1015000 |
|       2 |      1 |       1 |         1 |      98 |           1 |              99 |           0 |                  0 |      1018885 |
|       2 |      2 |       1 |         0 |      99 |           1 |              99 |           0 |                  0 |      1023944 |
|       2 |      3 |       1 |         0 |      99 |           0 |             100 |           0 |                  0 |      1013012 |
|       2 |      4 |       1 |         0 |      99 |           0 |             100 |           0 |                  0 |      1013135 |
|       2 |      5 |       1 |         0 |      99 |           0 |             100 |           0 |                  0 |      1026514 |
|       2 |      6 |       5 |         2 |      93 |           3 |              97 |           0 |                  0 |      1014065 |
+---------+--------+---------+-----------+---------+-------------+-----------------+-------------+--------------------+--------------+
14 rows in set, 1 warning (0.04 sec)

mysql> show warnings\G
*************************** 1. row ***************************
  Level: Note
   Code: 40001
Message: Table 'ndb$cpustat' is defined differently in NDB, there are more columns available. The SQL to regenerate is: 'CREATE TABLE `ndbinfo`.`ndb$cpustat` (`node_id` INT UNSIGNED, `thr_no` INT UNSIGNED, `OS_user` INT UNSIGNED, `OS_system` INT UNSIGNED, `OS_idle` INT UNSIGNED, `thread_exec` INT UNSIGNED, `thread_sleeping` INT UNSIGNED, `thread_spinning` INT UNSIGNED, `thread_send` INT UNSIGNED, `thread_buffer_full` INT UNSIGNED, `elapsed_time` INT UNSIGNED) ENGINE=NDBINFO'
1 row in set (0.00 sec)

mysql> show create table `ndbinfo`.`ndb$cpustat`\G
*************************** 1. row ***************************
       Table: ndb$cpustat
Create Table: CREATE TABLE `ndb$cpustat` (
  `node_id` int(10) unsigned DEFAULT NULL COMMENT 'node id',
  `thr_no` int(10) unsigned DEFAULT NULL COMMENT 'thread_number',
  `OS_user` int(10) unsigned DEFAULT NULL COMMENT 'Percentage time spent in user mode as reported by OS',
  `OS_system` int(10) unsigned DEFAULT NULL COMMENT 'Percentage time spent in system mode as reported by OS',
  `OS_idle` int(10) unsigned DEFAULT NULL COMMENT 'Perncentage time spent in idle mode as reported by OS',
  `thread_exec` int(10) unsigned DEFAULT NULL COMMENT 'Percetage time spent executing as calculated by thread',
  `thread_sleeping` int(10) unsigned DEFAULT NULL COMMENT 'Percentage time spent sleeping as calculated by thread',
  `thread_send` int(10) unsigned DEFAULT NULL COMMENT 'Percentage time spent sending as calculated by thread',
  `thread_buffer_full` int(10) unsigned DEFAULT NULL COMMENT 'Percentage time spent in buffer full as calculated by thread',
  `elapsed_time` int(10) unsigned DEFAULT NULL COMMENT 'Elapsed time in microseconds for measurement'
) ENGINE=NDBINFO DEFAULT CHARSET=latin1 COMMENT='Thread CPU stats for last second'
1 row in set (0.01 sec)

Suggested fix:
Correct table defs used during --initialize
[13 Jun 2016 17:34] Jon Stephens
Documented fix in the NDB 7.5.3 changelog as follows:

    Following a restart of the cluster, the first attempt to read from any
    of the ndbinfo tables cpustat, cpustat_50ms, cpustat_1sec, or
    cpustat_20sec generated a warning that columns were missing from the
    table. In each case, the thread_sleeping and spin_time columns were
    missing.

Closed.