Bug #83281 SDI file losts after altering database
Submitted: 6 Oct 2016 9:11 Modified: 26 Oct 2016 14:08
Reporter: zhai weixiang (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: DDL Severity:S3 (Non-critical)
Version:8.0.0 OS:Any
Assigned to: CPU Architecture:Any

[6 Oct 2016 9:11] zhai weixiang
Description:
The sdi file losts after executing `alter database`

How to repeat:
mysql> create database db1;
Query OK, 1 row affected (8.09 sec)

$ls -lh db1*
-rw-r----- 1 yinfeng.zwx users  210 Oct  6 17:04 db1_22.SDI

mysql> alter database db1 default charset gbk;

the serial number of new sdi file is not increased according to gdb:

Breakpoint 3, (anonymous namespace)::write_sdi_file (fname=".//db1_22.SDI", sdi=
    "{\n    \"sdi_version\": 1,\n    \"dd_version\": 1,\n    \"dd_object_type\": \"Schema\",\n    \"dd_object\": {\n        \"name\": \"db1\",\n        \"default_collation_id\": 28,\n        \"created\": 0,\n        \"last_altered\":"...)
    at /u01/yf_57/mysql-server/sql/dd/impl/sdi_file.cc:45
45        File sdif= mysql_file_create(key_file_sdi, fname.c_str(), CREATE_MODE,

And then the file is unlinked after being updated. 

Breakpoint 5, 0x00000030004d9950 in unlink () from /lib64/libc.so.6
(gdb) bt
#0  0x00000030004d9950 in unlink () from /lib64/libc.so.6
#1  0x00000000030d69fd in my_delete (name=0x2b750c045168 ".//db1_22.SDI", MyFlags=8) at /u01/yf_57/mysql-server/mysys/my_delete.cc:32
#2  0x0000000001c26d5c in inline_mysql_file_delete (key=31, src_file=0x418e988 "/u01/yf_57/mysql-server/sql/dd/impl/sdi_file.cc", src_line=157, name=0x2b750c045168 ".//db1_22.SDI", flags=8)
    at /u01/yf_57/mysql-server/include/mysql/psi/mysql_file.h:1304
#3  0x0000000001c27f80 in dd::sdi_file::remove (fname=".//db1_22.SDI") at /u01/yf_57/mysql-server/sql/dd/impl/sdi_file.cc:156

Check the directory:

$ls -lh db1*
total 0

Suggested fix:
Increase the serial number of sdi file when the database is altered.
[6 Oct 2016 9:33] MySQL Verification Team
Hello Zhai,

Thank you for the report.

Thanks,
Umesh
[26 Oct 2016 14:08] Paul DuBois
Posted by developer:
 
Fixed in 8.0.1.

Technically, this affects a released version (8.0.0), but we have not documented .sdi files beyond just barely mentioning them, so: No changelog entry needed.