Bug #15608 5.0.16 Crashing on AMD64 when querying a view that has UNIONS in it.
Submitted: 8 Dec 2005 23:25 Modified: 9 Dec 2005 13:05
Reporter: Timothy Havens Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server Severity:S1 (Critical)
Version:5.0.16 OS:Linux (Suse 9.1)
Assigned to: CPU Architecture:Any

[8 Dec 2005 23:25] Timothy Havens
Description:
First of the this issue is on a Dual AMD64 Suse 9.1 machine.

I am trying to create two identical tables each in it's own database.  Then I create a third database into which is created a view of a (select * one.a) union (select * two.a).  

Next I want to query the new view with a 'select * from three.a' (my new view).

The First time it returns the results successfully.
The Second time with the same query FAILS and the Server restarts.
The Third time with the same query returns the results successfully.
The Forth time again same query FAILS and the Server restarts....etc...

I have tried the prepared MySQL binaries 5.0.16 for AMD64, and I have built my own from source for 5.0.16 and have the exact same failure.  When I built my own from source I included the --with-debug=full.

What can I do?  I'm stumped at this point.

I have tried this on Red Hat 9, and it works fine with 5.0.15.

How to repeat:
mysql> create database one
mysql> create table one.a (col1 int(4), col2 varchar(8));
mysql> insert into one.a (col1,col2) values (1,'test');

mysql> create database two;
mysql> create table two.a (col1 int(4), col2 varchar(8));
mysql> insert into two.a (col1,col2) values (1,'test');

mysql> create database three;
mysql> use three
mysql> create view three.a as (select *, 'one' from one.a) union (select *, 'two' from two.a);
mysql> select * from three.a;
+------+------+---+
| col1 | col2 | 1 |
+------+------+---+
|    1 | test | 1 |
|    1 | test | 2 |
+------+------+---+
2 rows in set (0.01 sec)

mysql> select * from a;
ERROR 2013 (HY000): Lost connection to MySQL server during query
mysql> select * from a;
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id:    28
Current database: three

+------+------+---+
| col1 | col2 | 1 |
+------+------+---+
|    1 | test | 1 |
|    1 | test | 2 |
+------+------+---+
2 rows in set (0.01 sec)

mysql> select * from a;
ERROR 2013 (HY000): Lost connection to MySQL server during query
mysql> select * from a;
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id:    34
Current database: three

+------+------+---+
| col1 | col2 | 1 |
+------+------+---+
|    1 | test | 1 |
|    1 | test | 2 |
+------+------+---+
2 rows in set (0.01 sec)

LOGS:

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=268435456
read_buffer_size=2093056
max_used_connections=205
max_connections=1000
threads_connected=192
It is possible that mysqld could use up to
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_connections = 4354108 K
bytes of memory
Hope that's ok; if not, decrease some variables in the equation.

Number of processes running now: 0
051208 22:52:32  mysqld restarted
051208 22:52:33 [Note] /usr/local/mysql/libexec/mysqld: ready for connections.
Version: '5.0.16-debug-log'  socket: '/tmp/mysql.sock'  port: 3306  Source distribution
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=268435456
read_buffer_size=2093056
max_used_connections=101
max_connections=1000
threads_connected=99
It is possible that mysqld could use up to
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_connections = 4354108 K
bytes of memory
Hope that's ok; if not, decrease some variables in the equation.

Number of processes running now: 0
051208 22:53:30  mysqld restarted
051208 22:53:31 [Note] /usr/local/mysql/libexec/mysqld: ready for connections.
Version: '5.0.16-debug-log'  socket: '/tmp/mysql.sock'  port: 3306  Source distribution
[9 Dec 2005 11:17] Valeriy Kravchuk
Thank you for a problem report. Because of that UNION-based view and crash on a second run only, I believe, it is a duplicate of bug #15516 (and some other similar reports). Please, check. 

Note, that this bug is not repeatable in 5.0.17 and later version, so it looks like a fixed already. Wait for the 5.0.17 to be officially released.
[9 Dec 2005 13:05] Timothy Havens
I have reverted to 5.0.13 and the bug is not there.  I will wait for 5.0.17+