mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Bug #56494 Segfault in upgrade_shared_lock_to_exclusive() for
REPAIR of merge table Bug #56422 CHECK TABLE run when the table is locked reports corruption along with timeout The crash happened if a table maintenance statement (ANALYZE TABLE, REPAIR TABLE, etc.) was executed on a MERGE table and opening and locking a child table failed. This could for example happen if a child table did not exist or if a lock timeout happened while waiting for a conflicting metadata lock to disappear. Since opening and locking the MERGE table and its children failed, the tables would be closed and the metadata locks released. However, TABLE_LIST::table for the MERGE table would still be set, with its value invalid since the tables had been closed. This caused the table maintenance statement to try to continue and upgrade the metadata lock on the MERGE table. But since the lock already had been released, this caused a segfault. This patch fixes the problem by setting TABLE_LIST::table to NULL if open_and_lock_tables() fails. This prevents maintenance statements from continuing and trying to upgrade the metadata lock. The patch includes a 5.5 version of the fix for Bug #46339 crash on REPAIR TABLE merge table USE_FRM. This bug caused REPAIR TABLE ... USE_FRM to give an assert when used on merge tables. The patch also enables the CHECK TABLE statement for log tables. Before, CHECK TABLE for log tables gave ER_CANT_LOCK_LOG_TABLE, yet still counted the statement as successfully executed. With the changes to table maintenance statement error handling in this patch, CHECK TABLE would no longer be considered as successful in this case. This would have caused upgrade scripts to mistakenly think that the general and slow logs are corrupted and have to be repaired. Enabling CHECK TABLES for log tables prevents this from happening. Finally, the patch changes the error message from "Corrupt" to "Operation failed" for a number of issues not related to table corruption. For example "Lock wait timeout exceeded" and "Deadlock found trying to get lock". Test cases added to merge.test and check.test.
This commit is contained in:
@ -2358,6 +2358,48 @@ t2 WHERE b SOUNDS LIKE e AND d = 1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
DROP TABLE t2, t1;
|
||||
#
|
||||
# Bug#46339 - crash on REPAIR TABLE merge table USE_FRM
|
||||
#
|
||||
DROP TABLE IF EXISTS m1, t1;
|
||||
CREATE TABLE t1 (c1 INT) ENGINE=MYISAM;
|
||||
CREATE TABLE m1 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1) INSERT_METHOD=LAST;
|
||||
LOCK TABLE m1 READ;
|
||||
REPAIR TABLE m1 USE_FRM;
|
||||
Table Op Msg_type Msg_text
|
||||
test.m1 repair Error Table 'm1' was locked with a READ lock and can't be updated
|
||||
test.m1 repair status Operation failed
|
||||
UNLOCK TABLES;
|
||||
REPAIR TABLE m1 USE_FRM;
|
||||
Table Op Msg_type Msg_text
|
||||
test.m1 repair note The storage engine for the table doesn't support repair
|
||||
DROP TABLE m1,t1;
|
||||
CREATE TABLE m1 (f1 BIGINT) ENGINE=MRG_MyISAM UNION(t1);
|
||||
REPAIR TABLE m1 USE_FRM;
|
||||
Table Op Msg_type Msg_text
|
||||
test.m1 repair Warning Can't open table
|
||||
test.m1 repair error Corrupt
|
||||
CREATE TABLE t1 (f1 BIGINT) ENGINE = MyISAM;
|
||||
REPAIR TABLE m1 USE_FRM;
|
||||
Table Op Msg_type Msg_text
|
||||
test.m1 repair note The storage engine for the table doesn't support repair
|
||||
REPAIR TABLE m1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.m1 repair note The storage engine for the table doesn't support repair
|
||||
DROP TABLE m1, t1;
|
||||
CREATE TEMPORARY TABLE m1 (f1 BIGINT) ENGINE=MRG_MyISAM UNION(t1);
|
||||
REPAIR TABLE m1 USE_FRM;
|
||||
Table Op Msg_type Msg_text
|
||||
test.m1 repair Error Table 'test.m1' doesn't exist
|
||||
test.m1 repair error Corrupt
|
||||
CREATE TEMPORARY TABLE t1 (f1 BIGINT) ENGINE=MyISAM;
|
||||
REPAIR TABLE m1 USE_FRM;
|
||||
Table Op Msg_type Msg_text
|
||||
m1 repair error Cannot repair temporary table from .frm file
|
||||
REPAIR TABLE m1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.m1 repair note The storage engine for the table doesn't support repair
|
||||
DROP TABLE m1, t1;
|
||||
End of 5.1 tests
|
||||
#
|
||||
# An additional test case for Bug#27430 Crash in subquery code
|
||||
@ -2677,7 +2719,7 @@ OPTIMIZE TABLE t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 optimize Error Table 'test.t_not_exists' doesn't exist
|
||||
test.t1 optimize Error Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
|
||||
test.t1 optimize note The storage engine for the table doesn't support optimize
|
||||
test.t1 optimize error Corrupt
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# Bug#36171 - CREATE TEMPORARY TABLE and MERGE engine
|
||||
@ -3575,4 +3617,48 @@ ERROR HY000: The definition of table 'v1' prevents operation DELETE on table 'm1
|
||||
drop view v1;
|
||||
drop temporary table tmp;
|
||||
drop table t1, t2, t3, m1, m2;
|
||||
#
|
||||
# Bug#56494 Segfault in upgrade_shared_lock_to_exclusive() for
|
||||
# REPAIR of merge table
|
||||
#
|
||||
DROP TABLE IF EXISTS t1, t2, t_not_exists;
|
||||
CREATE TABLE t1(a INT);
|
||||
ALTER TABLE t1 engine= MERGE UNION (t_not_exists);
|
||||
ANALYZE TABLE t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze Error Table 'test.t_not_exists' doesn't exist
|
||||
test.t1 analyze Error Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
|
||||
test.t1 analyze error Corrupt
|
||||
CHECK TABLE t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 check Error Table 'test.t_not_exists' doesn't exist
|
||||
test.t1 check Error Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
|
||||
test.t1 check error Corrupt
|
||||
CHECKSUM TABLE t1;
|
||||
Table Checksum
|
||||
test.t1 NULL
|
||||
Warnings:
|
||||
Error 1146 Table 'test.t_not_exists' doesn't exist
|
||||
Error 1168 Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
|
||||
OPTIMIZE TABLE t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 optimize Error Table 'test.t_not_exists' doesn't exist
|
||||
test.t1 optimize Error Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
|
||||
test.t1 optimize error Corrupt
|
||||
REPAIR TABLE t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 repair Error Table 'test.t_not_exists' doesn't exist
|
||||
test.t1 repair Error Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
|
||||
test.t1 repair error Corrupt
|
||||
REPAIR TABLE t1 USE_FRM;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 repair Warning Can't open table
|
||||
test.t1 repair error Corrupt
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1(a INT);
|
||||
CREATE TABLE t2(a INT) engine= MERGE UNION (t1);
|
||||
REPAIR TABLE t2 USE_FRM;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t2 repair note The storage engine for the table doesn't support repair
|
||||
DROP TABLE t1, t2;
|
||||
End of 6.0 tests
|
||||
|
Reference in New Issue
Block a user