1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

BUG#11763712 - 56458: KILLING A FLUSH TABLE FOR A MERGE/CHILD

CRASHES SERVER

Flushing of MERGE table or one of its child tables, which was
locked by flushing thread using LOCK TABLES, might have caused
crashes or assertion failures if the thread failed to reopen
child or parent table.
Particularly, this might have happened when another connection
killed this FLUSH TABLE statement/connection.
Also this problem might have occurred when we failed to reopen
MERGE table or one of its children when executing DDL statement
under LOCK TABLES.

The problem was caused by the fact that reopen_tables() might
have failed to reopen child table but still tried to reopen,
reattach children for and re-lock its parent. Vice versa it
might have failed to reopen parent but kept references from
children to parent around. Since reopen_tables() closes table
it has failed to reopen and therefore frees all associated
memory such dangling references led to crashes when followed.

This patch solves this problem by ensuring that we always close
parent table and all its children if we fail to reopen this
table or one of its children. Same happens if we fail to reattach
children to parent.

Affects 5.1 only.

mysql-test/r/merge.result:
  A test case for BUG#11763712.
mysql-test/t/merge.test:
  A test case for BUG#11763712.
sql/sql_base.cc:
  When flushing tables under LOCK TABLES, all locked
  and flushed tables are released and then reopened.
  It may happen that we failed to reopen some tables,
  in this case we reopen as much tables as possible.
  
  If it was not possible to reopen MERGE child, MERGE
  parent is unusable and must be removed from thread
  open tables list.
  
  If it was not possible to reopen MERGE parent, all
  MERGE child table objects are unusable as well, at
  least because their locks are handled by MERGE parent.
  They must also be removed from thread open tables
  list.
  
  In other words if it was impossible to reopen any
  object of a MERGE table or reattach child tables,
  all objects of this MERGE table must be considered
  unusable and closed.
This commit is contained in:
Sergey Vojtovich
2011-08-18 10:38:51 +04:00
parent 16f26d2aaf
commit a8ee6e48f7
3 changed files with 215 additions and 42 deletions

View File

@ -2341,4 +2341,33 @@ 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;
#
# BUG#11763712 - 56458: KILLING A FLUSH TABLE FOR A MERGE/CHILD
# CRASHES SERVER
#
CREATE TABLE t1(a INT);
CREATE TABLE t2(a INT);
CREATE TABLE t3(a INT, b INT);
CREATE TABLE m1(a INT) ENGINE=MERGE UNION=(t1, t2);
# Test reopen merge parent failure
LOCK TABLES m1 READ;
# Remove 'm1' table using file operations.
FLUSH TABLES;
ERROR 42S02: Table 'test.m1' doesn't exist
UNLOCK TABLES;
CREATE TABLE m1(a INT) ENGINE=MERGE UNION=(t1, t2);
# Test reopen merge child failure
LOCK TABLES m1 READ;
# Remove 't1' table using file operations.
FLUSH TABLES;
ERROR 42S02: Table 'test.t1' doesn't exist
UNLOCK TABLES;
CREATE TABLE t1(a INT);
# Test reattach merge failure
LOCK TABLES m1 READ;
# Replace 't1' with 't3' table using file operations.
FLUSH TABLES;
ERROR HY000: Can't reopen table: 'm1'
UNLOCK TABLES;
DROP TABLE t1, t2, t3, m1;
End of 5.1 tests