MySQL server gone away

Issue #3107 closed
Juda Kaleta created an issue

We are using SQLAlchemy to pool connections to MySQL server (together with django-mysqlpool). After upgrading to 0.9.6 many error like this have started to appear frequently.

sqlalchemy.pool.QueuePool   Exception during reset or similar

Traceback (most recent call last):
  File "/home/mcat/venv_sk/local/lib/python2.7/site-packages/sqlalchemy/pool.py", line 557, in _finalize_fairy
    fairy._reset(pool, echo)
  File "/home/mcat/venv_sk/local/lib/python2.7/site-packages/sqlalchemy/pool.py", line 688, in _reset
    pool._dialect.do_rollback(self)
  File "/home/mcat/venv_sk/local/lib/python2.7/site-packages/sqlalchemy/pool.py", line 79, in do_rollback
    dbapi_connection.rollback()
OperationalError: (2006, 'MySQL server has gone away')

Recycle and other arguments passed to pool haven't changed and should be correct.

Comments (4)

  1. Mike Bayer repo owner

    After upgrading to 0.9.6

    after upgrading.... from what? 0.9.4? 0.6.7? This looks like you are just seeing the effects of #2752: http://docs.sqlalchemy.org/en/rel_0_9/changelog/changelog_09.html#change-026a7898970464580f20e377c6428616.

    Here's a simple program (an incorrect program, in order to illustrate this error) emitting the same output:

    from sqlalchemy import create_engine
    import gc
    import logging
    
    logging.basicConfig()
    
    e = create_engine("mysql://scott:tiger@localhost/test", echo=True)
    c = e.connect()
    
    # incorrect method of closing - closing the DBAPI
    # connection directly
    c.connection.connection.close()
    
    # then don't actually close() so
    # that GC gets it insead
    del c
    
    gc.collect()
    
  2. Mike Bayer repo owner

    the exception in the above case is emitted on pretty much any SQLA version, it's just in 0.9 we are now showing it in the logs. Without further detail illustrating correct use leading to this failure there's not enough detail to show a bug.

  3. Log in to comment