Bug #57058 SERVER_QUERY_WAS_SLOW not wired up.
Submitted: 28 Sep 2010 9:57 Modified: 6 Jan 2011 15:00
Reporter: Mark Leith Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: General Severity:S3 (Non-critical)
Version:5.5.6 OS:Any
Assigned to: Konstantin Osipov CPU Architecture:Any
Triage: Triaged: D3 (Medium)

[28 Sep 2010 9:57] Mark Leith
Description:
WL#4098 - Add a status flag for slow queries - was added in to 5.5, basically adding a flag in the protocol that will flag when a query runtime exceeds the long_query_time variable. 

The define was added - http://lists.mysql.com/commits/87658 - all connectors are apparently OK with this, and some even now try use the new flag - http://lists.mysql.com/commits/99137 -  but it was not wired up fully, the flag is never set.

How to repeat:
Verified with code inspection. 

Suggested fix:
Set the flag when a statement runs for longer than long_query_time.
[19 Oct 2010 19:00] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/121194

3167 Konstantin Osipov	2010-10-19
      Implement a fix for Bug#57058 -- send SERVER_QUERY_WAS_SLOW over
      network when a query was slow.
      
      When a query is slow, sent a special flag to the client
      indicating this fact.
      
      Add a test case.
     @ include/mysql_com.h
        Clear SERVER_QUERY_WAS_SLOW at end of each statement.
        Since this patch removes the technique when 
        thd->server_status is modified briefly only to
        execute my_eof(), reset more server status
        bit that may remain in the status from
        execution of the previous statement.
     @ sql/protocol.cc
        Always use thd->server_status to 
        in net_* functions to send the latest
        status to the client.
     @ sql/sp_head.cc
        Calculate if a query was slow before
        sending EOF packet.
     @ sql/sql_cursor.cc
        Remove juggling with thd->server_status.
        The extra status bits are reset at
        start of the next statement.
     @ sql/sql_db.cc
        Remove juggling with thd->server_status.
        The extra status bits are reset at
        start of the next statement.
     @ sql/sql_error.cc
        Remove m_server_status member,
        it's not really part of the Diagnostics_area.
     @ sql/sql_error.h
        Remove server_status member, it's
        not part of the Diagnostics_area.
        The associated hack is removed as well.
     @ sql/sql_parse.cc
        Do not calculate if a query was
        slow twice. Use a status flag in thd->server_status.
     @ tests/mysql_client_test.c
        Add a test case for Bug#57058.
        Check that the status is present
        at the client, when sent.
[12 Nov 2010 12:57] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/123721

3181 Konstantin Osipov	2010-11-12
      Implement a fix for Bug#57058 -- send SERVER_QUERY_WAS_SLOW over
      network when a query was slow.
      
      When a query is slow, sent a special flag to the client
      indicating this fact.
      
      Add a test case.
      Implement review comments.
     @ include/mysql_com.h
        Clear SERVER_QUERY_WAS_SLOW at end of each statement.
        Since this patch removes the technique when 
        thd->server_status is modified briefly only to
        execute my_eof(), reset more server status
        bit that may remain in the status from
        execution of the previous statement.
     @ sql/protocol.cc
        Always use thd->server_status to 
        in net_* functions to send the latest
        status to the client.
     @ sql/sp_head.cc
        Calculate if a query was slow before
        sending EOF packet.
     @ sql/sql_cursor.cc
        Remove juggling with thd->server_status.
        The extra status bits are reset at
        start of the next statement.
     @ sql/sql_db.cc
        Remove juggling with thd->server_status.
        The extra status bits are reset at
        start of the next statement.
     @ sql/sql_error.cc
        Remove m_server_status member,
        it's not really part of the Diagnostics_area.
     @ sql/sql_error.h
        Remove server_status member, it's
        not part of the Diagnostics_area.
        The associated hack is removed as well.
     @ sql/sql_parse.cc
        Do not calculate if a query was
        slow twice. Use a status flag in thd->server_status.
     @ tests/mysql_client_test.c
        Add a test case for Bug#57058.
        Check that the status is present
        at the client, when sent.
[12 Nov 2010 13:03] Konstantin Osipov
Queued into 5.5-runtime.
[12 Nov 2010 14:21] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/123735

3183 Konstantin Osipov	2010-11-12
      Fix a compilation failure of non-debug build introduced 
      by the patch for Bug#57058.
     @ sql/sql_error.cc
        Delete assignment of a removed class member.
[16 Nov 2010 21:57] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/124091

3187 Davi Arnaut	2010-11-16
      Bug#57058: SERVER_QUERY_WAS_SLOW not wired up.
      
      Finalize the server flags after any kind of command is executed.
      To avoid updating the flag multiple times, reorganize code so that
      its invoked only once for each command.
     @ sql/log_event.cc
        Explicit update after the query is executed in the slave.
     @ sql/sql_parse.cc
        Reorganize so that the status flag is updated for any command and
        not done twice for a query command.
[5 Dec 2010 12:40] Bugs System
Pushed into mysql-trunk 5.6.1 (revid:alexander.nozdrin@oracle.com-20101205122447-6x94l4fmslpbttxj) (version source revid:alexander.nozdrin@oracle.com-20101205122447-6x94l4fmslpbttxj) (merge vers: 5.6.1) (pib:23)
[16 Dec 2010 22:34] Bugs System
Pushed into mysql-5.5 5.5.9 (revid:jonathan.perkin@oracle.com-20101216101358-fyzr1epq95a3yett) (version source revid:jonathan.perkin@oracle.com-20101216101358-fyzr1epq95a3yett) (merge vers: 5.5.9) (pib:24)
[6 Jan 2011 15:00] Paul Dubois
Noted in 5.5.8 changelog.

The client/server protocol now includes a SERVER_QUERY_WAS_SLOW flag
to indicate when a query is slow; that is, when query execution 
exceeds the value or the long_query_time system variable.
[6 Jan 2011 15:00] Paul Dubois
Last line should be:

exceeds the value *of* the long_query_time system variable.