Uploaded image for project: 'Percona Server'
  1. Percona Server
  2. PS-4570

Flush status; adds twice to global values

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Done
    • Priority: Low
    • Resolution: Fixed
    • Affects Version/s: 5.7.22-22
    • Fix Version/s: 5.7.23-23
    • Component/s: None
    • Labels:

      Description

      A statement executed counts twice when adding to global status if "flush status" is executed from a different session.
      The count is updated once when the statement is executed excuted, and once again when "flush status;" is executed.
      This has been tested for parameters: 'slow_queries', 'questions', 'bytes_received', 'Bytes_sent'

       

      How to reproduce:

      --pre requisites:
      -- have long_query_time = 2
      
      mysql [localhost] {msandbox} ((none)) > show global status like 'Slow_queries';
      +---------------+-------+
      | Variable_name | Value |
      +---------------+-------+
      | Slow_queries | 0 |
      +---------------+-------+
      1 row in set (0.00 sec)
      
      -- Run a query to increase 'slow_queries' counter
      mysql [localhost] {msandbox} ((none)) > select sleep (2);
      +-----------+
      | sleep (2) |
      +-----------+
      | 0 |
      +-----------+
      1 row in set (2.00 sec)
      
      -- check slow_queries have increased
      mysql [localhost] {msandbox} ((none)) > show global status like 'Slow_queries';
      +---------------+-------+
      | Variable_name | Value |
      +---------------+-------+
      | Slow_queries | 1 |
      +---------------+-------+
      1 row in set (0.00 sec)
      
      mysql [localhost] {msandbox} ((none)) > exit
      Bye
      carlos.tutte@bm-support01:~/sandboxes/5.7.22$ ./use 
      Welcome to the MySQL monitor. Commands end with ; or \g.
      Your MySQL connection id is 5
      Server version: 5.7.22-22 Percona Server (GPL), Release 22, Revision f62d93c
      
      Copyright (c) 2009-2018 Percona LLC and/or its affiliates
      Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
      
      Oracle is a registered trademark of Oracle Corporation and/or its
      affiliates. Other names may be trademarks of their respective
      owners.
      
      Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
      
      mysql [localhost] {msandbox} ((none)) > show global status like 'Slow_queries';
      +---------------+-------+
      | Variable_name | Value |
      +---------------+-------+
      | Slow_queries | 1 |
      +---------------+-------+
      1 row in set (0.00 sec)
      
      mysql [localhost] {msandbox} ((none)) > select * from performance_schema.status_by_user where variable_name in ('Slow_queries');
      +----------+---------------+----------------+
      | USER | VARIABLE_NAME | VARIABLE_VALUE |
      +----------+---------------+----------------+
      | NULL | Slow_queries | 0 |
      | msandbox | Slow_queries | 1 |
      +----------+---------------+----------------+
      2 rows in set (0.00 sec)
      
      mysql [localhost] {msandbox} ((none)) > flush status;
      Query OK, 0 rows affected (0.00 sec)
      
      mysql [localhost] {msandbox} ((none)) > select * from performance_schema.status_by_user where variable_name in ('Slow_queries');
      +----------+---------------+----------------+
      | USER | VARIABLE_NAME | VARIABLE_VALUE |
      +----------+---------------+----------------+
      | NULL | Slow_queries | 0 |
      | msandbox | Slow_queries | 0 |
      +----------+---------------+----------------+
      2 rows in set (0.00 sec)
      
      -- slow_queries have increased twice
      mysql [localhost] {msandbox} ((none)) > show global status like 'Slow_queries';
      +---------------+-------+
      | Variable_name | Value |
      +---------------+-------+
      | Slow_queries | 2 |
      +---------------+-------+
      1 row in set (0.00 sec)

       

      Workaround: If enabling `show_compatibility_56`, the bug does not trigger but performance_schema is disabled.

      Suggested fix: Check under which conditions "flush status" should add to global variables, as status variables are already added to global after every statement execution.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                yura.sorokin Yura Sorokin
                Reporter:
                carlos.tutte Carlos Tutte
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 4 days, 6 hours, 43 minutes
                  4d 6h 43m