Bug #18002 GRANT Hangs on amd64
Submitted: 6 Mar 2006 23:28 Modified: 9 Apr 2006 12:49
Reporter: Christian Hammers (Silver Quality Contributor) (OCA) Email Updates:
Status: No Feedback Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.0 from mysql.com OS:Linux (Debian Sarge)
Assigned to: CPU Architecture:Any

[6 Mar 2006 23:28] Christian Hammers
Description:
Hello

The following Query just 'hangs' when using MySQL (either the Debian Backport or the debugging binary from www.mysql.com) 5.0 on AMD64.

As it is no crash and the server is still responsible for other queries, I don't know how to create a backtrace.

bye,

-christian-

How to repeat:
# uname -r
2.6.14-2-amd64-k8-smp

# uname -m
x86_64

Use a freshly installed MySQL server and pipe the following through "/usr/bin/mysql" (its from "Horde3"):

app109:/usr/share/doc/horde3/examples/scripts/sql# zcat create.mysql.sql.gz | mysql -v 
--------------
REPLACE INTO user (host, user, password)
    VALUES (
        'localhost',
        'horde',
        PASSWORD('horde')
)
--------------

--------------
REPLACE INTO db (host, db, user, select_priv, insert_priv, update_priv,
                 delete_priv, create_priv, drop_priv, index_priv)
    VALUES (
        'localhost',
        'horde',
        'horde',
        'Y', 'Y', 'Y', 'Y',
        'Y', 'Y', 'Y'
)
--------------

--------------
FLUSH PRIVILEGES
--------------

--------------
CREATE DATABASE horde
--------------

--------------
CREATE TABLE horde_users (
    user_uid       VARCHAR(255) NOT NULL,
    user_pass      VARCHAR(32) NOT NULL,
    PRIMARY KEY (user_uid)
)
--------------

--------------
GRANT SELECT, INSERT, UPDATE, DELETE ON horde_users TO horde@localhost
--------------

#### Here it hangs. After ctrl-c: 

mysql> SHOW PROCESSLIST;
+----+------+-----------+-------+---------+------+-------+------------------------------------------------------------------------+
| Id | User | Host      | db    | Command | Time | State | Info                                                                   |
+----+------+-----------+-------+---------+------+-------+------------------------------------------------------------------------+
|  4 | root | localhost | horde | Query   |   57 | NULL  | GRANT SELECT, INSERT, UPDATE, DELETE ON horde_users TO horde@localhost |
| 28 | root | localhost | NULL  | Query   |    0 | NULL  | SHOW PROCESSLIST                                                       |
+----+------+-----------+-------+---------+------+-------+------------------------------------------------------------------------+
2 rows in set (0.01 sec)

Suggested fix:
...
[9 Mar 2006 9:45] Mickael Marchand
just want to add that I can fully reproduce this bug on my servers
I tried it on 3 differents machines (different hardware).
(including em64t and amd64)

basically it makes mysql 5.0 unusable in production.
I hope you will be able to fix it soon :)

I am okay to test patches if you have some.

btw, it's not 'GRANT' specific, I have a simple PHP application that does simple INSERT which locks up mysqld quite often.
[9 Mar 2006 12:49] Valeriy Kravchuk
Thank you for a problem report. Is this problem repeatable on non-SMP systems? With GRANTs instead of direct manipulation with db and user tables? And usual question: what threading library is used? Just to be sure.
[9 Mar 2006 14:43] Mickael Marchand
I just rebooted my em64t test box in non-hyperthreading mode so I can test without SMP
it seems to work a lot better. I just loaded+dropped the horde db 5 times without any glitches.
this machine is running a 2.6.15, and mysqld is linked against libpthread (I don't really know how to tell which threading library it's using ...) (it's Debian's mysql-server-5.0 backport to sarge-amd64)

to not confuse you : I am the one who reported the problem to Debian's maintainer, so that's why I am answering here now :)

thanks
[21 Mar 2006 23:03] Mickael Marchand
after some discussion with other debian developers, I was pointed to this bug :
http://bugs.mysql.com/bug.php?id=8555
and to the Debian specific one.
I have patched my libc6 since and it does not seem to lock up anymore, so I guess this is just the same bug.

I guess that bug can be closed but maybe Chritian has more comments to do.

thanks

Cheers,
Mik
[22 Mar 2006 7:55] Alessandro Polverini
I had a similar problem on my machines: a web site running joomla was hanging with too many users.
After a lot of (unuseful) test I migrated on a 32bit machine running the same version of mysql (5.0.18-4) and the problem was the same.
There was hundreds of "sleeping" threads on mysql.

I had to downgrade to mysql 4.1 to solve the problem.

HTH,
Alex
[9 Apr 2006 23:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
[8 Jul 2006 10:30] [ name withheld ]
Can reproduce this on Linux 2.6.8-11-amd64-k8 x86_64 (Debian/AMD64 3.0 stable). GRANT hangs mysqld completely (quite often, but not always); in this case, you can't connect to the daemon, i.e. even shutdown doesn't work and I have to SIGKILL all mysqld processes.

Sometimes the INSERT command locks up mysqld, but then I can connect at least and send "SHOW PROCESSLIST" which shows up a long list of commands in the "Locked" state (the first is "querying").

I'm using MySQL-5.0.22-Debian_1bpo1-log from the backports.

This is a big problem for me because it makes MySQL 5.0 unusable for me. I need >= 5.0 because I need UTF-8 and other features which are only available for 5.0 and newer.

I used MySQL 5.0.21 on a FreeBSD machine (FreeBSD/5.3-RELEASE-p29 i386) before where everything worked perfectly! Then I had to migrate to another machine and here MySQL makes problems ... :/
[12 Nov 2006 15:12] Arkadiusz Miskiewicz
For me mysqld 5.0.27 hangs sometimes - unfortunately I can't check if this happens on grant command because when it hangs I can't even connect to it - connection hangs. Even kill -TERM doesn't work. I need to use -9.

Not sure if these bugs are related but it's quite possible (grant commands are issued quite often from admin panel).

This is on linux 2.6.16.27 smp x86_64.