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

In-place upgrade of views that select from performance_schema is broken

Details

    Description

      In-place upgrade of views that select performance_schema tables are not imported properly from 5.7 to 8.0.

      Instructions
      1. Create view in PS 5.7.36:

      use test;CREATE VIEW v1 AS SELECT gs1.* FROM performance_schema.global_status gs1 JOIN performance_schema.global_status gs2 ON gs1.VARIABLE_NAME = gs2.VARIABLE_NAME;

      2.  Copy 5.7.36 datadir in 8.0.27 and start it up. The error log will show issues with the in-place upgrade.

      2022-03-24T12:52:40.441672Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended. 2022-03-24T12:52:44.952040Z 2 [Warning] [MY-010200] [Server] Resolving dependency for the view 'test.v1' failed. View is no more valid to use 2022-03-24T12:52:45.677799Z 2 [System] [MY-011003] [Server] Finished populating Data Dictionary tables with data.

      3. It may seem that the view is working:
       

      mysql> SELECT * FROM test.v1 LIMIT 3; 
      +-----------------------+----------------+ | VARIABLE_NAME | VARIABLE_VALUE | +-----------------------+----------------+ | Aborted_clients | 0 | | Aborted_connects | 0 | | Acl_cache_items_count | 0 | +-----------------------+----------------+ 3 rows in set (0.00 sec) 
      
      ~/opt/percona/8.0.27/bin/mysql --port=8027 -e 'SHOW CREATE VIEW test.v1' +------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------+----------------------+ | View | Create View | character_set_client | collation_connection | +------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------+----------------------+ | v1 | CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `test`.`v1` AS select `gs1`.`VARIABLE_NAME` AS `VARIABLE_NAME`,`gs1`.`VARIABLE_VALUE` AS `VARIABLE_VALUE` from (`performance_schema`.`global_status` `gs1` join `performance_schema`.`global_status` `gs2` on((`gs1`.`VARIABLE_NAME` = `gs2`.`VARIABLE_NAME`))) | utf8 | utf8_general_ci | +------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

       
       4. Try a mysqldump and you will get this error:
       

      ~/opt/percona/8.0.27/bin/mysqldump --port=8027 test -- MySQL dump 10.13 Distrib 8.0.27-18, for Linux (x86_64) -- -- Host: 127.0.0.1 Database: test -- ------------------------------------------------------ -- Server version 8.0.27-18 
       /*!40101 SET @[email protected]@CHARACTER_SET_CLIENT */; /*!40101 SET @[email protected]@CHARACTER_SET_RESULTS */; /*!40101 SET @[email protected]@COLLATION_CONNECTION */; /*!50503 SET NAMES utf8mb4 */; /*!40103 SET @[email protected]@TIME_ZONE */; /*!40103 SET TIME_ZONE='+00:00' */; /*!40014 SET @[email protected]@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @[email protected]@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OL[email protected]@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40111 SET @[email protected]@SQL_NOTES, SQL_NOTES=0 */; /*!50717 SELECT COUNT(*) INTO @rocksdb_has_p_s_session_variables FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'performance_schema' AND TABLE_NAME = 'session_variables' */; /*!50717 SET @rocksdb_get_is_supported = IF (@rocksdb_has_p_s_session_variables, 'SELECT COUNT(*) INTO @rocksdb_is_supported FROM performance_schema.session_variables WHERE VARIABLE_NAME=\'rocksdb_bulk_load\'', 'SELECT 0') */; /*!50717 PREPARE s FROM @rocksdb_get_is_supported */; /*!50717 EXECUTE s */; /*!50717 DEALLOCATE PREPARE s */; /*!50717 SET @rocksdb_enable_bulk_load = IF (@rocksdb_is_supported, 'SET SESSION rocksdb_bulk_load = 1', 'SET @rocksdb_dummy_bulk_load = 0') */; /*!50717 PREPARE s FROM @rocksdb_enable_bulk_load */; /*!50717 EXECUTE s */; /*!50717 DEALLOCATE PREPARE s */; 
       -- -- Temporary view structure for view `v1` -- 
       DROP TABLE IF EXISTS `v1`; mysqldump: Couldn't execute 'SHOW FIELDS FROM `v1`': View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them (1356)

       
      5. If you drop and recreate the view in 8.0.27, the issue is gone:
       

      mysql> DROP VIEW v1; Query OK, 0 rows affected (0.02 sec) 
      mysql> CREATE VIEW v1 AS SELECT gs1.* FROM performance_schema.global_status gs1 JOIN performance_schema.global_status gs2 ON gs1.VARIABLE_NAME = gs2.VARIABLE_NAME; Query OK, 0 rows affected (0.02 sec) 
      mysql> SHOW FIELDS FROM test.v1; 
      +----------------+---------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +----------------+---------------+------+-----+---------+-------+ | VARIABLE_NAME | varchar(64) | NO | | NULL | | | VARIABLE_VALUE | varchar(1024) | YES | | NULL | | +----------------+---------------+------+-----+---------+-------+ 2 rows in set (0.00 sec)   

      Something went wrong during the in-place upgrade of this view.{{}}

      Attachments

        Activity

          People

            amonar Anton Matvienko
            jaime.sicam@percona.com Jaime Sicam
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Smart Checklist