Bug #78115 ps_is_instrument_default_enabled and ps_is_instrument_default_timed in 5.7.7+
Submitted: 18 Aug 2015 0:39 Modified: 5 Oct 2015 18:48
Reporter: Jesper wisborg Krogh Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: SYS Schema Severity:S2 (Serious)
Version:5.7.7 OS:Any
Assigned to: CPU Architecture:Any

[18 Aug 2015 0:39] Jesper wisborg Krogh
Description:
The sys schema functions ps_is_instrument_default_enabled and ps_is_instrument_default_timed returns the wrong results in 5.7.7 for some of the instruments as the default value has been changed or the instrument is new.

How to repeat:
From 5.7.9:

mysql> SELECT NAME, ENABLED FROM performance_schema.setup_instruments WHERE sys.ps_is_instrument_default_enabled(NAME) <> ENABLED;
+---------------------------------------------------------+---------+
| NAME                                                    | ENABLED |
+---------------------------------------------------------+---------+
| stage/sql/copy to tmp table                             | YES     |
| stage/innodb/alter table (end)                          | YES     |
| stage/innodb/alter table (flush)                        | YES     |
| stage/innodb/alter table (insert)                       | YES     |
| stage/innodb/alter table (log apply index)              | YES     |
| stage/innodb/alter table (log apply table)              | YES     |
| stage/innodb/alter table (merge sort)                   | YES     |
| stage/innodb/alter table (read PK and internal sort)    | YES     |
| stage/innodb/buffer pool load                           | YES     |
| memory/performance_schema/mutex_instances               | YES     |
| memory/performance_schema/rwlock_instances              | YES     |
...
| memory/performance_schema/prepared_statements_instances | YES     |
| memory/performance_schema/scalable_buffer               | YES     |
+---------------------------------------------------------+---------+
79 rows in set (0.05 sec)

mysql> SELECT NAME, TIMED FROM performance_schema.setup_instruments WHERE sys.ps_is_instrument_default_timed(NAME) <> TIMED;
+------------------------------------------------------+-------+
| NAME                                                 | TIMED |
+------------------------------------------------------+-------+
| stage/sql/copy to tmp table                          | YES   |
| stage/innodb/alter table (end)                       | YES   |
| stage/innodb/alter table (flush)                     | YES   |
| stage/innodb/alter table (insert)                    | YES   |
| stage/innodb/alter table (log apply index)           | YES   |
| stage/innodb/alter table (log apply table)           | YES   |
| stage/innodb/alter table (merge sort)                | YES   |
| stage/innodb/alter table (read PK and internal sort) | YES   |
| stage/innodb/buffer pool load                        | YES   |
+------------------------------------------------------+-------+
9 rows in set (0.07 sec)

Suggested fix:
Update the functions
[5 Oct 2015 18:48] Paul DuBois
Noted in 5.7.9, 5.8.0 changelogs.

The sys schema ps_is_instrument_default_enabled() and
ps_is_instrument_default_timed() stored functions returned incorrect
results in some cases.