Bug #865 Connections to MySQL are sometimes strange interrupted
Submitted: 17 Jul 2003 9:14 Modified: 1 Aug 2003 6:29
Reporter: Dariusz Jackowski Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:4.0.13 OS:FreeBSD (FreeBSD 4.8-RELEASE)
Assigned to: CPU Architecture:Any

[17 Jul 2003 9:14] Dariusz Jackowski
Description:
MySQL was upgraded from 3.23.56 to 4.0.13, and then started problems. PHP scripts, which do mysql_connect(), return error number 1045:

Access denied for user: 'root@localhost' (Using password: NO)

Function is used as: mysql_connect("localhost", "user", "pass"); user is not "root", and password IS defined.

I finded out, bug with ID: 398
http://bugs.mysql.com/bug.php?id=398

It's similar. But we have MySQL with LinuxThreads, and it's not TCP/IP stack problem, because connection is prepared by UNIX socket.

How to repeat:
It's rather hard to find it from PHP. It shows about 7-15 times per day. Server is not shutdowned, or killed.

Log-in to database using command 'mysql'. Wait some time (it's random time, from 3m to 3h). Try to do query, like:

mysql> SELECT * FROM example;
ERROR:

Try to do another query:

mysql> SELECT * FROM example;
ERROR 2006: MySQL server has gone away
No connection. Trying to reconnect...
Connection id:    136725
Current database: example

+---------+
| example |
+---------+
|       1 |
|       2 |
+---------+
2 rows in set (0.01 sec)

Suggested fix:
I traced MySQL client. I logged to database, waited some time, and tried select * from tmp, and got just error without code or description. Most interesting part IMHO is "Broken pipe":

 61025 mysql    RET   read 1
 61025 mysql    CALL  write(0x1,0x808e000,0x12)
 61025 mysql    GIO   fd 1 wrote 18 bytes
       "select * from tmp;"
 61025 mysql    RET   write 18/0x12
 61025 mysql    CALL  sigprocmask(0x1,0,0x806db1c)
 61025 mysql    RET   sigprocmask 0
 61025 mysql    CALL  read(0,0xbfbffa8f,0x1)
 61025 mysql    GIO   fd 0 read 1 byte
       "\r"
 61025 mysql    RET   read 1
 61025 mysql    CALL  write(0x1,0x808e000,0x1)
 61025 mysql    GIO   fd 1 wrote 1 byte
       "
       "
 61025 mysql    RET   write 1
 61025 mysql    CALL  sigprocmask(0x1,0x806d5a0,0x806d5b0)
 61025 mysql    RET   sigprocmask 0
 61025 mysql    CALL  ioctl(0,TIOCSETAW,0x806d5e0)
 61025 mysql    RET   ioctl 0
 61025 mysql    CALL  sigprocmask(0x3,0x806d5b0,0)
 61025 mysql    RET   sigprocmask 0
 61025 mysql    CALL  sigaction(0x2,0x806d768,0xbfbffae8)
 61025 mysql    RET   sigaction 0
 61025 mysql    CALL  sigaction(0xf,0x806d780,0xbfbffae8)
 61025 mysql    RET   sigaction 0
 61025 mysql    CALL  sigaction(0x3,0x806d7b0,0xbfbffae8)
 61025 mysql    RET   sigaction 0
 61025 mysql    CALL  sigaction(0xe,0x806d798,0xbfbffae8)
 61025 mysql    RET   sigaction 0
 61025 mysql    CALL  sigaction(0x12,0x806d7c8,0xbfbffae8)
 61025 mysql    RET   sigaction 0
 61025 mysql    CALL  sigaction(0x16,0x806d7e0,0xbfbffae8)
 61025 mysql    RET   sigaction 0
 61025 mysql    CALL  sigaction(0x15,0x806d7f8,0xbfbffae8)
 61025 mysql    RET   sigaction 0
 61025 mysql    CALL  sigaction(0x1c,0x806d810,0xbfbffae8)
 61025 mysql    RET   sigaction 0
 61025 mysql    CALL  getrusage(0,0xbfbff938)
 61025 mysql    RET   getrusage 0
 61025 mysql    CALL  getrusage(0xffffffff,0xbfbff938)
 61025 mysql    RET   getrusage 0
 61025 mysql    CALL  gettimeofday(0xbfbff930,0)
 61025 mysql    RET   gettimeofday 0
 61025 mysql    CALL  fcntl(0x3,0x4,0x6)
 61025 mysql    RET   fcntl 0
 61025 mysql    CALL  readv(0x3,0xbfbff8e0,0x2)
 61025 mysql    GIO   fd 3 read 0 bytes
       ""
 61025 mysql    RET   readv 0
 61025 mysql    CALL  fcntl(0x3,0x4,0x2)
 61025 mysql    RET   fcntl 0
 61025 mysql    CALL  write(0x3,0x8076000,0x16)
 61025 mysql    RET   write -1 errno 32 Broken pipe
 61025 mysql    CALL  shutdown(0x3,0x2)
 61025 mysql    RET   shutdown 0
 61025 mysql    CALL  close(0x3)
 61025 mysql    RET   close 0
 61025 mysql    CALL  write(0x1,0x808e000,0x9)
 61025 mysql    GIO   fd 1 wrote 9 bytes
       "\aERROR:
       "
 61025 mysql    RET   write 9
 61025 mysql    CALL  write(0x1,0x808e000,0x1)
 61025 mysql    GIO   fd 1 wrote 1 byte
       "
       "
 61025 mysql    RET   write 1
 61025 mysql    CALL  sigprocmask(0x1,0x806d5a0,0x806d5b0)
 61025 mysql    RET   sigprocmask 0
 61025 mysql    CALL  ioctl(0,TIOCGWINSZ,0xbfbffa38)
 61025 mysql    RET   ioctl 0
 61025 mysql    CALL  ioctl(0,TIOCSWINSZ,0xbfbffa38)
 61025 mysql    RET   ioctl 0
 61025 mysql    CALL  ioctl(0,TIOCGETA,0xbfbffab4)
 61025 mysql    RET   ioctl 0
 61025 mysql    CALL  ioctl(0,TIOCSETAW,0xbfbffab4)
 61025 mysql    RET   ioctl 0
 61025 mysql    CALL  sigprocmask(0x3,0x806d5b0,0)
 61025 mysql    RET   sigprocmask 0
 61025 mysql    CALL  sigaction(0x2,0xbfbffa48,0x806d768)
 61025 mysql    RET   sigaction 0
 61025 mysql    CALL  sigaction(0xf,0xbfbffa38,0x806d780)
 61025 mysql    RET   sigaction 0
 61025 mysql    CALL  sigaction(0x3,0xbfbffa48,0x806d7b0)
 61025 mysql    RET   sigaction 0
 61025 mysql    CALL  sigaction(0xe,0xbfbffa98,0x806d798)
 61025 mysql    RET   sigaction 0
 61025 mysql    CALL  sigaction(0x12,0xbfbffa48,0x806d7c8)
 61025 mysql    RET   sigaction 0
 61025 mysql    CALL  sigaction(0x16,0xbfbffa38,0x806d7e0)
 61025 mysql    RET   sigaction 0
 61025 mysql    CALL  sigaction(0x15,0xbfbffa48,0x806d7f8)
 61025 mysql    RET   sigaction 0
 61025 mysql    CALL  sigaction(0x1c,0xbfbffa48,0x806d810)
 61025 mysql    RET   sigaction 0
 61025 mysql    CALL  write(0x1,0x808e000,0x7)
 61025 mysql    GIO   fd 1 wrote 7 bytes
       "mysql> "
 61025 mysql    RET   write 7
 61025 mysql    CALL  sigprocmask(0x1,0,0x806db1c)
 61025 mysql    RET   sigprocmask 0
 61025 mysql    CALL  read(0,0xbfbffa8f,0x1)
 61025 mysql    GIO   fd 0 read 1 byte
       "\^["
 61025 mysql    RET   read 1
 61025 mysql    CALL  read(0,0xbfbffa5f,0x1)
 61025 mysql    GIO   fd 0 read 1 byte
       "["
 61025 mysql    RET   read 1
 61025 mysql    CALL  read(0,0xbfbffa2f,0x1)
 61025 mysql    GIO   fd 0 read 1 byte
       "A"
 61025 mysql    RET   read 1
 61025 mysql    CALL  write(0x1,0x808e000,0x12)
 61025 mysql    GIO   fd 1 wrote 18 bytes
       "select * from tmp;"
 61025 mysql    RET   write 18/0x12
 61025 mysql    CALL  sigprocmask(0x1,0,0x806db1c)
 61025 mysql    RET   sigprocmask 0
 61025 mysql    CALL  read(0,0xbfbffa8f,0x1)
 61025 mysql    GIO   fd 0 read 1 byte
       "\r"
 61025 mysql    RET   read 1
 61025 mysql    CALL  write(0x1,0x808e000,0x1)
 61025 mysql    GIO   fd 1 wrote 1 byte
       "
       "
 61025 mysql    RET   write 1
 61025 mysql    CALL  sigprocmask(0x1,0x806d5a0,0x806d5b0)
 61025 mysql    RET   sigprocmask 0
 61025 mysql    CALL  ioctl(0,TIOCSETAW,0x806d5e0)
 61025 mysql    RET   ioctl 0
 61025 mysql    CALL  sigprocmask(0x3,0x806d5b0,0)
 61025 mysql    RET   sigprocmask 0
 61025 mysql    CALL  sigaction(0x2,0x806d768,0xbfbffae8)
 61025 mysql    RET   sigaction 0
 61025 mysql    CALL  sigaction(0xf,0x806d780,0xbfbffae8)
 61025 mysql    RET   sigaction 0
 61025 mysql    CALL  sigaction(0x3,0x806d7b0,0xbfbffae8)
 61025 mysql    RET   sigaction 0
 61025 mysql    CALL  sigaction(0xe,0x806d798,0xbfbffae8)
 61025 mysql    RET   sigaction 0
 61025 mysql    CALL  sigaction(0x12,0x806d7c8,0xbfbffae8)
 61025 mysql    RET   sigaction 0
 61025 mysql    CALL  sigaction(0x16,0x806d7e0,0xbfbffae8)
 61025 mysql    RET   sigaction 0
 61025 mysql    CALL  sigaction(0x15,0x806d7f8,0xbfbffae8)
 61025 mysql    RET   sigaction 0
 61025 mysql    CALL  sigaction(0x1c,0x806d810,0xbfbffae8)
 61025 mysql    RET   sigaction 0
 61025 mysql    CALL  getrusage(0,0xbfbff938)
 61025 mysql    RET   getrusage 0
 61025 mysql    CALL  getrusage(0xffffffff,0xbfbff938)
 61025 mysql    RET   getrusage 0
 61025 mysql    CALL  gettimeofday(0xbfbff930,0)
 61025 mysql    RET   gettimeofday 0
 61025 mysql    CALL  write(0x2,0xbfbff268,0xc)
 61025 mysql    GIO   fd 2 wrote 12 bytes
       "ERROR 2006: "
 61025 mysql    RET   write 12/0xc
 61025 mysql    CALL  write(0x1,0x808e000,0x1c)
 61025 mysql    GIO   fd 1 wrote 28 bytes
       "\aMySQL server has gone away
       "
 61025 mysql    RET   write 28/0x1c
 61025 mysql    CALL  write(0x1,0x808e000,0x26)
 61025 mysql    GIO   fd 1 wrote 38 bytes
       "No connection. Trying to reconnect...
       "
 61025 mysql    RET   write 38/0x26
 61025 mysql    CALL  socket(0x1,0x1,0)
 61025 mysql    RET   socket 3
 61025 mysql    CALL  fcntl(0x3,0x3,0xbfbfebb0)
 61025 mysql    RET   fcntl 2
 61025 mysql    CALL  connect(0x3,0xbfbff620,0x6a)
 61025 mysql    NAMI  "/dev/mysql"
 61025 mysql    RET   connect 0
 61025 mysql    CALL  setsockopt(0x3,0xffff,0x8,0xbfbfebac,0x4)
 61025 mysql    RET   setsockopt 0
 61025 mysql    CALL  readv(0x3,0xbfbfeae0,0x2)
[1 Aug 2003 6:20] Boyd Gerber
I have tried to duplicate the problem but I was unsuccessful.  My FreeBSB 4.8 had all the patches installed.  This may be an OS/patch related problem.  Please make sure you have all the patches/updates installed.
[1 Aug 2003 6:29] Boyd Gerber
Not enough information was provided for us to be able
to handle this bug. Please re-read the instructions at
http://bugs.mysql.com/how-to-report.php

If you can provide more information, feel free to add it
to this bug and change the status back to 'Open'.

Thank you for your interest in MySQL.

I was unable to reproduce the problem.  Could you please make sure every thing is up to date.  I also recommend you upgrade to 4.0.14.