Before opening a ticket I wanted to open a discussion on ways of
avoiding the MySQL connection timeout scenario (a symptom of this is
the "MySQL server has gone away" exception.)

=Background for those interested=
MySQL enforces an idle connection timeout policy. Additionaly, the
connection protocl has been designed to minimise the latency of
creating new connections. MySQL after all was originally designed for
web applications creating tens or more connections a second.  The
MySQL team advise not holding persistent connections to the database
(http://www.mysql.com/news-and-events/newsletter/2002-11/
a0000000086.html) unless benchmarking indicates it would be of
benefit.

Because SQLAlchemy retains a persistent connection to the database a
long running application that go through periods of inactivity (8
hours by default) my find the connection timing out. This is
particularily painful for applications frameworks such as Turbogears
as there is little recourse for recreating the connection without
restarting the application.

=Discussion=
1. Is this an issue that SQLAlchemy ought to be concerned with. Or is
this an issue for the utilising applicaiton?

=Possible Solutions=
There are at least two possible solutions inside of SQLAlchemy.

1. Call connection.ping(True) before any call to cursor.execute() to
transparently reconnect. This has the downside of causing an
additional call to the database for each statement.

2. Put cursor.execute() calls inside a try/except block that looks for
exception codes 2006, reconnecting to the database and reissueing the
statement if trapped.

=End=
My apologies if this post if off topic.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to