MySQLConnection.disconnect() fails on dead connection

Bug #752975 reported by tormen
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
MySQL Connector/Python
Confirmed
Medium
Geert JM Vanderkelen

Bug Description

MySQL Connector/Python version 0.3.2 with Python 3.2:

Within class MySQLConnection:

.connect() calls .disconnect() triggers a signal 13 if the connection is dead!
--> put a try: self.disconnect()
except: pass
in .connect() and .connect() works as the .reconnect() I wanted ... except that
my reconnect will check is_connected AND have a semaphore around the .connect()
call to avoid race conditions between multiple cursors :)

... and actually looking at .disconnect() the signal 13 originates from the call
"self.protocol.cmd_quit()".
If I move this line into the try block you already have in .disconnect, the
signal 13 does not happen and the try, except around the .disconnect() call
within .connect() are not necessary.

Side note: The patch also fixes a wrong indentation:
Line 453 in connection.py:
self.collation = collation
within:
def _post_connection(self, time_zone=None, autocommit=False,
shows invalid indenting in my eclipse.

Revision history for this message
tormen (quickhelp) wrote :
Revision history for this message
tormen (quickhelp) wrote :
Revision history for this message
Geert JM Vanderkelen (geertjmvdk) wrote :

Hey,

Thanks for reporting this bug!
I'm trying to reproduce this. If I understand the problem, if you kill the connection, you would get an error, right?
Something like this:

    cnx = mysql.connector.connect(user='root')
    print(cnx.connection_id)
    cnx.protocol.cmd_process_kill(cnx.connection_id)
    cnx.connect()
    print(cnx.connection_id)

Could you get a small test case like the above?

Cheers,
Geert

Changed in myconnpy:
assignee: nobody → Geert JM Vanderkelen (geertjmvdk)
status: New → Incomplete
Changed in myconnpy:
status: Incomplete → Confirmed
importance: Undecided → Medium
Revision history for this message
Geert JM Vanderkelen (geertjmvdk) wrote :

The code around MySQLConnection.connect() has been refactored, but there might be still some improvement needed.
We'll check a bit more if handling the exceptions is now done correctly.

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.