From: Nisha Gopalakrishnan Date: June 6 2012 11:14am Subject: bzr push into mysql-trunk branch (nisha.gopalakrishnan:3949 to 3950) Bug#11827404 List-Archive: http://lists.mysql.com/commits/144107 X-Bug: 11827404 Message-Id: <201206061114.q56BEtAj025514@acsmt356.oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 3950 Nisha Gopalakrishnan 2012-06-06 Bug#11827404:60114: INSERT DELAYED CAN CALL HA_RELEASE_AUTO_INCREMENT WITHOUT HAVING A LOCK. Analysis ------- Mysqld crashes at times on a debug build, during the execution of the INSERT DELAYED statement under error scenarios. When a thread executes a DELAYED statement for a table, a handler thread is created to process all DELAYED statements for the table. The handler thread locks the table and handles the queued up inserts on the table. The handler thread updates the auto increment value row prior to writing the record. After the handler thread processes the stacked inserts, the auto increment value is reset and the table is unlocked. In case of simple INSERT, the thread that received INSERT request resets the auto increment value after writing the record. But not in the case of DELAYED INSERT since the threads share the table object. Under error scenarios, the thread that received the INSERT DELAYED request makes a redundant call to reset the auto increment value. The crash is observed in an error scenario and under a timing window where: The handler thread resets the auto increment value and unlocks the table, then the thread which received the INSERT DELAYED request tries to call the redundant release of auto increment value without having the lock on the table. Fix: --- Since the handler thread ensures the cleanup, removed the redundant call to reset the auto increment value in the main thread. Also in case of simple INSERT, it was observed that the call to reset auto increment value was redundant since the release was performed much ahead during the execution. NOTE:No regression test case has been added because the sync points currently does not work for the handler thread. The patch has been verified by running the existing test case main.delayed which fails sometimes without this patch. modified: sql/handler.cc sql/sql_insert.cc 3949 Sunny Bains 2012-06-06 BUG 14161424 - IMPORT OF COMPRESSED TABLE DOES AN EXTRA CHECKSUM OF NON INDEX PAGES When converting a page from the to be imported tablespace only checksum up to the compressed table page size. Approved Marko Makela modified: storage/innobase/row/row0import.cc === modified file 'sql/handler.cc' --- a/sql/handler.cc 2012-05-28 07:35:47 +0000 +++ b/sql/handler.cc 2012-06-06 11:13:22 +0000 @@ -3351,10 +3351,8 @@ void handler::get_auto_increment(ulonglo void handler::ha_release_auto_increment() { -#ifdef BUG60114_IS_FIXED DBUG_ASSERT(table_share->tmp_table != NO_TMP_TABLE || m_lock_type != F_UNLCK); -#endif release_auto_increment(); insert_id_for_cur_row= 0; auto_inc_interval_for_cur_row.replace(0, 0, 0); === modified file 'sql/sql_insert.cc' --- a/sql/sql_insert.cc 2012-05-28 11:41:46 +0000 +++ b/sql/sql_insert.cc 2012-06-06 11:13:22 +0000 @@ -1097,8 +1097,6 @@ exit_without_my_ok: if (lock_type == TL_WRITE_DELAYED) end_delayed_insert(thd); #endif - if (table != NULL) - table->file->ha_release_auto_increment(); if (!joins_freed) free_underlaid_joins(thd, &thd->lex->select_lex); thd->abort_on_warning= 0; No bundle (reason: useless for push emails).