[openstack-dev] [all] switch from mysqldb to another eventlet aware mysql client -- status of postgresql drivers?

Mike Bayer mbayer at redhat.com
Mon Jul 14 17:53:58 UTC 2014


On Jul 14, 2014, at 1:02 PM, Chris Friesen <chris.friesen at windriver.com> wrote:

> On 07/14/2014 10:41 AM, Mike Bayer wrote:
>> 
>> On Jul 14, 2014, at 12:29 PM, Chris Friesen <chris.friesen at windriver.com> wrote:
>> 
>>> On 07/09/2014 05:17 AM, Ihar Hrachyshka wrote:
>>>> -----BEGIN PGP SIGNED MESSAGE-----
>>>> Hash: SHA512
>>>> 
>>>> Hi all,
>>>> 
>>>> Multiple projects are suffering from db lock timeouts due to deadlocks
>>>> deep in mysqldb library that we use to interact with mysql servers. In
>>>> essence, the problem is due to missing eventlet support in mysqldb
>>>> module, meaning when a db lock is encountered, the library does not
>>>> yield to the next green thread, allowing other threads to eventually
>>>> unlock the grabbed lock, and instead it just blocks the main thread,
>>>> that eventually raises timeout exception (OperationalError).
>>>> 
>>>> The failed operation is not retried, leaving failing request not
>>>> served. In Nova, there is a special retry mechanism for deadlocks,
>>>> though I think it's more a hack than a proper fix.
>>> 
>>> This may be a bit of a tangent to the original discussion, but does anyone know where we stand with postgres and eventlets?  Is pyscopg2 susceptible to the same problems as mysqldb?
>> 
>> if psycopg2 is in use, the set_wait_callback() extension must be enabled.
>> 
>> see http://initd.org/psycopg/docs/extensions.html#psycopg2.extensions.set_wait_callback and https://bitbucket.org/zzzeek/green_sqla/src/2732bb7ea9d06b9d4a61e8cd587a95148ce2599b/green_sqla/psyco_gevent.py?at=default for an example use taken from psycopg2 developers.
> 
> Can you elaborate a bit?  It's my understanding that sqlalchemy will use psycopg2 for connection strings like:
> 
> sql_connection = postgresql://
> 
> is that correct?

it will, though I strongly recommend naming the driver explicitly, as in :

postgresql+psycopg2://

docs at: http://docs.sqlalchemy.org/en/rel_0_9/dialects/postgresql.html#module-sqlalchemy.dialects.postgresql.psycopg2

> Assuming this is the case, do we need to do something extra to set up the extension above and beyond what is already in the openstack/sqlalchemy/eventlet codebase?  Is this documented somewhere?

That I do not know, the folks who implement eventlet compat would have to respond with what testing and development they’ve done in this regard.


More information about the OpenStack-dev mailing list