Bug #98091 InnoDB does not initialize raw disk partitions
Submitted: 29 Dec 2019 15:01 Modified: 9 Feb 10:08
Reporter: Saverio Miroddi Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S3 (Non-critical)
Version:8.0.18, 5.7.29, 8.0.19 OS:Linux
Assigned to: CPU Architecture:x86

[29 Dec 2019 15:01] Saverio Miroddi
Description:
I'm following the instructions on https://dev.mysql.com/doc/refman/8.0/en/innodb-system-tablespace.html#innodb-raw-devices, in order to setup the InnoDB system tablespace on a raw disk partition, however, it seems that InnoDB does *not* perform the initialization of the partition.

How to repeat:
# Ensure that only one configuration file is used.
#
root:$ mysqld --help --verbose | grep cnf | head -n 1 | tee /dev/stderr | perl -pe 's/~/$ENV{HOME}/' | xargs ls -l 2> /dev/null
/etc/my.cnf /etc/mysql/my.cnf /usr/local/mysql/etc/my.cnf ~/.my.cnf
-rw-r--r-- 1 root root 808 Dec 29 12:48 /root/.my.cnf

root:$ parted /dev/sda print
# ...details...
Number  Start   End     Size    File system  Name  Flags
# ...other details...
 4      928GB   992GB   64,0GB
 5      992GB   1002GB  10,0GB

# Load the raw module, and bind the raw device.
#
root:$ modprobe raw
root:$ raw /dev/raw/raw1 /dev/sda4
/dev/raw/raw1:  bound to major 8, minor 4

# Verify the following:
#
# > When you use a raw disk partition, ensure that the user ID that runs the MySQL server has read and write privileges for that partition.
#
root:$ dd if=/dev/zero status=progress of=/dev/raw/raw1 bs=1M count=1
1+0 records in
1+0 records out
1048576 bytes (1,0 MB, 1,0 MiB) copied, 0,00247748 s, 423 MB/s

# Initialize the mysql data; now raw partition initialization yet.
#
root:$ cat > /root/.my.cnf << 'CONF'
[mysqld]

datadir                   = /media/disk_b/mysql_data
CONF

root:$ mysqld --user="$(whoami)" --initialize-insecure
2019-12-29T14:37:43.438865Z 0 [System] [MY-013169] [Server] /path/to/mysql-8.0.18-linux-glibc2.12-x86_64/bin/mysqld (mysqld 8.0.18) initializing of server in progress as process 5403
2019-12-29T14:37:45.956817Z 5 [Warning] [MY-010453] [Server] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.

# Now write try to initialize the raw partition.
#
# > When you create a new data file, specify the keyword newraw immediately after the data file size for the innodb_data_file_path option
# > [mysqld]
# > innodb_data_home_dir=
# > innodb_data_file_path=/dev/hdd1:3Gnewraw;/dev/hdd2:2Gnewraw
#
root:$ cat > /root/.my.cnf << 'CONF'
[mysqld]

datadir                   = /media/disk_b/mysql_data
innodb_data_home_dir      =
innodb_data_file_path     = /dev/raw/raw1:2Gnewraw
CONF

root:$ mysqld --user="$(whoami)"
2019-12-29T14:38:53.780113Z 0 [System] [MY-010116] [Server] /path/to/mysql-8.0.18-linux-glibc2.12-x86_64/bin/mysqld (mysqld 8.0.18) starting as process 5470
2019-12-29T14:38:53.804420Z 1 [ERROR] [MY-012224] [InnoDB] Header page consists of zero bytes in datafile: /dev/raw/raw1, Space ID:0, Flags: 0. Please refer to http://dev.mysql.com/doc/refman/8.0/en/innodb-troubleshooting-datadict.html for how to resolve the issue.
2019-12-29T14:38:53.804508Z 1 [ERROR] [MY-012237] [InnoDB] Corrupted page [page id: space=0, page number=0] of datafile '/dev/raw/raw1' could not be found in the doublewrite buffer.
2019-12-29T14:38:53.804576Z 1 [ERROR] [MY-012930] [InnoDB] Plugin initialization aborted with error Data structure corruption.
# ...details...

# Double check that the innodb_data_file_path value is parsed correctly, by feeding a wrong value.
#
root:$ cat > /root/.my.cnf << 'CONF'
[mysqld]

datadir                   = /media/disk_b/mysql_data
innodb_data_home_dir      =
innodb_data_file_path     = /dev/raw/raw1:2Gnewrawx
CONF

root:$ mysqld --user="$(whoami)"
2019-12-29T14:47:59.798128Z 0 [System] [MY-010116] [Server] /path/to/mysql-8.0.18-linux-glibc2.12-x86_64/bin/mysqld (mysqld 8.0.18) starting as process 7315
2019-12-29T14:47:59.803963Z 0 [ERROR] [MY-012261] [InnoDB] File Path Specification: '/dev/raw/raw1:2Gnewrawx' has unrecognized characters after '/dev/raw/raw1:2Gnewraw'
2019-12-29T14:47:59.803991Z 0 [ERROR] [MY-012370] [InnoDB] Unable to parse innodb_data_file_path=/dev/raw/raw1:2Gnewrawx
# ...details...

# Try to initialize both the mysql data and the partition in one pass
#
root:$ rm -rf /media/disk_b/mysql_data
root:$ cat > /root/.my.cnf << 'CONF'
[mysqld]

datadir                   = /media/disk_b/mysql_data
innodb_data_home_dir      =
innodb_data_file_path     = /dev/raw/raw1:2Gnewraw
CONF
root:$ mysqld --user="$(whoami)" --initialize-insecure
2019-12-29T14:57:49.819750Z 0 [System] [MY-013169] [Server] /path/to/mysql-8.0.18-linux-glibc2.12-x86_64/bin/mysqld (mysqld 8.0.18) initializing of server in progress as process 8835
2019-12-29T14:57:49.825484Z 1 [ERROR] [MY-012279] [InnoDB] The innodb_system data file '/dev/raw/raw1' was not found but one of the other data files '/dev/raw/raw1' exists.
2019-12-29T14:57:49.825620Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.
[31 Jan 13:36] Sinisa Milivojevic
You can try several different options:

* omit `datadir` in the configuration
* make sure that a device is owned by mysql
* see if secure initialisation works ......
[7 Feb 5:19] Umesh Shastry
Hello Saverio M,

Thank you for the report and feedback.
Observed this with 5.7.29 and 8.0.19 builds on OL7.

regards,
Umesh
[9 Feb 10:08] Saverio Miroddi
> Thank you for the report and feedback.
> Observed this with 5.7.29 and 8.0.19 builds on OL7.

Thanks Umesh. I'm fairly loaded right now, so it would have taken me a while to perform further tests.

Of course, if there's anything additional I should test, let me know (it seems not, based on the last comment).