summaryrefslogtreecommitdiff
path: root/storage/archive
diff options
context:
space:
mode:
authorAshish Agarwal <ashish.y.agarwal@oracle.com>2012-02-03 19:37:00 +0530
committerAshish Agarwal <ashish.y.agarwal@oracle.com>2012-02-03 19:37:00 +0530
commitcfcb5daba80df535527890b5bd37607057623e8f (patch)
treebbed1921838dd076952714b241f214659a6ed9a1 /storage/archive
parentbbcc86f5d41aba2562936e90ea1ea2c3034f8f6b (diff)
downloadmariadb-git-cfcb5daba80df535527890b5bd37607057623e8f.tar.gz
BUG#11748748 - 37280: CHECK AND REPAIR TABLE REPORT TABLE
CORRUPTED WHEN RUN CONCURRENTLY WITH ISSUE: Table corruption due to concurrent queries. Different threads running check, repair query along with insert. Locks not properly acquired in repair query. Rows are inserted inbetween repair query. SOLUTION: Mutex lock is acquired before the repair call. Concurrent queries wont effect the call to repair.
Diffstat (limited to 'storage/archive')
-rw-r--r--storage/archive/ha_archive.cc6
1 files changed, 6 insertions, 0 deletions
diff --git a/storage/archive/ha_archive.cc b/storage/archive/ha_archive.cc
index 79053f284b3..dc88f1d652f 100644
--- a/storage/archive/ha_archive.cc
+++ b/storage/archive/ha_archive.cc
@@ -1310,6 +1310,7 @@ int ha_archive::optimize(THD* thd, HA_CHECK_OPT* check_opt)
azio_stream writer;
char writer_filename[FN_REFLEN];
+ pthread_mutex_lock(&share->mutex);
init_archive_reader();
// now we close both our writer and our reader for the rename
@@ -1324,7 +1325,10 @@ int ha_archive::optimize(THD* thd, HA_CHECK_OPT* check_opt)
MY_REPLACE_EXT | MY_UNPACK_FILENAME);
if (!(azopen(&writer, writer_filename, O_CREAT|O_RDWR|O_BINARY)))
+ {
+ pthread_mutex_unlock(&share->mutex);
DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE);
+ }
/*
An extended rebuild is a lot more effort. We open up each row and re-record it.
@@ -1403,10 +1407,12 @@ int ha_archive::optimize(THD* thd, HA_CHECK_OPT* check_opt)
rc = my_rename(writer_filename,share->data_file_name,MYF(0));
+ pthread_mutex_unlock(&share->mutex);
DBUG_RETURN(rc);
error:
DBUG_PRINT("ha_archive", ("Failed to recover, error was %d", rc));
azclose(&writer);
+ pthread_mutex_unlock(&share->mutex);
DBUG_RETURN(rc);
}