Possible bug in MySQLDialect._check_unicode_returns() (missing optional parameter) (0.9.3 )

32 views
Skip to first unread message

Oliver Bestwalter

unread,
Feb 21, 2014, 7:05:02 AM2/21/14
to sqlal...@googlegroups.com
Hi all,

after updgrading sqlalchemy from 0.9.1 to 0.93 we (not always but often) get this traceback

Traceback (most recent call last):
File "/opt/prodenv/trunk/frontend/decorators.py", line 134, in _decorated return func(*args, **kwargs)
File "/opt/prodenv/trunk/frontend/buildmgt_frontend.py", line 1351, in releases_to_customer get_history_builds(abs(int(limit)))
File "/opt/prodenv/trunk/shared/utils/database.py", line 189, in _db_session_view return func(*args, **kwargs)
File "/opt/prodenv/trunk/frontend/buildmgt_frontend_funcs.py", line 193, in get_history_builds historyData = get_product_history()
File "/opt/prodenv/trunk/frontend/release_data_collector.py", line 70, in get_product_history session, filtersProduct)
File "/opt/prodenv/trunk/frontend/release_data_collector.py", line 59, in query_and_filter_all jobs = query.all()
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/query.py", line 2280, in all def all(self):
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/query.py", line 2392, in __iter__
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/query.py", line 2405, in _execute_and_instances return conn
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/query.py", line 2396, in _connection_from_session if self._autoflush and not self._populate_existing:
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/session.py", line 843, in connection close_with_result=close_with_result)
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/session.py", line 847, in _connection_for_bind return self.transaction._connection_for_bind(engine)
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/session.py", line 315, in _connection_for_bind conn = bind.contextual_connect()
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1645, in contextual_connect will also be closed, which allows its associated DBAPI connection
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/pool.py", line 281, in connect and configured with identical creation arguments.
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/pool.py", line 466, in checkout methods are called, as well as when any so-called "automatic invalidation"
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/pool.py", line 329, in checkout pass
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/pool.py", line 799, in _do_get use_threadlocal=self._use_threadlocal,
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/pool.py", line 224, in _create_connection
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/pool.py", line 320, in __init__ the pool.
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/event/attr.py", line 238, in exec_once
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/event/attr.py", line 247, in __call__ self(*args, **kw)
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/util/langhelpers.py", line 1180, in go return once_fn(*arg, **kw)
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/strategies.py", line 166, in first_connect dialect.initialize(c)
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/dialects/mysql/base.py", line 2297, in initialize default.DefaultDialect.initialize(self, connection)
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/default.py", line 209, in initialize return weakref.WeakKeyDictionary()
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/dialects/mysql/mysqldb.py", line 100, in _check_unicode_returns connection, additional_tests)
TypeError: _check_unicode_returns() takes exactly 2 arguments (3 given)

for mysql this method was overridden to fix https://github.com/farcepest/MySQLdb1/commit/cd44524fef63bd3fcb71947392326e9742d520e8 but now the overriden method is is lacking the optional parameter additional_tests and crashes when called with it.
I just wanted to check here before I open an issue and it turns out it's something else.

Thanks
Oliver

--
Avira Operations GmbH & Co. KG
Kaplaneiweg 1 | 88069 Tettnang | Deutschland / Germany
Telefon / Telephone: +49 7542-500 0
Telefax / Facsimile: +49 7542-500 3000

Registergericht: Amtsgericht Ulm, HRA 722586 | USt.-IdNr.: DE 815289569 | Pers. haftende Gesellschafterin: Avira OP GmbH | Firmensitz: Tettnang | Registergericht: Amtsgericht Ulm, HRB 726712 | Geschäftsführer: Travis Witteveen

Commercial Register: Amtsgericht Ulm, HRA 722586 | VAT-ID: DE 815289569 | Personally Liable Partner: Avira OP GmbH | Headquarters: Tettnang | Commercial Register: Amtsgericht Ulm, HRB 726712 | Chief Executive Officer (CEO): Travis Witteveen

Michael Bayer

unread,
Feb 21, 2014, 7:24:05 AM2/21/14
to sqlal...@googlegroups.com

On Feb 21, 2014, at 7:05 AM, Oliver Bestwalter <oliver.b...@avira.com> wrote:

> File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/strategies.py", line 166, in first_connect dialect.initialize(c)
> File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/dialects/mysql/base.py", line 2297, in initialize default.DefaultDialect.initialize(self, connection)
> File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/default.py", line 209, in initialize return weakref.WeakKeyDictionary()
> File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/dialects/mysql/mysqldb.py", line 100, in _check_unicode_returns connection, additional_tests)
> TypeError: _check_unicode_returns() takes exactly 2 arguments (3 given)
>
> for mysql this method was overridden to fix https://github.com/farcepest/MySQLdb1/commit/cd44524fef63bd3fcb71947392326e9742d520e8 but now the overriden method is is lacking the optional parameter additional_tests and crashes when called with it.
> I just wanted to check here before I open an issue and it turns out it's something else.


It’s not, I can’t quite explain that particular issue but it seems like your Python interpreter is doing something weird - line 209 of default.py is not calling into mysqldb like that and it seems like things are not calling each other as they should (like, your interpreter is corrupted). The _check_unicode_returns() method is called immediately when an engine first connects, and is only called with “self, connection”. The three-argument form is specifically called by the overridden method in the MySQL dialect. The trace seems to be mis-tracking the correct line number in default.py.

I don’t have much advice here except to make sure the SQLAlchemy installation is unmodified, and to look into issues like memory usage or native libraries in use that may be interfering with the Python interpreter’s stability.
signature.asc

Oliver Bestwalter

unread,
Feb 21, 2014, 7:38:04 AM2/21/14
to sqlal...@googlegroups.com
Hi Michael,


That sounds scary.
* SQLAlchemy installation is unmodified: check
* look into issues like memory usage: check
* or native libraries in use that may be interfering with the Python interpreter’s stability: wouldn't know what to look for, but we don't do weird stuff - all normal apt-get and pip installation of normally releases.

Maybe it's even a code version mix up if everything wasn't restarted properly (it's a webapp running on gunicorn/nginx)? Will restart everything and see if it goes away.

Cheers
Oliver

Jonathan Vanasco

unread,
Feb 21, 2014, 1:16:41 PM2/21/14
to sqlal...@googlegroups.com
I'd suggest recompiling mysqldb

I've had weird/odd issues happen when either Python or MySQL/PostgreSQL were updated and the driver wasn't.  Even for minor updates ( Python 2.7.4 -> 2.7.5 ; Postgres 9.3 -> 9.4, etc ), the compiled c-extension will often cause random errors if anything that touches it was updated.

Oliver Bestwalter

unread,
Feb 21, 2014, 6:41:27 PM2/21/14
to sqlal...@googlegroups.com
Hi Jonathan,

thanks, I'll do that from now on.

Cheers
Oliver


On 21 February 2014 19:16, Jonathan Vanasco <jona...@findmeon.com> wrote:
I'd suggest recompiling mysqldb

I've had weird/odd issues happen when either Python or MySQL/PostgreSQL were updated and the driver wasn't.  Even for minor updates ( Python 2.7.4 -> 2.7.5 ; Postgres 9.3 -> 9.4, etc ), the compiled c-extension will often cause random errors if anything that touches it was updated.

--
You received this message because you are subscribed to a topic in the Google Groups "sqlalchemy" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sqlalchemy/_E4vzz1FgEQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sqlalchemy+...@googlegroups.com.
To post to this group, send email to sqlal...@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/groups/opt_out.

Reply all
Reply to author
Forward
0 new messages