Commit c5dd72b5 authored by Sergey Vojtovich's avatar Sergey Vojtovich

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.

mysql-test/r/archive_debug.result:
  A test case for BUG#12402794.
mysql-test/t/archive_debug.test:
  A test case for BUG#12402794.
storage/archive/azio.c:
  A test case for BUG#12402794.
storage/archive/ha_archive.cc:
  Handle init_archive_reader() failure.
parent 91133804
#
# BUG#12402794 - 60976: CRASH, VALGRIND WARNING AND MEMORY LEAK
# WITH PARTITIONED ARCHIVE TABLES
#
CREATE TABLE t1(a INT) ENGINE=ARCHIVE;
INSERT INTO t1 VALUES(1);
SET SESSION debug='d,simulate_archive_open_failure';
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check error Corrupt
SET SESSION debug=DEFAULT;
DROP TABLE t1;
--source include/have_archive.inc
--source include/have_debug.inc
--echo #
--echo # BUG#12402794 - 60976: CRASH, VALGRIND WARNING AND MEMORY LEAK
--echo # WITH PARTITIONED ARCHIVE TABLES
--echo #
CREATE TABLE t1(a INT) ENGINE=ARCHIVE;
INSERT INTO t1 VALUES(1);
SET SESSION debug='d,simulate_archive_open_failure';
CHECK TABLE t1;
SET SESSION debug=DEFAULT;
DROP TABLE t1;
...@@ -114,6 +114,15 @@ int az_open (azio_stream *s, const char *path, int Flags, File fd) ...@@ -114,6 +114,15 @@ int az_open (azio_stream *s, const char *path, int Flags, File fd)
errno = 0; errno = 0;
s->file = fd < 0 ? my_open(path, Flags, MYF(0)) : fd; 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 ) if (s->file < 0 )
{ {
......
...@@ -1586,11 +1586,12 @@ int ha_archive::check(THD* thd, HA_CHECK_OPT* check_opt) ...@@ -1586,11 +1586,12 @@ int ha_archive::check(THD* thd, HA_CHECK_OPT* check_opt)
azflush(&(share->archive_write), Z_SYNC_FLUSH); azflush(&(share->archive_write), Z_SYNC_FLUSH);
pthread_mutex_unlock(&share->mutex); 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 Now we will rewind the archive file so that we are positioned at the
start of the file. start of the file.
*/ */
init_archive_reader();
read_data_header(&archive); read_data_header(&archive);
while (!(rc= get_row(&archive, table->record[0]))) while (!(rc= get_row(&archive, table->record[0])))
count--; count--;
......
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