Commit cf8df9ca authored by Jon Olav Hauglid's avatar Jon Olav Hauglid

Bug #47459 Assertion in Diagnostics_area::set_eof_status on OPTIMIZE TABLE

This assertion could be triggered during execution of OPTIMIZE TABLE for
InnoDB tables. As part of optimize for InnoDB tables, the table is recreated
and then opened again. If the reopen failed for any reason, the assertion
would be triggered. This could for example be caused by a concurrent DROP
TABLE executed by a different connection. The reason for the assertion was
that any failures during reopening were ignored.

This patch fixes the problem by making sure that the result of reopening the
table is checked and that any error messages are sent to the client.

Test case added to innodb_mysql_sync.test.
parent 4347e302
...@@ -24,3 +24,27 @@ Warnings: ...@@ -24,3 +24,27 @@ Warnings:
Error 1030 Got error -1 from storage engine Error 1030 Got error -1 from storage engine
DROP TABLE t1; DROP TABLE t1;
SET DEBUG_SYNC='RESET'; SET DEBUG_SYNC='RESET';
#
# Bug#47459 Assertion in Diagnostics_area::set_eof_status on
# OPTIMIZE TABLE
#
DROP TABLE IF EXISTS t1;
CREATE TABLE t1(a INT) ENGINE= InnoDB;
# Connection con1
SET DEBUG_SYNC= "ha_admin_open_ltable SIGNAL opening WAIT_FOR dropped";
# Sending:
OPTIMIZE TABLE t1;
# Connection default
SET DEBUG_SYNC= "now WAIT_FOR opening";
DROP TABLE t1;
SET DEBUG_SYNC= "now SIGNAL dropped";
# Connection con1
# Reaping: OPTIMIZE TABLE t1
Table Op Msg_type Msg_text
test.t1 optimize note Table does not support optimize, doing recreate + analyze instead
test.t1 optimize error Table 'test.t1' doesn't exist
test.t1 optimize status Operation failed
Warnings:
Error 1146 Table 'test.t1' doesn't exist
# Connection default
SET DEBUG_SYNC= "RESET";
...@@ -43,6 +43,43 @@ DROP TABLE t1; ...@@ -43,6 +43,43 @@ DROP TABLE t1;
SET DEBUG_SYNC='RESET'; SET DEBUG_SYNC='RESET';
--echo #
--echo # Bug#47459 Assertion in Diagnostics_area::set_eof_status on
--echo # OPTIMIZE TABLE
--echo #
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
connect (con1, localhost, root);
connection default;
CREATE TABLE t1(a INT) ENGINE= InnoDB;
--echo # Connection con1
connection con1;
SET DEBUG_SYNC= "ha_admin_open_ltable SIGNAL opening WAIT_FOR dropped";
--echo # Sending:
--send OPTIMIZE TABLE t1
--echo # Connection default
connection default;
SET DEBUG_SYNC= "now WAIT_FOR opening";
DROP TABLE t1;
SET DEBUG_SYNC= "now SIGNAL dropped";
--echo # Connection con1
connection con1;
--echo # Reaping: OPTIMIZE TABLE t1
--reap
--echo # Connection default
connection default;
disconnect con1;
SET DEBUG_SYNC= "RESET";
# Check that all connections opened by test cases in this file are really # Check that all connections opened by test cases in this file are really
# gone so execution of other tests won't be affected by their presence. # gone so execution of other tests won't be affected by their presence.
--source include/wait_until_count_sessions.inc --source include/wait_until_count_sessions.inc
...@@ -5016,12 +5016,18 @@ send_result_message: ...@@ -5016,12 +5016,18 @@ send_result_message:
{ {
/* Clear the ticket released in close_thread_tables(). */ /* Clear the ticket released in close_thread_tables(). */
table->mdl_request.ticket= NULL; table->mdl_request.ticket= NULL;
if ((table->table= open_ltable(thd, table, lock_type, 0)) && DEBUG_SYNC(thd, "ha_admin_open_ltable");
((result_code= table->table->file->ha_analyze(thd, check_opt)) > 0)) if (table->table= open_ltable(thd, table, lock_type, 0))
result_code= 0; // analyze went ok {
if (result_code) // analyze failed result_code= table->table->file->ha_analyze(thd, check_opt);
if (result_code == HA_ADMIN_ALREADY_DONE)
result_code= HA_ADMIN_OK;
else if (result_code) // analyze failed
table->table->file->print_error(result_code, MYF(0)); table->table->file->print_error(result_code, MYF(0));
} }
else
result_code= -1; // open failed
}
/* Start a new row for the final status row */ /* Start a new row for the final status row */
protocol->prepare_for_resend(); protocol->prepare_for_resend();
protocol->store(table_name, system_charset_info); protocol->store(table_name, system_charset_info);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment