Bug #37723 NAME_CONST() hangs forever, yet no query is running

Submitted: 29 Jun 2008 2:17 Modified: 30 Jun 2008 18:20
Reporter: Baron Schwartz (Basic Quality Contributor) Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:5.0.51a OS:Linux (5.0.51a-3ubuntu5.1-log)
Assigned to: CPU Architecture:Any

[29 Jun 2008 2:17] Baron Schwartz
Description:
A query with NAME_CONST appears to hang forever.  Another connection sees it as sleeping in the processlist.

How to repeat:
set @var := 0;
select actor_id, @var from sakila.actor where ((@var := @var + 1) <= name_const('foo', @var + 20)) and actor_id % 2 = 0 limit 20;

This hangs.

mysql> show full processlist\G
*************************** 1. row ***************************
     Id: 26
   User: baron
   Host: localhost
     db: NULL
Command: Query
   Time: 0
  State: NULL
   Info: show full processlist
*************************** 2. row ***************************
     Id: 27
   User: baron
   Host: localhost
     db: sakila
Command: Sleep
   Time: 167
  State: 
   Info: NULL
2 rows in set (0.00 sec)
[30 Jun 2008 5:03] Valeriy Kravchuk
Thank you for the problem report. Please, send the results of SHOW CREATE TABLE and SHOW TABLE STATUS for your sakila.actor table.
[30 Jun 2008 16:11] Baron Schwartz
mysql> show create table actor\G
*************************** 1. row ***************************
       Table: actor
Create Table: CREATE TABLE `actor` (
  `actor_id` smallint(5) unsigned NOT NULL auto_increment,
  `first_name` varchar(45) NOT NULL,
  `last_name` varchar(45) NOT NULL,
  `last_update` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
  PRIMARY KEY  (`actor_id`),
  KEY `idx_actor_last_name` (`last_name`)
) ENGINE=InnoDB AUTO_INCREMENT=201 DEFAULT CHARSET=utf8
1 row in set (0.01 sec)

mysql> show table status like 'actor'\G
*************************** 1. row ***************************
           Name: actor
         Engine: InnoDB
        Version: 10
     Row_format: Compact
           Rows: 200
 Avg_row_length: 81
    Data_length: 16384
Max_data_length: 0
   Index_length: 16384
      Data_free: 0
 Auto_increment: 201
    Create_time: 2008-06-19 12:50:02
    Update_time: NULL
     Check_time: NULL
      Collation: utf8_general_ci
       Checksum: NULL
 Create_options: 
        Comment: InnoDB free: 8192 kB
1 row in set (0.00 sec)
[30 Jun 2008 18:16] Valeriy Kravchuk
Sorry, but I can not repeat the behaviour described with a newer version, 5.0.52:

C:\Program Files\MySQL\MySQL Server 5.0\bin>mysql -uroot -proot -P3308 test
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 5.0.62-enterprise-gpl-nt MySQL Enterprise Server (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> CREATE TABLE `actor` (
    ->   `actor_id` smallint(5) unsigned NOT NULL auto_increment,
    ->   `first_name` varchar(45) NOT NULL,
    ->   `last_name` varchar(45) NOT NULL,
    ->   `last_update` timestamp NOT NULL default CURRENT_TIMESTAMP on update CU
RRENT_TIMESTAMP,
    ->   PRIMARY KEY  (`actor_id`),
    ->   KEY `idx_actor_last_name` (`last_name`)
    -> ) ENGINE=InnoDB;
Query OK, 0 rows affected (0.17 sec)

mysql> insert into actor (first_name, last_name) values ('Bruce', 'Lee');
Query OK, 1 row affected (0.03 sec)

mysql> insert into actor (first_name, last_name) select first_name, last_name fr
om actor;
Query OK, 1 row affected (0.39 sec)
Records: 1  Duplicates: 0  Warnings: 0

mysql> insert into actor (first_name, last_name) select first_name, last_name fr
om actor;
Query OK, 2 rows affected (0.03 sec)
Records: 2  Duplicates: 0  Warnings: 0

mysql> insert into actor (first_name, last_name) select first_name, last_name fr
om actor;
Query OK, 4 rows affected (0.39 sec)
Records: 4  Duplicates: 0  Warnings: 0

mysql> insert into actor (first_name, last_name) select first_name, last_name fr
om actor;
Query OK, 8 rows affected (0.03 sec)
Records: 8  Duplicates: 0  Warnings: 0

mysql> insert into actor (first_name, last_name) select first_name, last_name fr
om actor;
Query OK, 16 rows affected (0.03 sec)
Records: 16  Duplicates: 0  Warnings: 0

mysql> insert into actor (first_name, last_name) select first_name, last_name fr
om actor;
Query OK, 32 rows affected (0.03 sec)
Records: 32  Duplicates: 0  Warnings: 0

mysql> insert into actor (first_name, last_name) select first_name, last_name fr
om actor;
Query OK, 64 rows affected (0.05 sec)
Records: 64  Duplicates: 0  Warnings: 0

mysql> insert into actor (first_name, last_name) select first_name, last_name fr
om actor;
Query OK, 128 rows affected (0.03 sec)
Records: 128  Duplicates: 0  Warnings: 0

mysql> set @var := 0;
Query OK, 0 rows affected (0.00 sec)

mysql> select actor_id, @var from sakila.actor where ((@var := @var + 1) <= name
_const('foo',
    -> @var + 20)) and actor_id % 2 = 0 limit 20;
ERROR 1210 (HY000): Incorrect arguments to NAME_CONST

Please, check if something is wrong in my test case.
[30 Jun 2008 18:20] Baron Schwartz
Maybe it's arch-specific.  I'm on AMD64 Ubuntu.  I haven't tried the newer version.

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.053 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.