Bug #64393 Lost connection causes infinite loop when reading rows
Submitted: 21 Feb 2012 10:17 Modified: 8 Aug 2012 4:48
Reporter: Geert Vanderkelen Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / Python Severity:S2 (Serious)
Version:0.3.2 OS:Any
Assigned to: Geert Vanderkelen CPU Architecture:Any

[21 Feb 2012 10:17] Geert Vanderkelen
Description:
When the connection is lost and a cursor still has unread result set, an infinite loop is triggered in the recv_plain() method.

How to repeat:
import time
import mysql.connector

def main():
    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()
[8 Aug 2012 4:48] Geert Vanderkelen
Fixed with Connector/Python v1.0.5 beta release.