From 33a9d9fa65a430d566cfdbebc549039751fdddcc Mon Sep 17 00:00:00 2001 From: Sergey Vojtovich Date: Wed, 18 May 2011 14:01:43 +0400 Subject: BUG#12402794 - 60976: CRASH, VALGRIND WARNING AND MEMORY LEAK WITH PARTITIONED ARCHIVE TABLES CHECK TABLE against archive table, when file descriptors are exhausted, caused server crash. Archive didn't handle errors when opening data file for CHECK TABLE. --- storage/archive/azio.c | 9 +++++++++ storage/archive/ha_archive.cc | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) (limited to 'storage') diff --git a/storage/archive/azio.c b/storage/archive/azio.c index c1dd6e6f38c..aaf8233a30c 100644 --- a/storage/archive/azio.c +++ b/storage/archive/azio.c @@ -114,6 +114,15 @@ int az_open (azio_stream *s, const char *path, int Flags, File fd) errno = 0; s->file = fd < 0 ? my_open(path, Flags, MYF(0)) : fd; + DBUG_EXECUTE_IF("simulate_archive_open_failure", + { + if (s->file >= 0) + { + my_close(s->file, MYF(0)); + s->file= -1; + my_errno= EMFILE; + } + }); if (s->file < 0 ) { diff --git a/storage/archive/ha_archive.cc b/storage/archive/ha_archive.cc index e5c483daac5..4da98507dcf 100644 --- a/storage/archive/ha_archive.cc +++ b/storage/archive/ha_archive.cc @@ -1586,11 +1586,12 @@ int ha_archive::check(THD* thd, HA_CHECK_OPT* check_opt) azflush(&(share->archive_write), Z_SYNC_FLUSH); pthread_mutex_unlock(&share->mutex); + if (init_archive_reader()) + DBUG_RETURN(HA_ADMIN_CORRUPT); /* Now we will rewind the archive file so that we are positioned at the start of the file. */ - init_archive_reader(); read_data_header(&archive); while (!(rc= get_row(&archive, table->record[0]))) count--; -- cgit v1.2.1