Bug #53345 SET @foo=(SELECT max(a) FROM t1), GLOBAL read_only=1 hangs
Submitted: 1 May 2010 12:00 Modified: 12 Jul 2012 14:40
Reporter: Konstantin Osipov (OCA) Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server: Locking Severity:S3 (Non-critical)
Version:5.1+ OS:Any
Assigned to: Jon Olav Hauglid CPU Architecture:Any

[1 May 2010 12:00] Konstantin Osipov
Description:
set  @foo=(select max(a) from t1), global read_only=1; hangs.

In other words, an attempt to use expressions that use tables in multi-variable set that assigns the global read_only variable hangs.

The setting of global read_only causes an implicit commit, and this is apparently the source of the trouble.

How to repeat:
mysql> create table t1 (a varchar(25));
Query OK, 0 rows affected (0.05 sec)

mysql> insert into t1 (a) values ("value");
Query OK, 1 row affected (0.00 sec)

mysql> set  @foo=(select max(a) from t1), global read_only=1;
[1 May 2010 12:03] Konstantin Osipov
I'm using 5.5.
[1 May 2010 16:07] MySQL Verification Team
First test with 5.1 crashes!

mysql> show variables like "%version%";
+-------------------------+---------------------+
| Variable_name           | Value               |
+-------------------------+---------------------+
| protocol_version        | 10                  |
| version                 | 5.1.47-debug        |
| version_comment         | Source distribution |
| version_compile_machine | x86_64              |
| version_compile_os      | unknown-linux-gnu   |
+-------------------------+---------------------+
5 rows in set (0.00 sec)

mysql> create table t1 (a varchar(25));
Query OK, 0 rows affected (0.06 sec)

mysql> insert into t1 (a) values ("value");
Query OK, 1 row affected (0.00 sec)

mysql> set  @foo=(select max(a) from t1), global read_only=1;
ERROR 2013 (HY000): Lost connection to MySQL server during query
mysql> 

Version: '5.1.47-debug'  socket: '/tmp/mysql.sock'  port: 3306  Source distribution
100501 13:06:24 - mysqld got signal 11 ;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.
We will try our best to scrape up some info that will hopefully help diagnose
the problem, but since we have already crashed, something is definitely wrong
and this may fail.

key_buffer_size=8384512
read_buffer_size=131072
max_used_connections=1
max_threads=151
threads_connected=1                                                                                                                                                
It is possible that mysqld could use up to 
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 338309 K
bytes of memory
Hope that's ok; if not, decrease some variables in the equation.

thd: 0x2d2a738
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
stack_bottom = 0x7fa15f697e98 thread_stack 0x40000
dbs/5.1/libexec/mysqld(my_print_stacktrace+0x35)[0xb7046b]
dbs/5.1/libexec/mysqld(handle_segfault+0x288)[0x6c5f2c]
/lib/libpthread.so.0(+0xf8f0)[0x7fa163aa78f0]
dbs/5.1/libexec/mysqld(_Z16mysql_lock_mergeP13st_mysql_lockS0_+0x52)[0x6bdc00]
dbs/5.1/libexec/mysqld(_Z13reopen_tablesP3THDbb+0x51f)[0x729d88]
dbs/5.1/libexec/mysqld(_Z19close_cached_tablesP3THDP10TABLE_LISTbbb+0x43e)[0x723d2d]
dbs/5.1/libexec/mysqld(_ZN20sys_var_opt_readonly6updateEP3THDP7set_var+0x17b)[0x6f0b0f]
dbs/5.1/libexec/mysqld(_ZN7set_var6updateEP3THD+0x77)[0x6ef2dd]
dbs/5.1/libexec/mysqld(_Z17sql_set_variablesP3THDP4ListI12set_var_baseE+0x10a)[0x6eed64]
dbs/5.1/libexec/mysqld(_Z21mysql_execute_commandP3THD+0x446b)[0x6dc7ff]
dbs/5.1/libexec/mysqld(_Z11mysql_parseP3THDPKcjPS2_+0x2bf)[0x6e4150]
dbs/5.1/libexec/mysqld(_Z16dispatch_command19enum_server_commandP3THDPcj+0xd2d)[0x6d650a]
dbs/5.1/libexec/mysqld(_Z10do_commandP3THD+0x27e)[0x6d54e6]
dbs/5.1/libexec/mysqld(handle_one_connection+0x14e)[0x6d37e1]
/lib/libpthread.so.0(+0x69ca)[0x7fa163a9e9ca]
/lib/libc.so.6(clone+0x6d)[0x7fa162f2269d]
Trying to get some variables.
Some pointers may be invalid and cause the dump to abort...
thd->query at 0x2d367e8 = set  @foo=(select max(a) from t1), global read_only=1
thd->thread_id=2
thd->killed=NOT_KILLED
The manual page at http://dev.mysql.com/doc/mysql/en/crashing.html contains
information that should help you find out what is causing the crash.
miguel@tikal:~$
[1 May 2010 16:25] MySQL Verification Team
5.1 crashes 5.6 hangs:

miguel@tikal:~$ dbs/5.5-mr/bin/mysql -uroot test
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.99-m4-debug Source distribution

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

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

mysql> create table t1 (a varchar(25));
Query OK, 0 rows affected (0.06 sec)

mysql> insert into t1 (a) values ("value");
Query OK, 1 row affected (0.00 sec)

mysql> set  @foo=(select max(a) from t1), global read_only=1;

Verified on Ubuntu 10.04 X86_64:

miguel@tikal:~$ dbs/5.5-mr/bin/mysql -uroot test
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.99-m4-debug Source distribution

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

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

mysql> create table t1 (a varchar(25));
Query OK, 0 rows affected (0.06 sec)

mysql> insert into t1 (a) values ("value");
Query OK, 1 row affected (0.00 sec)

mysql> set  @foo=(select max(a) from t1), global read_only=1;
[12 Jul 2012 14:40] Jon Olav Hauglid
Fixed in 5.6.