Bug #77497 InnoDB Online Ater Table ends in crash on disk full
Submitted: 26 Jun 2015 6:27 Modified: 29 Oct 2015 17:24
Reporter: Daniël van Eeden (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S2 (Serious)
Version:5.6.25, 5.6.26 OS:Any
Assigned to: CPU Architecture:Any
Tags: crash

[26 Jun 2015 6:27] Daniël van Eeden
Description:
An InnoDB Online Alter Table can crash MySQL when the filesystem on which the datadir resides has no free space left.

How to repeat:
ALTER TABLE t1 LOCK=NONE, ADD COLUMN foocol1 INT UNSIGNED DEFAULT '0';

2015-06-25 18:23:18 7fa5546b5700 InnoDB: Error: Write to file ./test/#sql-ib25-1897058496.ibd failed at offset 8439988224.
InnoDB: 1048576 bytes should have been written, only 356352 were written.
InnoDB: Operating system error number 0.
InnoDB: Check that your OS and file system support files of this size.
InnoDB: Check also that the disk is not full or a disk quota exceeded.
InnoDB: Error number 0 means 'Success'.
InnoDB: Some operating system error numbers are described at
InnoDB: http://dev.mysql.com/doc/refman/5.6/en/operating-system-error-codes.html
16:23:18 UTC - mysqld got signal 11 ;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.
We will try our best to scrape up some info that will hopefully help
diagnose the problem, but since we have already crashed, 
something is definitely wrong and this may fail.

key_buffer_size=805306368
read_buffer_size=131072
max_used_connections=25
max_threads=3000
thread_count=3
connection_count=2
It is possible that mysqld could use up to 
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 4280775 K  bytes of memory
Hope that's ok; if not, decrease some variables in the equation.

Thread pointer: 0x3fdd7da0
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
stack_bottom = 7fa5546b4e18 thread_stack 0x40000
/usr/sbin/mysqld(my_print_stacktrace+0x35)[0x8db795]
/usr/sbin/mysqld(handle_fatal_signal+0x494)[0x664dc4]
/lib64/libpthread.so.0(+0xf710)[0x7faf8b80b710]
/usr/sbin/mysqld[0xa69cb4]
/usr/sbin/mysqld[0xa751df]
/usr/sbin/mysqld[0xa03d6f]
/usr/sbin/mysqld[0xa0836f]
/usr/sbin/mysqld[0x98c7d2]
/usr/sbin/mysqld[0x732d12]
/usr/sbin/mysqld(_Z17mysql_alter_tableP3THDPcS1_P24st_ha_create_informationP10TABLE_LISTP10Alter_infojP8st_orderb+0x1901)[0x734891]
/usr/sbin/mysqld(_ZN19Sql_cmd_alter_table7executeEP3THD+0x479)[0x81cb09]
/usr/sbin/mysqld(_Z21mysql_execute_commandP3THD+0x2051)[0x6e2761]
/usr/sbin/mysqld(_Z11mysql_parseP3THDPcjP12Parser_state+0x3c0)[0x6e5790]
/usr/sbin/mysqld(_Z16dispatch_command19enum_server_commandP3THDPcj+0x152b)[0x6e6d6b]
/usr/sbin/mysqld(_Z24do_handle_one_connectionP3THD+0xcf)[0x6b32bf]
/usr/sbin/mysqld(handle_one_connection+0x47)[0x6b33e7]
/usr/sbin/mysqld(pfs_spawn_thread+0x12a)[0x960b4a]
/lib64/libpthread.so.0(+0x79d1)[0x7faf8b8039d1]
/lib64/libc.so.6(clone+0x6d)[0x7faf8a56c8fd]

Trying to get some variables.
Some pointers may be invalid and cause the dump to abort.
Query (7fa4d0009200): is an invalid pointer
Connection ID (thread ID): 118516
Status: NOT_KILLED

The manual page at http://dev.mysql.com/doc/mysql/en/crashing.html contains
information that should help you find out what is causing the crash.
150625 18:23:22 mysqld_safe Number of processes running now: 0
150625 18:23:22 mysqld_safe mysqld restarted

Suggested fix:
Abort the alter table and rollback.
[26 Jun 2015 6:58] Daniël van Eeden
This left two files in the data/test directory:
#sql-26b9_1cef4.frm
#sql-ib25-1897058496.ibd

This is in addition to the expected t1.frm and t1.ibd
[26 Jun 2015 9:17] Umesh Shastry
Hello Daniël,
 
Thank you for the report.
Observed this with 5.6.26 build with disk filled.

Thanks,
Umesh
[26 Jun 2015 9:17] Umesh Shastry
// 5.6.26

2015-06-26 10:42:57 20316 [Note] bin/mysqld: ready for connections.
Version: '5.6.26-enterprise-commercial-advanced'  socket: '/tmp/mysql_ushastry.sock'  port: 15000  MySQL Enterprise Server - Advanced Edition (Commercial)
2015-06-26 11:05:32 20316 [ERROR] bin/mysqld: The table 't5' is full
2015-06-26 11:10:47 7f40d48af700 InnoDB: Error: Write to file ./bug77497/#sql-ib22-24111827.ibd failed at offset 2320498688.
InnoDB: 1048576 bytes should have been written, only 675840 were written.
InnoDB: Operating system error number 0.
InnoDB: Check that your OS and file system support files of this size.
InnoDB: Check also that the disk is not full or a disk quota exceeded.
InnoDB: Error number 0 means 'Success'.
InnoDB: Some operating system error numbers are described at
InnoDB: http://dev.mysql.com/doc/refman/5.6/en/operating-system-error-codes.html
09:10:47 UTC - mysqld got signal 11 ;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.
We will try our best to scrape up some info that will hopefully help
diagnose the problem, but since we have already crashed,
something is definitely wrong and this may fail.

key_buffer_size=8388608
read_buffer_size=131072
max_used_connections=2
max_threads=151
--More--(94%)
[26 Jun 2015 13:46] Daniël van Eeden
> InnoDB: 1048576 bytes should have been written, only 356352 were written.
> InnoDB: Operating system error number 0.

It looks like this is the code where this happens:
https://github.com/mysql/mysql-server/blob/5.6/storage/innobase/os/os0file.cc#L2991

I wonder why it enters this function:
if (!os_has_said_disk_full) {

On disk full I expect os_has_said_disk_full() to return true.
And I also expect an non-zero error number.
Could this be filesystem dependend? I used XFS.
[6 Jul 2015 10:35] Andrii Nikitin
may be part of bug #68895
[29 Oct 2015 17:23] Daniel Price
Posted by developer:
 
    Bug #21326304 : INNODB ONLINE ALTER TABLE ENDS IN CRASH ON DISK FULL
    
    Issue
    =====
    Alter table crashes when disk is full. Reason for crash is that there is
    no check for NULL after btr_page_alloc().
    
    Fix
    ===
    If disk is full after btr_page_alloc() then return the error
    DB_OUT_OF_FILE_SPACE.
[29 Oct 2015 17:24] Daniel Price
Posted by developer:
 
Fixed as of the upcoming 5.6.28, 5.7.10, 5.8.0 release, and here's the changelog entry:

An ALTER TABLE operation caused the server to exit on disk full.

Thank you for the bug report.