Lost connection causes infinite loop

Bug #809033 reported by Daniel W. Levi
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
MySQL Connector/Python
Triaged
Critical
Geert JM Vanderkelen

Bug Description

If the connection to MySQL is lost, the connector goes into an infinite loop in recv_plain. By contrast, MySQLdb reports _mysql_exceptions.OperationalError: (2013, 'Lost connection to MySQL server during query')

To recreate:
1. In python, submit a query that returns a large data set (100K total bytes or 50,000 rows should be enough.)
2. Do nothing yet with the returned object. Instead, go to MySQL interface, and run SHOW PROCESSLIST every minute or so. Eventually, the query will go away when MySQL times out on a send.
3. Go back to python and try to use the rows.

Versions:

python -c "import mysql.connector as db; print db.__version__"
(0, 3, 2, 'devel', 292)

python --version
Python 2.7.1

mysql -NB -e "SELECT VERSION()"
5.1.30-community

uname -a
Linux xxxxx.xxxxx.com 2.6.18-164.el5 #1 SMP Tue Aug 18 15:51:48 EDT 2009 x86_64 x86_64 x86_64 GNU/Linux

Related branches

Changed in myconnpy:
assignee: nobody → Geert JM Vanderkelen (geertjmvdk)
Revision history for this message
Geert JM Vanderkelen (geertjmvdk) wrote :

Code to reproduce:

import time
import mysql.connector

def bug809033():
    cnx = mysql.connector.connect(user='root',database='test')
    cnx2 = mysql.connector.connect(user='root',database='mysql')

    cur = cnx.cursor()
    # Bad query
    cur.execute("SELECT * FROM mysql.time_zone AS t1 JOIN mysql.time_zone AS t2")

    cur2 = cnx2.cursor()
    cur2.execute("KILL %d" % cnx.connection_id)

    for row in cur:
        print(row)

    cur.close()
    cnx.close()
    cur2.close()
    cnx2.close()

Changed in myconnpy:
status: New → Confirmed
importance: Undecided → High
Changed in myconnpy:
importance: High → Critical
Changed in myconnpy:
status: Confirmed → Fix Committed
milestone: none → 0.4
Revision history for this message
Geert JM Vanderkelen (geertjmvdk) wrote :

This bug was moved to http://bugs.mysql.com/bug.php?id=64393

Please add comments or subscribe using the above URL.

Changed in myconnpy:
status: Fix Committed → Triaged
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.