Bug #85922 if performance_schema=OFF, cannot access variables
Submitted: 12 Apr 2017 22:51 Modified: 13 Apr 2017 15:07
Reporter: Matthew Boehm Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Performance Schema Severity:S1 (Critical)
Version:5.7 OS:Any
Assigned to: CPU Architecture:Any
Tags: global variables, performance_schema, variables

[12 Apr 2017 22:51] Matthew Boehm
Description:
If the performance_schema is turned off, unable to access global and session variables.

node3 mysql> select @@performance_schema;
+----------------------+
| @@performance_schema |
+----------------------+
|                    0 |
+----------------------+
1 row in set (0.00 sec)

node3 mysql> show global variables like 'general%';
ERROR 1682 (HY000): Native table 'performance_schema'.'global_variables' has the wrong structure

=========

node3 mysql> select @@performance_schema;
+----------------------+
| @@performance_schema |
+----------------------+
|                    1 |
+----------------------+
1 row in set (0.00 sec)

node3 mysql> show global variables like 'general%';
+------------------+--------------------------+
| Variable_name    | Value                    |
+------------------+--------------------------+
| general_log      | OFF                      |
| general_log_file | /var/lib/mysql/node3.log |
+------------------+--------------------------+
2 rows in set (0.00 sec)

How to repeat:
Turn off performance_schema.
Restart MySQL
Attempt to access global variables in any way

Suggested fix:
Keep variables in information_schema
Keep variables available in p_s even if off
Somehow, allow variables to be viewed when p_s is off
[12 Apr 2017 23:26] Matthew Boehm
Changing to S1. This is blocking our monitoring.
[13 Apr 2017 0:16] Matthew Boehm
Reasons for turning p_s off:
 https://bugs.mysql.com/bug.php?id=85910
[13 Apr 2017 2:58] MySQL Verification Team
C:\dbs>5.7\bin\mysql -uroot -p
Enter password: **********
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.18-log MySQL Community Server (GPL)

Copyright (c) 2000, 2017, 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>  select @@performance_schema;
+----------------------+
| @@performance_schema |
+----------------------+
|                    0 |
+----------------------+
1 row in set (0.00 sec)

mysql> show global variables like 'general%';
+------------------+-----------+
| Variable_name    | Value     |
+------------------+-----------+
| general_log      | OFF       |
| general_log_file | TIKAL.log |
+------------------+-----------+
2 rows in set (0.03 sec)

mysql> show global variables like '%sql%';
+----------------------------------------+----------------------------------------------------------------+
| Variable_name                          | Value                                                          |
+----------------------------------------+----------------------------------------------------------------+
| mysql_native_password_proxy_users      | OFF                                                            |
| performance_schema_max_sql_text_length | 0                                                              |
| slave_sql_verify_checksum              | ON                                                             |
| sql_auto_is_null                       | OFF                                                            |
| sql_big_selects                        | ON                                                             |
| sql_buffer_result                      | OFF                                                            |
| sql_log_off                            | OFF                                                            |
| sql_mode                               | STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION |
| sql_notes                              | ON                                                             |
| sql_quote_show_create                  | ON                                                             |
| sql_safe_updates                       | OFF                                                            |
| sql_select_limit                       | 18446744073709551615                                           |
| sql_slave_skip_counter                 | 0                                                              |
| sql_warnings                           | OFF                                                            |
+----------------------------------------+----------------------------------------------------------------+
14 rows in set (0.00 sec)
[13 Apr 2017 3:12] Matthew Boehm
In which version was this fixed? I'm on 5.7.17 and the issue exists.
[13 Apr 2017 3:15] MySQL Verification Team
I tested with lasted released version 5.7.18:

C:\dbs>5.7\bin\mysql -uroot -p
Enter password: **********
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.18-log MySQL Community Server (GPL)

https://dev.mysql.com/downloads/mysql/
[13 Apr 2017 9:23] MySQL Verification Team
I don't see any issue in 5.7.17 or in GA 5.7.18.

## 5.7.17

[umshastr@hod03]/export/umesh/server/binaries/GABuilds/mysql-advanced-5.7.17: bin/mysql -uroot
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.17-enterprise-commercial-advanced MySQL Enterprise Server - Advanced Edition (Commercial)

Copyright (c) 2000, 2016, 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.

root@localhost [(none)]> select @@performance_schema;
+----------------------+
| @@performance_schema |
+----------------------+
|                    0 |
+----------------------+
1 row in set (0.00 sec)

root@localhost [(none)]> show global variables like 'general%';
+------------------+------------------------------------------------------------------------------+
| Variable_name    | Value                                                                        |
+------------------+------------------------------------------------------------------------------+
| general_log      | OFF                                                                          |
| general_log_file | /export/umesh/server/binaries/GABuilds/mysql-advanced-5.7.17/85922/hod03.log |
+------------------+------------------------------------------------------------------------------+
2 rows in set (0.00 sec)

-- 5.7.18

[umshastr@hod03]/export/umesh/server/binaries/GABuilds/mysql-5.7.18: bin/mysql -uroot
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.18 MySQL Community Server (GPL)

Copyright (c) 2000, 2017, 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.

root@localhost [(none)]> select @@performance_schema;
+----------------------+
| @@performance_schema |
+----------------------+
|                    0 |
+----------------------+
1 row in set (0.00 sec)

root@localhost [(none)]> show global variables like 'general%';
+------------------+---------------------------------------------------------------------+
| Variable_name    | Value                                                               |
+------------------+---------------------------------------------------------------------+
| general_log      | OFF                                                                 |
| general_log_file | /export/umesh/server/binaries/GABuilds/mysql-5.7.18/85922/hod03.log |
+------------------+---------------------------------------------------------------------+
2 rows in set (0.00 sec)

Looking at your output, it seems me that you have upgraded the instance but didn't run mysql_upgrade? Please could you confirm if you are still having the issue after running mysql_upgrade?

node3 mysql> show global variables like 'general%';
ERROR 1682 (HY000): Native table 'performance_schema'.'global_variables' has the wrong structure
[13 Apr 2017 15:07] Matthew Boehm
I'm unable to reproduce this in my environment. Will continue to investigate and re-open if necessary.