From: Dmitry Shulga Date: November 7 2010 5:42pm Subject: bzr commit into mysql-5.1-bugteam branch (Dmitry.Shulga:3554) Bug#47924 List-Archive: http://lists.mysql.com/commits/123036 X-Bug: 47924 Message-Id: <201011071744.oA7HiAo9022022@rcsinet15.oracle.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0308201138==" --===============0308201138== MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline #At file:///Users/shulga/projects/mysql/5.1-bugteam-bug47924/ based on revid:guilhem@stripped 3554 Dmitry Shulga 2010-11-07 A fix and a test case for Bug#47924 -main.log_tables times out sporadically. The cause of the sporadic time out was a leaking protection against the global read lock, taken by the RENAME statement, and not released in case of an error occurred during RENAME. The leaking protection counter would lead to the value of protect_against_global_read never dropping to 0. Consequently FLUSH TABLES in all connections, including the one that leaked the protection, could not proceed. The fix is to ensure that all branchesin RENAME code properly release GRL protection. @ mysql-test/r/log_tables.result Added results for test for bug#47924. @ mysql-test/t/log_tables.test Added test for bug#47924. @ sql/sql_rename.cc mysql_rename_tables() modified: replaced return from function to goto to clean up code block in case of error. modified: mysql-test/r/log_tables.result mysql-test/t/log_tables.test sql/sql_rename.cc === modified file 'mysql-test/r/log_tables.result' --- a/mysql-test/r/log_tables.result 2009-03-11 20:30:56 +0000 +++ b/mysql-test/r/log_tables.result 2010-11-07 17:42:54 +0000 @@ -899,6 +899,16 @@ TIMESTAMP 1 1 SELECT SQL_NO_CACHE 'Bug#3 TIMESTAMP 1 1 SELECT SQL_NO_CACHE 'Bug#31700 - PK', f1,f2,f3,SLEEP(1.1) FROM t1 WHERE f1=2 DROP TABLE t1; TRUNCATE TABLE mysql.slow_log; +use mysql; +drop table if exists renamed_general_log; +drop table if exists renamed_slow_log; +RENAME TABLE general_log TO renamed_general_log; +ERROR HY000: Cannot rename 'general_log'. When logging enabled, rename to/from log table must rename two tables: the log table to an archive table and another table back to 'general_log' +RENAME TABLE slow_log TO renamed_slow_log; +ERROR HY000: Cannot rename 'slow_log'. When logging enabled, rename to/from log table must rename two tables: the log table to an archive table and another table back to 'slow_log' +use test; +flush tables with read lock; +unlock tables; SET @@session.long_query_time= @old_long_query_time; SET @@global.log_output= @old_log_output; SET @@global.slow_query_log= @old_slow_query_log; === modified file 'mysql-test/t/log_tables.test' --- a/mysql-test/t/log_tables.test 2009-03-11 20:30:56 +0000 +++ b/mysql-test/t/log_tables.test 2010-11-07 17:42:54 +0000 @@ -1027,6 +1027,25 @@ DROP TABLE t1; TRUNCATE TABLE mysql.slow_log; +# +# Bug #47924 main.log_tables times out sporadically +# + +use mysql; +# Should result in error +--disable_warnings +drop table if exists renamed_general_log; +drop table if exists renamed_slow_log; +--enable_warnings +--error ER_CANT_RENAME_LOG_TABLE +RENAME TABLE general_log TO renamed_general_log; +--error ER_CANT_RENAME_LOG_TABLE +RENAME TABLE slow_log TO renamed_slow_log; + +use test; +flush tables with read lock; +unlock tables; + SET @@session.long_query_time= @old_long_query_time; SET @@global.log_output= @old_log_output; === modified file 'sql/sql_rename.cc' --- a/sql/sql_rename.cc 2010-01-24 07:03:23 +0000 +++ b/sql/sql_rename.cc 2010-11-07 17:42:54 +0000 @@ -99,7 +99,7 @@ bool mysql_rename_tables(THD *thd, TABLE */ my_error(ER_CANT_RENAME_LOG_TABLE, MYF(0), ren_table->table_name, ren_table->table_name); - DBUG_RETURN(1); + goto err; } } else @@ -112,7 +112,7 @@ bool mysql_rename_tables(THD *thd, TABLE */ my_error(ER_CANT_RENAME_LOG_TABLE, MYF(0), ren_table->table_name, ren_table->table_name); - DBUG_RETURN(1); + goto err; } else { @@ -130,7 +130,7 @@ bool mysql_rename_tables(THD *thd, TABLE else my_error(ER_CANT_RENAME_LOG_TABLE, MYF(0), rename_log_table[1], rename_log_table[1]); - DBUG_RETURN(1); + goto err; } } --===============0308201138== MIME-Version: 1.0 Content-Type: text/bzr-bundle; charset="us-ascii"; name="bzr/dmitry.shulga@stripped" Content-Transfer-Encoding: 7bit Content-Disposition: inline # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: dmitry.shulga@stripped\ # rr1n5tuj3t4mrgc7 # target_branch: file:///Users/shulga/projects/mysql/5.1-bugteam-\ # bug47924/ # testament_sha1: 22930788d0c891ab85de690f974e0e4c6c93392e # timestamp: 2010-11-07 23:43:03 +0600 # base_revision_id: guilhem@stripped # # Begin bundle IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWfDyjcsAA7XfgFBQWOf//3/H nqC////wYAkrt9rplbEqGJVFK0ZAKpSpGDUJiI0yDQaaNPSAAANADTQDQJKRkBiBNBqnonqflI/V PUGgAAA0AcwBGCYgGATBNGQ0MAmCMTCREIiYnoCJPam1J+ITTUekHqB6EyeoeUBzAEYJiAYBME0Z DQwCYIxMJJCNDSYTTIaJhBlGmRT9AkfqaIeo2kejZIUkemuIdfQyUxSgsTwj5xvV6LDdYkikI8F8 lSAw1A+syk8DGdGze788miCFCtTCEb9LbKXUOnbx+ePHstiTtZhgpGCa+m3kb5c/BfNY022xN2ye SWat8wa2anrms/W99VzLpSEnOYh1olKxAodc4CcakuiACE4FkQR05dQKkaCRMOX8XD6GIUdLI+E9 FNhQECtFS+TFZZ/GmP4tI1MFfzd+Pl0UnnulYyDkOHukOKstUhnHFFjnUP47PMqsBj/RUMzNwrUg yJRc40GYWBWazIsxropKxMU7IRJ8n63ESmoc2eUNzKmkPF38+vybaCx3OTWlPjJ7UmMQvINPmwmC 9vL6WapqjKkLFOLvAOfoO8/qE0m07xYK+KsO2C6iOUIqwitvCefb3+h6Pnko9hcjStCckRtZ9SLC GjSpmq3mPWaljjKuf79eQQNlBcFK/ocqQGdfXfvtiJFcJShQK6GmUEzdUky0CBuJxP1sI3EVAIKh lPOFFR1IkyabMkPoLkoGqx72KcMimWhYQiyq0jSYdGe9C5vhdgYyoqKXNYNaOGqtsaZsJNl6fSMD BGFS1sxtLqKzZXERpRZzy2zyFgaR0Rmcvxi/SoaDW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