Skip to content

Commit bc7eacd

Browse files
Bug#31989290: SYSTEM TABLES UPGRADED FROM 5.7 DIFFER FROM SYSTEM TABLES CREATED IN 8.0
PROBLEM: -------- If we take a freshly initialized data directory from a MySQL 5.7 instance and upgrade it to 8.0, the definition of some system tables (mysql schema) differs from the definition of the same tables, in a freshly initialized datadir. of an 8.0 instance. FIX: ---- The appropriate ALTER TABLE statements are added/modified in mysql_system_tables_fix.sql to make the upgraded system table definition match the definitions in mysql_system_tables.sql Additionally, an upgrade test is added to catch any new inconsistencies introduced in the future to system tables present in the mysql tablespace Note: The diff in the file mysql-test/std_data/dd/sdi/upgrade/mysql.json is the ibd2sdi output generated by re-recording main.dd_upgrade_test Additionally, the deprecated 'binary' keyword is removed from mysql_system_tables_fix.sql in the cases where it was not present in mysql_system_tables.sql (though this does not affect the internal metadata) Change-Id: I40c8220a8b70c88e62c28812b4950af25b316665
1 parent d418144 commit bc7eacd

File tree

5 files changed

+4246
-3978
lines changed

5 files changed

+4246
-3978
lines changed

mysql-test/r/upgrade_system_tables.result

+60
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,63 @@
1+
2+
# Dump system table information for the newly initialized data directory
3+
# Adding debug point 'skip_dd_table_access_check' to @@GLOBAL.debug
4+
5+
# Dump all tables in newly initialized mysql schema
6+
include/write_result_to_file.inc [connection=default statement=SELECT t.* FROM mysql.tables t JOIN mysql.schemata s JOIN mysql.tablespaces ts WHERE t.schema_id = s.id AND t.tablespace_id = ts.id AND s.name = "mysql" AND ts.name = "mysql" ORDER BY t.name]
7+
include/filter_file.inc
8+
9+
# Dump all columns in newly initialized mysql schema
10+
include/write_result_to_file.inc [connection=default statement=SELECT t.name, c.* FROM mysql.columns c JOIN mysql.tables t JOIN mysql.schemata s JOIN mysql.tablespaces ts WHERE c.table_id = t.id AND t.schema_id = s.id AND t.tablespace_id = ts.id AND s.name = "mysql" AND ts.name = "mysql" AND t.name != "ndb_binlog_index" ORDER BY t.name, c.name]
11+
include/filter_file.inc
12+
# Removing debug point 'skip_dd_table_access_check' from @@GLOBAL.debug
13+
14+
# Upgrade a data directory from 5.7
15+
16+
# Copy the 5.7 data zip file to working directory and check it exists.
17+
# Unzip 5.7 data directory.
18+
# Set data directory and log file
19+
# Restart server to trigger upgrade.
20+
# restart: --datadir=MYSQLD_DATADIR1 --log-error=MYSQLD_LOG
21+
22+
# Dump system table information for the upgraded data directory
23+
# Adding debug point 'skip_dd_table_access_check' to @@GLOBAL.debug
24+
25+
# Dump all tables in upgraded mysql schema
26+
include/write_result_to_file.inc [connection=default statement=SELECT t.* FROM mysql.tables t JOIN mysql.schemata s JOIN mysql.tablespaces ts WHERE t.schema_id = s.id AND t.tablespace_id = ts.id AND s.name = "mysql" AND ts.name = "mysql" ORDER BY t.name]
27+
include/filter_file.inc
28+
29+
# Dump all columns in upgraded mysql schema
30+
include/write_result_to_file.inc [connection=default statement=SELECT t.name, c.* FROM mysql.columns c JOIN mysql.tables t JOIN mysql.schemata s JOIN mysql.tablespaces ts WHERE c.table_id = t.id AND t.schema_id = s.id AND t.tablespace_id = ts.id AND s.name = "mysql" AND ts.name = "mysql" AND t.name != "ndb_binlog_index" ORDER BY t.name, c.name]
31+
include/filter_file.inc
32+
# Removing debug point 'skip_dd_table_access_check' from @@GLOBAL.debug
33+
34+
########################################################################
35+
# NOTE: If this test fails, there is a possible inconsistency introduced
36+
# in the system table/column definition of an upgraded mysql
37+
# tablespace as compared to that of a newly initialized one.
38+
#
39+
# There are 2 possibilities:
40+
#
41+
# a) If the failure shows a new inconsistency in the table/column
42+
# properties, add the appropriate ALTER TABLE statements to
43+
# scripts/mysql_system_tables_fix.sql
44+
# to ensure that the metadata of the upgraded table/column is the
45+
# same as that of the newly created one.
46+
#
47+
# b) If the inconsistency is unavoidable, modify the regular expressions
48+
# above, re-record and update documentation if required.
49+
#
50+
########################################################################
51+
52+
# Compare fresh and upgraded tables
53+
20c20
54+
< # # gtid_executed BASE TABLE InnoDB # Dynamic 255 Visible avg_row_length=0;encrypt_type=N;explicit_tablespace=1;key_block_size=0;keys_disabled=0;pack_record=1;row_type=2;stats_auto_recalc=0;stats_sample_pages=0; # # 1 NULL NULL NULL NULL NULL NULL NULL NULL # # NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL # NULL NULL
55+
---
56+
> # # gtid_executed BASE TABLE InnoDB # Dynamic 255 Visible avg_row_length=0;encrypt_type=N;explicit_tablespace=1;key_block_size=0;keys_disabled=0;pack_record=1;row_type=2;stats_auto_recalc=0;stats_persistent=0;stats_sample_pages=0; # # 1 NULL NULL NULL NULL NULL NULL NULL NULL # # NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL # NULL NULL
57+
58+
# Compare fresh and upgraded columns
59+
60+
# Cleanup.
161
# Copy the 5.7 data zip file to working directory and check it exists.
262
# Unzip 5.7 data directory.
363
# Set data directory and log file

0 commit comments

Comments
 (0)