Bug #77846 Sys Schema Incompatible with fix for bug 75156; TIMER_END / TIMER_WAIT NOT NULL
Submitted: 28 Jul 2015 0:47 Modified: 5 Oct 2015 19:06
Reporter: Jesper wisborg Krogh Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: SYS Schema Severity:S2 (Serious)
Version:5.7.8 OS:Any
Assigned to: CPU Architecture:Any

[28 Jul 2015 0:47] Jesper wisborg Krogh
Description:
MySQL 5.6.26 and 5.7.8 has the following incompatible change:

    Current-event timing now provides more information. Previously, while a wait, stage, or statement event was executing, the respective tables displayed the event with TIMER_START populated, but with TIMER_END and TIMER_WAIT as NULL:

    events_waits_current
    events_stages_current
    events_statements_current

    To make it possible to determine how how long a not-yet-completed event has been running, the timer columns now are set as follows:

        TIMER_START is populated (unchanged from previous behavior)

        TIMER_END is populated with the current timer value

        TIMER_WAIT is populated with the time elapsed so far (TIMER_END − TIMER_START)

    To find events that have not yet completed (that is, have no END_EVENT_ID) and have taken longer than N picoseconds thus far, monitoring applications can use this expression in queries:

    WHERE END_EVENT_ID IS NULL AND TIMER_WAIT > N

    (Bug #75156, Bug #20889406)

However Sys Schema version 1.4.0 assumes TIMER_WAIT is null for queries that have not yet completed.

How to repeat:
See the various processlist view definitions, e.g.

views/p_s/processlist_57.sql:

...
       IF(esc.timer_wait IS NOT NULL,
          sys.format_statement(esc.sql_text),
          NULL) AS last_statement,
       IF(esc.timer_wait IS NOT NULL,
          sys.format_time(esc.timer_wait),
          NULL) AS last_statement_latency,
       ewc.event_name AS last_wait,
       IF(ewc.timer_wait IS NULL AND ewc.event_name IS NOT NULL,
          'Still Waiting',
          sys.format_time(ewc.timer_wait)) last_wait_latency,
...

Suggested fix:
Change the processlist views to use IF(esc.end_event_id IS NOT NULL, ...) instead.
[5 Oct 2015 19:06] Paul DuBois
Noted in 5.7.9 changelog.

Handing of event-timing information in the sys schema was updated to
handle changes to Performance Schema event-timing columns in MySQL
5.7.8.