From 3ddfab5e3c99a5f943cec1f003dbee5a2478c853 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Thu, 13 Jun 2013 15:13:13 +0200 Subject: [PATCH] MDEV-4444 Server crashes with "safe_mutex: Trying to destroy a mutex share->mutex that was locked" on attempt to recover an archive table --- mysql-test/suite/archive/repair.result | 11 +++++++++++ mysql-test/suite/archive/repair.test | 18 ++++++++++++++++++ storage/archive/ha_archive.cc | 3 +++ 3 files changed, 32 insertions(+) create mode 100644 mysql-test/suite/archive/repair.result create mode 100644 mysql-test/suite/archive/repair.test diff --git a/mysql-test/suite/archive/repair.result b/mysql-test/suite/archive/repair.result new file mode 100644 index 00000000000..5a8c92189d6 --- /dev/null +++ b/mysql-test/suite/archive/repair.result @@ -0,0 +1,11 @@ +create table t1 (a int) engine=archive; +insert into t1 values (1); +select * from t1; +Got one of the listed errors +insert into t1 values (2); +ERROR HY000: Table 't1' is marked as crashed and should be repaired +repair table t1; +Table Op Msg_type Msg_text +test.t1 repair error Corrupt +drop table t1; +ERROR 42S02: Unknown table 't1' diff --git a/mysql-test/suite/archive/repair.test b/mysql-test/suite/archive/repair.test new file mode 100644 index 00000000000..71f55c923b5 --- /dev/null +++ b/mysql-test/suite/archive/repair.test @@ -0,0 +1,18 @@ +# +# MDEV-4444 Server crashes with "safe_mutex: Trying to destroy a mutex share->mutex that was locked" on attempt to recover an archive table +# + +--source include/have_archive.inc + +--let $datadir = `SELECT @@datadir` + +create table t1 (a int) engine=archive; +insert into t1 values (1); +--remove_file $datadir/test/t1.ARZ +--error 13,1017 +select * from t1; +--error ER_CRASHED_ON_USAGE +insert into t1 values (2); +repair table t1; +--error ER_BAD_TABLE_ERROR +drop table t1; diff --git a/storage/archive/ha_archive.cc b/storage/archive/ha_archive.cc index f5b96989811..e33b1735914 100644 --- a/storage/archive/ha_archive.cc +++ b/storage/archive/ha_archive.cc @@ -1417,7 +1417,10 @@ int ha_archive::optimize(THD* thd, HA_CHECK_OPT* check_opt) mysql_mutex_lock(&share->mutex); if (init_archive_reader()) + { + mysql_mutex_unlock(&share->mutex); DBUG_RETURN(errno); + } // now we close both our writer and our reader for the rename if (share->archive_write_open)