theres no way to detect the database being restarted until a connection execute() is actually attempted, short of using a separate worker thread that is constantly polling the database (maybe that would make a good SA extension).
so because we are storing connections in a connection pool, we dont have any way to avoid the first error message. in the trunk we have code to invalidate a connection when this condition is detected, which is why on Postgres you eventually got a working app. But also note that psycopg2 has a bug in it which throws certain "not connected" exceptions in such a way that they cant be caught, so even then youre not going to do very well - frederico says "he'll fix it", but i havent seen any ticket placed in trac and ive been thinking of reminding him of this one. with firebird, the appropriate "database closed" exceptions need to be added to its dialect's is_disconnect() method...someone needs to submit a patch for that (you can create one based on the exception youre getting, which would look like: def is_disconnect(self, e): if isinstance(e, self.dbapi.OperationalError): return 'Unable to complete network request to host' in str(e) ). another way to minimize the impact from a database restart is to set the pool_recycle paramter on engine to a low number, indicating the number of seconds before it should recycle a connection. a setting of 120 for example means that no connection will be held around longer than 120 seconds, which would be the maximum downtime you could have from a suprise database restart. setting it to 0 would mean new connections are opened constantly and youd never get this error except for connections that are in use during the restart. On Apr 16, 2007, at 4:15 PM, Roger Demetrescu wrote: > > Hi folks, > > I'm having some connection problems with a TG application using > Firebird. To try understand the problems I did a test with Postgresql > and Firebird: > > [Postgresql] > > 1) started the app. and browsed some pages > 2) restarted postgresql > 3) in the first refresh of the page, after the restart, I got a : > > OperationalError: connection not open > > 4) Doing a refresh of the page once more, I got this: > > SQLError: (OperationalError) closed the connection unexpectedly > This probably means the server terminated abnormally > before or while processing the request. > > 5) Refresh once more: I got the page running normally. > > > > [Firebird 1.5] > > 1) started the app. and browsed some pages > 2) restarted firefird > 3) in the first refresh of the page, after the restart, I got a : > > > SQLError: (OperationalError) (-902, 'begin transaction: \n Unable to > complete network request to host "192.168.50.6".\n Error reading data > from the connection.\n Uma conex\xe3o estabelecida foi anulada pelo > software no computador host.') > > > 4) Doing a refresh of the page once more, I got this: > 5) No matter how many time I try to refresh the page, the error > repeats... I have to restart my TG app to make it run again. > > > I did the tests with SA 0.3.6 and 0.3.7dev-r2504... > > > What can I do to have my app more "stable" ? > > > Thanks > > Roger > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---