Probably avoidable (unclear) IndexError when connecting.

Bug #528451 reported by tormen
12
This bug affects 1 person
Affects Status Importance Assigned to Milestone
MySQL Connector/Python
New
Undecided
Unassigned

Bug Description

CLIENT:
python 3.1.1 + mysql connector 0.1.3
Linux pixel 2.6.31.3-nogo-pixel #1 SMP PREEMPT Mon Dec 7 01:14:18 EST 2009 i686 Intel(R) Core(TM)2 CPU U7600 @ 1.20GHz GenuineIntel GNU/Linux

SERVER:
Server version: 5.1.39-ndb-7.0.9-cluster-gpl-log MySQL Cluster Server (GPL)
Linux oneohone 2.6.18-6-amd64 #1 SMP Fri Dec 12 05:49:32 UTC 2008 x86_64 GNU/Linux

I am not sure what exactly causes the below problem, but I can pretty good predict /when/ it will happen:

I open a ssh tunnel to the mysql server and use this in the ~/.ssh/config:
    LocalForward 10101 127.0.0.1:3306
I open a db connection with python to 127.0.0.1 port 10101.
I put my notebook to standby <<< here I am not sure if the above connection is still open or already closed.
The next morning I power on the notebook the ssh connection still sits there but timed out.
If I now try to connect with python to 127.0.0.1 port 10101 I get the below traceback.
If I then reestablish the ssh tunnel everything works fine.

But if I try to connect to 127.0.0.1 port 10101 with no ssh tunnel established, I get a nice and clean:
mysql.connector.errors.InterfaceError: 2003: Can't connect to MySQL server on '127.0.0.1:10101' (111)

Traceback (most recent call last):
  File "/home/cypra/Desktop/dev/api/api/cypra/src/cypra/dl/db/user/session.py", line 7, in <module>
    import cypra.dl.db as db
  File "/home/cypra/Desktop/dev/api/api/cypra/src/cypra/dl/db/__init__.py", line 6, in <module>
    import cypra.dblogger as log
  File "/home/cypra/Desktop/dev/api/api/cypra/src/cypra/dblogger.py", line 13, in <module>
    __LOG_DB_CONN__ = db.connect(**config.SYSTEMDBPARAMS)
  File "/usr/lib/python3.1/site-packages/mysql/connector/__init__.py", line 45, in Connect
    return MySQL(*args, **kwargs)
  File "/usr/lib/python3.1/site-packages/mysql/connector/mysql.py", line 317, in __init__
    self.connect(*args, **kwargs)
  File "/usr/lib/python3.1/site-packages/mysql/connector/mysql.py", line 418, in connect
    self._open_connection()
  File "/usr/lib/python3.1/site-packages/mysql/connector/mysql.py", line 91, in _open_connection
    self.conn.open_connection()
  File "/usr/lib/python3.1/site-packages/mysql/connector/connection.py", line 163, in open_connection
    buf = self.recv()[0]
  File "/usr/lib/python3.1/site-packages/mysql/connector/connection.py", line 82, in recv
    (pktsize, pktnr) = self.protocol.handle_header(header)
  File "/usr/lib/python3.1/site-packages/mysql/connector/protocol.py", line 61, in handle_header
    pktnr = utils.int1read(buf[3])
IndexError: index out of range

Any idea what causes this?

Revision history for this message
tormen (quickhelp) wrote :

I confirmed: The problem occurs when you have established an ssh tunnel from host A to B (like described above).

Then host A looses network connection.

At this point the tunnel will stil appear in "netstat -tulpen".

But when you try to connect you don't get any response (maybe you have to wait REALLY long??!)
I waited about 1 minute or so and got stil no error message or what so ever from mysql.connector.
Then I closed the ssh connection (and so the tunnel vanished).
At this point you get the above cited "IndexError: index out of range".

So I am not sure if this is possible:
  a) to make mysql.connector not wait so long (maybe infinite?) before it fails
  b) create a nicer Exception

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

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