From: Dmitry Shulga Date: November 2 2010 11:32am Subject: bzr commit into mysql-5.1-bugteam branch (Dmitry.Shulga:3548) Bug#47924 List-Archive: http://lists.mysql.com/commits/122517 X-Bug: 47924 Message-Id: <201011021134.oA29S6k2022174@acsinet15.oracle.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0355415477==" --===============0355415477== 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:anitha.gopi@stripped 3548 Dmitry Shulga 2010-11-02 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-02 11:32:19 +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-02 11:32:19 +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-02 11:32:19 +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; } } --===============0355415477== 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\ # pmool43tft65qo81 # target_branch: file:///Users/shulga/projects/mysql/5.1-bugteam-\ # bug47924/ # testament_sha1: 668a2bec39dfcfe68f200b49d9c5a302e2bdd4f7 # timestamp: 2010-11-02 17:32:34 +0600 # base_revision_id: anitha.gopi@stripped\ # h9gdxjzhjv8zxse9 # # Begin bundle IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWcO3ZewAA7xfgFBQWOf//3/H nqC////wYAlLttPunXSqhm+d25zlg6973PTXXczpR3eGSSe1NUwymekNNR6n6RqAAyGgBp6gaaBJ KNGINBMIU3pT00o9okYhpkxMgHpAOYAjBMQDAJgmjIaGATBGJhIppDUwqfpMUxqfpJmFAADQAaA0 ARSJpBqbU9Keppo81TEPUfqh6gwQepkGh6gwSRBAmmmEmlP9DUTGmkwo9ExAANAJDpU0SvbPS24j EQJqwiz0syUzOkcdkGt+U+kUB0KqUuKehm2y30f1zcILYK9MWyx7iUHPc0/Z+mcPKVg/ZscVMwmv rsvbx5N66lam22Juu/7pdiqkSMWaHqiqNr3VRsaGhrYmFGaoQ5Qgnf4jbZhjbUBptAZRVZit4xDZ eCigmXleTwYdDvk/66YRkQBxYipexiwl5Yv+lw+pgs6nS3HROOWyFaSLjf4YDgq1qgOIcpq2NQ/l x9ZUs4x+xUMzNysVYaFb5pi04hILDU0JZ2QiWCYjvtkP42dcCRGooc+cNWqcW+nr3+r16QLqPGbw 8FbdZ70nMheYY+jCYMG8/jdtlYbqguUxcgDs9w93yCXNanxpBmOBxlFecEZYozKFNEFWjg0DREuA XXbwvkPBQkN3rRzgiYhkZKEJruLNxisnuWcaxAzEBdygvmNBQAY586JYjimJQQnFN2XBwWMxOiY5 PspqfOZFBR117FExsgzMK5hTgXFhUXSryLyopL0pjKihoRD1cTqV9qjBkK9ykRBOpV2SyL+y2Ijf 8n4EhFpSKNVLmHOKRyk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