Bug #11337 Check table for two views crashes server
Submitted: 15 Jun 2005 3:24 Modified: 7 Jul 2005 16:07
Reporter: James Day Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S1 (Critical)
Version:5.0.6 OS:Linux (RHEL AS2.1, Windows XP)
Assigned to: Oleksandr Byelkin CPU Architecture:Any

[15 Jun 2005 3:24] James Day
Description:
Server crashes with the following sequence, reported by customer on Red Hat Enterprise Linux AS2.1, reproduced on Windows.

mysql> CREATE TABLE t1 (col1 integer) ENGINE=InnoDB;
Query OK, 0 rows affected (0.16 sec)

mysql> CREATE TABLE t2 (col1 integer) ENGINE=InnoDB;
Query OK, 0 rows affected (0.11 sec)

mysql> CREATE OR REPLACE VIEW v1 AS SELECT col1 FROM t1;
Query OK, 0 rows affected (0.01 sec)

mysql> CREATE OR REPLACE VIEW v2 AS SELECT col1 FROM t2;
Query OK, 0 rows affected (0.02 sec)

mysql>
mysql> -- Check views
mysql> CHECK TABLE v1, v2;
+---------+-------+----------+----------+
| Table   | Op    | Msg_type | Msg_text |
+---------+-------+----------+----------+
| test.v1 | check | status   | OK       |
| test.v2 | check | status   | OK       |
+---------+-------+----------+----------+
2 rows in set (0.01 sec)

mysql>
mysql> -- OK, they exist
mysql>
mysql> DROP TABLE t1;
Query OK, 0 rows affected (0.04 sec)

mysql> CHECK TABLE v1;
+---------+-------+----------+--------------------------------------------------
----------------------+
| Table   | Op    | Msg_type | Msg_text
                      |
+---------+-------+----------+--------------------------------------------------
----------------------+
| test.v1 | check | error    | View 'test.v1' references invalid table(s) or col
umn(s) or function(s) |
+---------+-------+----------+--------------------------------------------------
----------------------+
1 row in set (0.01 sec)

mysql>
mysql> -- got the expected error
mysql>
mysql> CHECK TABLE v2;
+---------+-------+----------+----------+
| Table   | Op    | Msg_type | Msg_text |
+---------+-------+----------+----------+
| test.v2 | check | status   | OK       |
+---------+-------+----------+----------+
1 row in set (0.00 sec)

mysql> -- got the expected success
mysql> CHECK TABLE v1, v2;
ERROR 2013 (HY000): Lost connection to MySQL server during query

===================

Replacing InnoDB with MyISAM, the crash happens earlier:

mysql> CREATE TABLE t1 (col1 integer) ENGINE=MyISAM;
Query OK, 0 rows affected (0.15 sec)

mysql> CREATE TABLE t2 (col1 integer) ENGINE=MyISAM;
Query OK, 0 rows affected (0.10 sec)

mysql> CREATE OR REPLACE VIEW v1 AS SELECT col1 FROM t1;
Query OK, 0 rows affected (0.01 sec)

mysql> CREATE OR REPLACE VIEW v2 AS SELECT col1 FROM t2;
Query OK, 0 rows affected (0.01 sec)

mysql>
mysql> -- Check views
mysql> CHECK TABLE v1, v2;
ERROR 2013 (HY000): Lost connection to MySQL server during query

How to repeat:
CREATE TABLE t1 (col1 integer) ENGINE=InnoDB;
CREATE TABLE t2 (col1 integer) ENGINE=InnoDB;
CREATE OR REPLACE VIEW v1 AS SELECT col1 FROM t1;
CREATE OR REPLACE VIEW v2 AS SELECT col1 FROM t2;

-- Check views
CHECK TABLE v1, v2;

-- OK, they exist

DROP TABLE t1;
CHECK TABLE v1;

-- got the expected error

CHECK TABLE v2;

-- got the expected success

CHECK TABLE v1, v2;

-- server crashes
-- ERROR 2013 (HY000): Lost connection to MySQL server during query
[18 Jun 2005 18:34] Oleksandr Byelkin
I got crash even early:
mysql> CREATE TABLE t1 (col1 integer) ENGINE=InnoDB;
Query OK, 0 rows affected, 1 warning (0.01 sec)

mysql> CREATE TABLE t2 (col1 integer) ENGINE=InnoDB;
Query OK, 0 rows affected, 1 warning (0.01 sec)

mysql> CREATE OR REPLACE VIEW v1 AS SELECT col1 FROM t1;
Query OK, 0 rows affected (0.00 sec)

mysql> CREATE OR REPLACE VIEW v2 AS SELECT col1 FROM t2;
Query OK, 0 rows affected (0.00 sec)

mysql> CHECK TABLE v1, v2;
ERROR 2013 (HY000): Lost connection to MySQL server during query
mysql>
[22 Jun 2005 7:48] 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/internals/26276
[25 Jun 2005 8:26] 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/internals/26424
[5 Jul 2005 10: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/internals/26672
[5 Jul 2005 13:04] Oleksandr Byelkin
pushed to 5.0.9
[7 Jul 2005 16:07] Jon Stephens
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at
    http://www.mysql.com/doc/en/Installing_source_tree.html

Additional info:

Documented bugfix in 5.0.9 change history; closed.