Bug #75616 Cannot initialize or use raw device as InnoDB File
Submitted: 24 Jan 2015 6:14 Modified: 24 Jun 2015 4:57
Reporter: joshua ruehlig Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S1 (Critical)
Version:5.6.22, 5.6.23 OS:FreeBSD
Assigned to: CPU Architecture:Any
Tags: innodb, raw device, regression

[24 Jan 2015 6:14] joshua ruehlig
Description:
Creating a new InnoDB data file, or using an existing InnoDB data file, with a raw device isn't working with mysql56-server-5.6.22.

##ERROR##
[ERROR] InnoDB: '/dev/da1' not a regular file.
####

This works as expected with mysql55-server.

Apparently a similar issue was fixed (for linux) in version 5.6.16 (at least for linux), but maybe the patch to os_file_get_status doesn't work for FreeBSD.
http://bugs.mysql.com/bug.php?id=69424

How to repeat:
innodb_data_home_dir=
innodb_data_file_path = /dev/da1:8G(new)raw
[27 Jan 2015 13:54] Umesh Shastry
Hello joshua ruehlig,

Thank you for the report.
Observed similar behavior on OL6 with MySQL 5.6.23

Thanks,
Umesh
[27 Jan 2015 13:55] Umesh Shastry
// 5.6.23

//
[root@cluster-repo server]# ls -lR /dev/raw*
/dev/raw:
total 0
crw-rw---- 1 root disk 162, 1 Jan 29 19:56 raw1
crw-rw---- 1 root disk 162, 0 Jan 29 19:25 rawctl
[root@cluster-repo server]# raw -qa
/dev/raw/raw1:  bound to major 202, minor 49
[root@cluster-repo server]#

// Build used, start up etc

[root@cluster-repo mysql-5.6.23-linux-glibc2.5-x86_64]# more docs/INFO_SRC
commit: 19ff9770da1307a8b44be40beaa456c4d1149c2a
date: 2015-01-19 14:26:20 +0100
build-date: 2015-01-19 14:38:00 +0100
short: 19ff977
branch: mysql-5.6.23-release

MySQL source 5.6.23

[root@cluster-repo mysql-5.6.23-linux-glibc2.5-x86_64]# scripts/mysql_install_db --defaults-file=./my.cnf --user=root
[root@cluster-repo mysql-5.6.23-linux-glibc2.5-x86_64]# bin/mysqld --defaults-file=./my.cnf --user=root &

// Snippet from error log

2015-01-29 20:54:00 2046 [Note] Plugin 'FEDERATED' is disabled.
2015-01-29 20:54:00 2046 [Note] InnoDB: Using atomics to ref count buffer pool pages
2015-01-29 20:54:00 2046 [Note] InnoDB: The InnoDB memory heap is disabled
2015-01-29 20:54:00 2046 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2015-01-29 20:54:00 2046 [Note] InnoDB: Memory barrier is not used
2015-01-29 20:54:00 2046 [Note] InnoDB: Compressed tables use zlib 1.2.3
2015-01-29 20:54:00 2046 [Note] InnoDB: Using Linux native AIO
2015-01-29 20:54:00 2046 [Note] InnoDB: Not using CPU crc32 instructions
2015-01-29 20:54:00 2046 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2015-01-29 20:54:00 2046 [Note] InnoDB: Completed initialization of buffer pool
2015-01-29 20:54:00 2046 [ERROR] InnoDB: '/dev/raw/raw1' not a regular file.
2015-01-29 20:54:00 2046 [ERROR] InnoDB: The system tablespace must be writable!
2015-01-29 20:54:00 2046 [ERROR] Plugin 'InnoDB' init function returned error.
2015-01-29 20:54:00 2046 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2015-01-29 20:54:00 2046 [ERROR] Unknown/unsupported storage engine: InnoDB
2015-01-29 20:54:00 2046 [ERROR] Aborting
[27 Jan 2015 13:56] Umesh Shastry
// conf used

[root@cluster-repo mysql-5.6.23-linux-glibc2.5-x86_64]# more my.cnf
[mysqld]
pid-file = /data/ushastry/server/mysql-5.6.23-linux-glibc2.5-x86_64/run/master.pid
socket = /data/ushastry/server/mysql-5.6.23-linux-glibc2.5-x86_64/run/master.sock
log-error=/data/ushastry/server/mysql-5.6.23-linux-glibc2.5-x86_64/log/master.log
slow_query_log_file=/data/ushastry/server/mysql-5.6.23-linux-glibc2.5-x86_64/log/slow.log
general_log_file=/data/ushastry/server/mysql-5.6.23-linux-glibc2.5-x86_64/log/general.log

port = 15000
server-id = 1
basedir = /data/ushastry/server/mysql-5.6.23-linux-glibc2.5-x86_64
datadir = /data/ushastry/server/mysql-5.6.23-linux-glibc2.5-x86_64/data
tmpdir = /tmp

innodb_data_home_dir=
innodb_data_file_path=/dev/raw/raw1:1Gnewraw
[27 Jan 2015 13:58] Umesh Shastry
Also, Bug #75646
[3 Feb 2015 3:49] joshua ruehlig
I found the cause of the issue. FreeBSD doesn't present disks as block devices but instead as character devices.
https://www.freebsd.org/doc/en/books/arch-handbook/driverbasics-block.html

I "case S_IFCHR:" should be added directly before or after "case S_IFBLK:" here.
http://bazaar.launchpad.net/~mysql/mysql-server/5.6/view/head:/storage/innobase/os/os0file...
[3 Feb 2015 3:53] joshua ruehlig
What do I need to do to get this fix merged in?
Thanks
[10 Feb 2015 6:51] joshua ruehlig
I have submitted the likely solution to this (adding the single line to also look for a char device).
Is there any way I can have someone confirm my solution works?
[24 Jun 2015 4:08] Laurynas Biveinis
Has this been fixed in 5.6.25?

commit aee6bc8ed15e14fb2a532cd0ebffa0ec161c0e77
Author: Debarun Banerjee <debarun.banerjee@oracle.com>
Date:   Mon Mar 9 14:37:49 2015 +0530

    BUG#20422712 - CANNOT INITIALIZE OR USE RAW DEVICE AS INNODB FILE
    
    Problem :
    ---------
    Creating a new InnoDB data file, or using an existing InnoDB data file,
    with a raw device isn't working for mysql-5.6.
    
    From 5.6 onwards, a few changes caused conflict with the feature.
      1.InnoDB system tablespace is created during Initialization.
      2.mysqld is invoked multiple times with [newraw] option and SYS
        tablespace gets overwritten for newraw option.
      3.Many tables are created in mysql DB along with DB initialization
        and we throw [MODIFICATIONS_NOT_ALLOWED_MSG_RAW_PARTITION].
      4.FreeBSD dropped support for block disk devices and raw/newraw
        option breaks as the handling is missing for character device.
    
    Solution :
    ----------
      1. Use --innodb_data_file_path with mysql_install_db.
      2. Map character and block device to OS_FILE_TYPE_FILE.
      3. For NEWRAW option don't overwrite if systablespace is valid.
      4. Remove MODIFICATIONS_NOT_ALLOWED_MSG_RAW_PARTITION.
      5. Check --bootstrap option for initializing raw device.
    
    Reviewed-by: Vasil Dimov <vasil.dimov@oracle.com>
    
    RB: 8258

commit 8c486f2bc2fdb1a75214d4061de76f4718cf0a65
Author: Debarun Banerjee <debarun.banerjee@oracle.com>
Date:   Tue Apr 7 17:54:43 2015 +0530

    BUG#20422712 - CANNOT INITIALIZE OR USE RAW DEVICE AS INNODB FILE
    
    Fix warning for label err_exit not used in non-debug mode.
[24 Jun 2015 4:57] joshua ruehlig
Looks like it based on the description of those commits.

FreeBSD is still on 5.6.24 in the repo so whoever tests this would also need to update the port.

I can test this eventually but don't have time to tinker with it at the moment.
[9 Jul 2015 13:10] Laurynas Biveinis
bug 77668
[24 Apr 2018 13:15] Miguel Solorzano
https://bugs.mysql.com/bug.php?id=79446 marked as duplicate of this one.