From: Ashish Agarwal Date: February 3 2012 2:15pm Subject: bzr push into mysql-5.1 branch (ashish.y.agarwal:3682 to 3683) Bug#11748748 List-Archive: http://lists.mysql.com/commits/142743 X-Bug: 11748748 Message-Id: <201202031415.q13EF8jE004079@acsmt357.oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 3683 Ashish Agarwal 2012-02-03 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. modified: storage/archive/ha_archive.cc 3682 Alexander Barkov 2012-02-02 Postfix for Bug#11752408. Recording correct test results. modified: mysql-test/suite/engines/funcs/r/db_alter_collate_ascii.result mysql-test/suite/engines/funcs/r/db_alter_collate_utf8.result modified: mysql-test/suite/engines/funcs/r/db_alter_collate_ascii.result mysql-test/suite/engines/funcs/r/db_alter_collate_utf8.result === modified file 'storage/archive/ha_archive.cc' --- a/storage/archive/ha_archive.cc 2011-11-23 13:03:29 +0000 +++ b/storage/archive/ha_archive.cc 2012-02-03 14:07:00 +0000 @@ -1310,6 +1310,7 @@ int ha_archive::optimize(THD* thd, HA_CH 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_CH 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_CH 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); } No bundle (reason: useless for push emails).