Bug #51710 FLUSH TABLES <view> WITH READ LOCK kills the server.
Submitted: 4 Mar 2010 8:17 Modified: 14 Mar 2010 0:42
Reporter: Alexey Botchkov Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Locking Severity:S1 (Critical)
Version:5.5.99-m3 OS:Any
Assigned to: Konstantin Osipov CPU Architecture:Any

[4 Mar 2010 8:17] Alexey Botchkov
Description:
Any view added to the table list of the
FLUSH TABLES <list> WITH READ LOCK;
causes server to crash.

How to repeat:
drop view if exists v1;
drop table if exists t1;
create table t1 (id int);
create view v1 as select id from t1;
FLUSH TABLES v1 WITH READ LOCK;
[4 Mar 2010 9:18] Valeriy Kravchuk
Sorry, what exact tree do you use? Recent mysql-next-mr does not support this syntax at all it seems:

openxs@ubuntu:/home2/openxs/dbs/next-mr$ bin/mysql --no-defaults -uroot test
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.99-m3-debug Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> drop view if exists v1;
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> drop table if exists t1;
Query OK, 0 rows affected (0.00 sec)

mysql> create table t1 (id int);
Query OK, 0 rows affected (0.01 sec)

mysql> create view v1 as select id from t1;
Query OK, 0 rows affected (0.00 sec)

mysql> FLUSH TABLES v1 WITH READ LOCK;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'READ LOCK' at line 1
mysql> FLUSH TABLES WITH READ LOCK;
Query OK, 0 rows affected (0.00 sec)
[4 Mar 2010 14:27] Alexey Botchkov
I used mysql-next-mr-bugfixing
[4 Mar 2010 15:53] Sveta Smirnova
Thank you for the report.

Verified as described:

Thread 1 (process 19191):
#0  0x0000003429e0b002 in pthread_kill () from /lib64/libpthread.so.0
#1  0x0000000000b55b15 in my_write_core (sig=6) at stacktrace.c:326
#2  0x000000000068fc1c in handle_segfault (sig=6) at mysqld.cc:2749
#3  <signal handler called>
#4  0x0000003429230015 in raise () from /lib64/libc.so.6
#5  0x0000003429231980 in abort () from /lib64/libc.so.6
#6  0x0000003429229726 in __assert_fail () from /lib64/libc.so.6
#7  0x00000000006f1912 in get_table_share (thd=0x1fa6c908, table_list=0x1fafcd88, key=0x40a7fdb0 "test", key_length=8, db_flags=8192, error=0x40a7ff74, hash_value=1096967734) at sql_base.cc:478
#8  0x00000000006f1cc2 in get_table_share_with_create (thd=0x1fa6c908, table_list=0x1fafcd88, key=0x40a7fdb0 "test", key_length=8, db_flags=8192, error=0x40a7ff74, hash_value=1096967734)
    at sql_base.cc:580
#9  0x00000000006f6387 in open_table (thd=0x1fa6c908, table_list=0x1fafcd88, mem_root=0x40a800f0, ot_ctx=0x40a80130, flags=64) at sql_base.cc:2714
#10 0x00000000006f8d8e in open_and_process_table (thd=0x1fa6c908, lex=0x1fa6e180, tables=0x1fafcd88, counter=0x40a8024c, flags=64, prelocking_strategy=0x40a80290, has_prelocking_list=false, 
    ot_ctx=0x40a80130, new_frm_mem=0x40a800f0) at sql_base.cc:4192
#11 0x00000000006f98a3 in open_tables (thd=0x1fa6c908, start=0x40a80210, counter=0x40a8024c, flags=64, prelocking_strategy=0x40a80290) at sql_base.cc:4591
#12 0x00000000006fa6f4 in open_and_lock_tables (thd=0x1fa6c908, tables=0x1fafb460, derived=false, flags=64, prelocking_strategy=0x40a80290) at sql_base.cc:5185
#13 0x00000000006a074d in flush_tables_with_read_lock (thd=0x1fa6c908, all_tables=0x1fafb460) at sql_parse.cc:1668
#14 0x00000000006a650d in mysql_execute_command (thd=0x1fa6c908) at sql_parse.cc:3844
#15 0x00000000006aafcd in mysql_parse (thd=0x1fa6c908, inBuf=0x1fafb378 "FLUSH TABLES v1 WITH READ LOCK", length=30, found_semicolon=0x40a81e90) at sql_parse.cc:5710
#16 0x000000000069ee58 in dispatch_command (command=COM_QUERY, thd=0x1fa6c908, packet=0x1faf33a9 "FLUSH TABLES v1 WITH READ LOCK", packet_length=30) at sql_parse.cc:1024
#17 0x000000000069e13b in do_command (thd=0x1fa6c908) at sql_parse.cc:710
#18 0x000000000069c3f2 in do_handle_one_connection (thd_arg=0x1fa6c908) at sql_connect.cc:1174
#19 0x000000000069c29e in handle_one_connection (arg=0x1fa6c908) at sql_connect.cc:1113
#20 0x0000000000b29b74 in pfs_spawn_thread (arg=0x1fabcf78) at pfs.cc:1011
#21 0x0000003429e061b5 in start_thread () from /lib64/libpthread.so.0
#22 0x00000034292cd39d in clone () from /lib64/libc.so.6
#23 0x0000000000000000 in ?? ()
[9 Mar 2010 22:27] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/102792

3122 Konstantin Osipov	2010-03-10
      A fix and a test case for Bug#Bug#51710 FLUSH TABLES <view> WITH READ LOCK 
      kills the server.
      
      Prohibit FLUSH TABLES WITH READ LOCK application to views.
      Test that temporary tables work.
[10 Mar 2010 14:06] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/102891

3122 Konstantin Osipov	2010-03-10
      A fix and a test case for Bug#51710 FLUSH TABLES <view> WITH READ LOCK 
      kills the server.
      
      Prohibit FLUSH TABLES WITH READ LOCK application to views or
      temporary tables.
      Fix a subtle bug in the implementation when we actually
      did not remove table share objects from the table cache after 
      acquiring exclusive locks.
     @ mysql-test/r/flush.result
        Update results (Bug#51710)
     @ mysql-test/t/flush.test
        Add a test case for Bug#51710.
[10 Mar 2010 14:36] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/102895

3122 Konstantin Osipov	2010-03-10
      A fix and a test case for Bug#51710 FLUSH TABLES <view> WITH READ
      LOCK kills the server.
      
      Prohibit FLUSH TABLES WITH READ LOCK application to views or
      temporary tables.
      Fix a subtle bug in the implementation when we actually
      did not remove table share objects from the table cache after 
      acquiring exclusive locks.
     @ mysql-test/r/flush.result
        Update results (Bug#51710)
     @ mysql-test/t/flush.test
        Add a test case for Bug#51710.
     @ sql/sql_parse.cc
        Fix Bug#51710 "FLUSH TABLES <view> WITH READ LOCK
        killes the server.
        Ensure we don't open views and temporary tables.
        Fix a yet another bug in the implementation which 
        did not actually remove the tables from cache after acquiring
        exclusive locks.
[10 Mar 2010 14:36] Konstantin Osipov
Pushed into next-4284. No changelog entry is necessary since the bug
is not present in any public release.
[12 Mar 2010 18:10] Bugs System
Pushed into 6.0.14-alpha (revid:alik@sun.com-20100312180926-0emfjrj8e9xnvl8h) (version source revid:alik@sun.com-20100312180447-2r0ak22y13s05134) (merge vers: 6.0.14-alpha) (pib:16)
[12 Mar 2010 18:11] Bugs System
Pushed into mysql-next-mr (revid:alik@sun.com-20100312180838-rk60kn38g0qwt78n) (version source revid:alik@sun.com-20100312180435-wk7nvsbfntfus5bu) (pib:16)
[12 Mar 2010 18:22] Bugs System
Pushed into 5.5.3-m3 (revid:alik@sun.com-20100312181131-0b7v8r2htpd9jz2a) (version source revid:alik@sun.com-20100312181131-0b7v8r2htpd9jz2a) (merge vers: 5.5.3-m3) (pib:16)
[14 Mar 2010 0:42] Paul DuBois
No changelog entry needed.