Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

MDEV-36017 Alter table aborts when temporary directory is full #3902

Open
wants to merge 1 commit into
base: 10.11
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions mysql-test/suite/innodb/r/alter_temp_fail.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#
# MDEV-36017 Alter table aborts when temporary
# directory is full
#
CREATE TABLE t1(f1 INT NOT NULL, f2 CHAR(100),
f3 CHAR(100))ENGINE=InnoDB;
INSERT INTO t1 SELECT seq, 'a', 'b' FROM seq_1_to_1024;
SET DEBUG_DBUG="+d,write_to_tmp_file_fail";
ALTER TABLE t1 FORCE, ALGORITHM=COPY;
ERROR HY000: Got error 59 'Temp file write failure' from InnoDB
SET DEBUG_DBUG="-d,write_to_tmp_file_fail";
DROP TABLE t1;
CREATE TABLE t1(f1 INT NOT NULL, f2 CHAR(100),
f3 CHAR(100))ENGINE=InnoDB;
INSERT INTO t1 SELECT seq, 'a', 'b' FROM seq_1_to_4096;
SET DEBUG_SYNC="inplace_after_index_build SIGNAL dml_start WAIT_FOR dml_commit";
ALTER TABLE t1 ADD KEY(f1), ADD INDEX(f3(10));
connect con1,localhost,root,,,;
SET DEBUG_SYNC="now WAIT_FOR dml_start";
BEGIN;
INSERT INTO t1 SELECT * FROM t1;
SET DEBUG_DBUG="+d,os_file_write_fail";
COMMIT;
SET DEBUG_DBUG="-d,os_file_write_fail";
SET DEBUG_SYNC="now SIGNAL dml_commit";
connection default;
ERROR HY000: Temporary file write failure
disconnect con1;
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
DROP TABLE t1;
1 change: 1 addition & 0 deletions mysql-test/suite/innodb/t/alter_temp_fail.opt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--innodb_sort_buffer_size=64k
37 changes: 37 additions & 0 deletions mysql-test/suite/innodb/t/alter_temp_fail.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
--source include/have_innodb.inc
--source include/have_sequence.inc
--source include/have_debug.inc
--echo #
--echo # MDEV-36017 Alter table aborts when temporary
--echo # directory is full
--echo #
CREATE TABLE t1(f1 INT NOT NULL, f2 CHAR(100),
f3 CHAR(100))ENGINE=InnoDB;
INSERT INTO t1 SELECT seq, 'a', 'b' FROM seq_1_to_1024;
SET DEBUG_DBUG="+d,write_to_tmp_file_fail";
--error ER_GET_ERRMSG
ALTER TABLE t1 FORCE, ALGORITHM=COPY;
SET DEBUG_DBUG="-d,write_to_tmp_file_fail";
DROP TABLE t1;

CREATE TABLE t1(f1 INT NOT NULL, f2 CHAR(100),
f3 CHAR(100))ENGINE=InnoDB;
INSERT INTO t1 SELECT seq, 'a', 'b' FROM seq_1_to_4096;
SET DEBUG_SYNC="inplace_after_index_build SIGNAL dml_start WAIT_FOR dml_commit";
SEND ALTER TABLE t1 ADD KEY(f1), ADD INDEX(f3(10));

connect(con1,localhost,root,,,);
SET DEBUG_SYNC="now WAIT_FOR dml_start";
BEGIN;
INSERT INTO t1 SELECT * FROM t1;
SET DEBUG_DBUG="+d,os_file_write_fail";
COMMIT;
SET DEBUG_DBUG="-d,os_file_write_fail";
SET DEBUG_SYNC="now SIGNAL dml_commit";

connection default;
--error ER_TEMP_FILE_WRITE_FAILURE
reap;
disconnect con1;
CHECK TABLE t1;
DROP TABLE t1;
2 changes: 1 addition & 1 deletion storage/innobase/fil/fil0fil.cc
Original file line number Diff line number Diff line change
@@ -605,7 +605,7 @@ fil_space_extend_must_retry(
*success = os_file_set_size(node->name, node->handle, new_size,
node->punch_hole == 1);

os_has_said_disk_full = *success;
os_has_said_disk_full = !*success;
if (*success) {
os_file_flush(node->handle);
last_page_no = size;
5 changes: 5 additions & 0 deletions storage/innobase/handler/ha_innodb.cc
Original file line number Diff line number Diff line change
@@ -2193,6 +2193,11 @@ convert_error_code_to_mysql(
return(HA_ERR_RECORD_FILE_FULL);

case DB_TEMP_FILE_WRITE_FAIL:
/* This error can happen during
ALTER TABLE..ALGORITHM=COPY or bulk insert operation */
innodb_transaction_abort(thd,
innobase_rollback_on_timeout,
error);
my_error(ER_GET_ERRMSG, MYF(0),
DB_TEMP_FILE_WRITE_FAIL,
ut_strerr(DB_TEMP_FILE_WRITE_FAIL),
5 changes: 5 additions & 0 deletions storage/innobase/row/row0log.cc
Original file line number Diff line number Diff line change
@@ -398,12 +398,17 @@ bool row_log_online_op(dict_index_t *index, const dtuple_t *tuple,
}

log->tail.blocks++;
DBUG_EXECUTE_IF("os_file_write_fail",
log->error = DB_TEMP_FILE_WRITE_FAIL;
goto write_failed;);

if (os_file_write(
IORequestWrite,
"(modification log)",
log->fd,
buf, byte_offset, srv_sort_buf_size)
!= DB_SUCCESS) {
log->error = DB_TEMP_FILE_WRITE_FAIL;
write_failed:
index->type |= DICT_CORRUPT;
}
2 changes: 2 additions & 0 deletions storage/innobase/row/row0merge.cc
Original file line number Diff line number Diff line change
@@ -5178,6 +5178,8 @@ dberr_t row_merge_bulk_t::write_to_tmp_file(ulint index_no)
buf->index->table->space->id))
return DB_TEMP_FILE_WRITE_FAIL;
MEM_UNDEFINED(&m_block[0], srv_sort_buf_size);
DBUG_EXECUTE_IF("write_to_tmp_file_fail",
return DB_TEMP_FILE_WRITE_FAIL;);
return DB_SUCCESS;
}

1 change: 1 addition & 0 deletions storage/innobase/row/row0mysql.cc
Original file line number Diff line number Diff line change
@@ -673,6 +673,7 @@ row_mysql_handle_errors(
case DB_TABLE_NOT_FOUND:
case DB_DECRYPTION_FAILED:
case DB_COMPUTE_VALUE_FAILED:
case DB_TEMP_FILE_WRITE_FAIL:
rollback_to_savept:
DBUG_EXECUTE_IF("row_mysql_crash_if_error", {
log_buffer_flush_to_disk();