Temporary connection failures with 2 exceptions

Bug #519301 reported by tormen
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
MySQL Connector/Python
Fix Released
High
Geert JM Vanderkelen

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

PROBLEM:
/Sometimes/ ... the below happens:
(/Sometimes/ means: During the run before and the next run this Exception does not occur and a database connection gets established without any problem!)

Traceback (most recent call last):
  File "C:\Python31\lib\site-packages\mysql\connector\protocol.py", line 646, in scramble
    for (h1,h3) in zip(hash1, hash3) ]
  File "C:\Python31\lib\site-packages\mysql\connector\protocol.py", line 646, in <listcomp>
    for (h1,h3) in zip(hash1, hash3) ]
  File "C:\Python31\lib\site-packages\mysql\connector\utils.py", line 39, in int1read
    raise ValueError('excepts int 0 <= x <= 254')
ValueError: excepts int 0 <= x <= 254

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "W:\api\company\src\company\tests\bl.logs.py", line 1, in <module>
    import company.bl as bl
  File "W:\api\company\src\company\__init__.py", line 29, in <module>
    bl.logs.init()
  File "W:\api\company\src\company\bl\logs.py", line 10, in init
    __LOG_DB_CONN__ = db.Connection('system')
  File "W:\api\company\src\company\dl\db.py", line 80, in __init__
    super(Connection, self).__init__( **self.params )
  File "C:\Python31\lib\site-packages\mysql\connector\mysql.py", line 317, in __init__
    self.connect(*args, **kwargs)
  File "C:\Python31\lib\site-packages\mysql\connector\mysql.py", line 418, in connect
    self._open_connection()
  File "C:\Python31\lib\site-packages\mysql\connector\mysql.py", line 99, in _open_connection
    database=self.database, charset=self.charset)
  File "C:\Python31\lib\site-packages\mysql\connector\protocol.py", line 78, in do_auth
    charset=charset)
  File "C:\Python31\lib\site-packages\mysql\connector\protocol.py", line 663, in create
    self.add(self.scramble(password,seed))
  File "C:\Python31\lib\site-packages\mysql\connector\protocol.py", line 649, in scramble
    raise errors.ProgrammingError('Failed scrambling password; %s' % e)
mysql.connector.errors.ProgrammingError: -1: Failed scrambling password; excepts int 0 <= x <= 254

Tags: py3k

Related branches

Revision history for this message
tormen (quickhelp) wrote :

Maybe that is not clear: /Sometimes/ is in about 30-50% of all runs.

Revision history for this message
tormen (quickhelp) wrote :

/Sometimes/ also 2 or 3 times in a row.

Remark on the Traceback:
As you can see we do have a wrapper class "Connection" around the MySQL Connection

But the problem occures at the execution time of the constructor of the wrapper Class when we call:
   super(Connection, self).__init__( **self.params )

The dictionary self.params just contains the valid parameters for the MySQL Connection class constructor.

A feedback on this would be nice.
For now I will catch the Exception in our wrapper class and retry.
<<< but this is ugly!

Revision history for this message
tormen (quickhelp) wrote :

Okey... the problem also occurs without the wrapper class :-((

CODE:
import mysql.connector as DB
print( config.SYSTEMDBPARAMS )
conn = DB.connect( **config.SYSTEMDBPARAMS )

OUTPUT:
OrderedDict([('host', 'localhost'), ('user', 'me'), ('password', 'secret'), ('db', 'system')])
Traceback (most recent call last):
  File "C:\Python31\lib\site-packages\mysql\connector\protocol.py", line 646, in scramble
    for (h1,h3) in zip(hash1, hash3) ]
  File "C:\Python31\lib\site-packages\mysql\connector\protocol.py", line 646, in <listcomp>
    for (h1,h3) in zip(hash1, hash3) ]
  File "C:\Python31\lib\site-packages\mysql\connector\utils.py", line 39, in int1read
    raise ValueError('excepts int 0 <= x <= 254')
ValueError: excepts int 0 <= x <= 254

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "W:\api\company\src\company\dl\db\__init__.py", line 97, in <module>
    conn = DB.connect( **config.SYSTEMDBPARAMS )
  File "C:\Python31\lib\site-packages\mysql\connector\__init__.py", line 45, in Connect
    return MySQL(*args, **kwargs)
  File "C:\Python31\lib\site-packages\mysql\connector\mysql.py", line 317, in __init__
    self.connect(*args, **kwargs)
  File "C:\Python31\lib\site-packages\mysql\connector\mysql.py", line 418, in connect
    self._open_connection()
  File "C:\Python31\lib\site-packages\mysql\connector\mysql.py", line 99, in _open_connection
    database=self.database, charset=self.charset)
  File "C:\Python31\lib\site-packages\mysql\connector\protocol.py", line 78, in do_auth
    charset=charset)
  File "C:\Python31\lib\site-packages\mysql\connector\protocol.py", line 663, in create
    self.add(self.scramble(password,seed))
  File "C:\Python31\lib\site-packages\mysql\connector\protocol.py", line 649, in scramble
    raise errors.ProgrammingError('Failed scrambling password; %s' % e)
mysql.connector.errors.ProgrammingError: -1: Failed scrambling password; excepts int 0 <= x <= 254

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

I have indeed seen this as well. Thanks for the report!

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

Simple test case for reproducing bug #519301

summary: - Temporary connection failures with 2 exceptions ("ValueError: excepts
- int 0 <= x <= 254" + "Failed scrambling password")
+ Temporary connection failures with 2 exceptions
Revision history for this message
Geert JM Vanderkelen (geertjmvdk) wrote :

revno: 205
committer: Geert Vanderkelen <email address hidden>
branch nick: myconnpy-dev
timestamp: Fri 2010-02-12 14:36:49 +0100
message:
  Fix authentication by fixing utils.int1read()

  * Scrambling the password failed randomly with Python 3.1 due to a bug in the
  utils.int1read() function. It was fixed also for Python 2.x.
  * Adding test case for bug lp:519301

Changed in myconnpy:
status: Confirmed → Fix Committed
Revision history for this message
Geert JM Vanderkelen (geertjmvdk) wrote :

You can patch it yourself if you can't wait. Replace mysql.connector.utils.int1read() with following:

def int1read(c):
    """
    Takes a byte and returns it was an integer.

    Returns integer.
    """
    if isinstance(c,int) and (c >= 0 and c < 256):
        return c

    try:
        return int('%02x' % ord(c),16)
    except:
        raise ValueError('int1read expects a byte, was %r' % c)

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

Other bug subscribers

Bug attachments

Remote bug watches

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