[Sqlalchemy-tickets] [sqlalchemy] #2570: Problem while handling server restart with postgresql 8.4.
Brought to you by:
zzzeek
|
From: sqlalchemy <mi...@zz...> - 2012-09-24 14:15:53
|
#2570: Problem while handling server restart with postgresql 8.4.12
-----------------------------------------+--------------------
Reporter: abdelrahman | Type: defect
Status: new | Priority: medium
Milestone: | Component: access
Severity: no triage selected yet | Keywords:
Progress State: awaiting triage |
-----------------------------------------+--------------------
I have a system where I am upgrading my postgresql from version 8.4.3 to
8.4.12 while my sqlachamy version is 0.6.4 which i also update to version
0.7.8.
I had a problem that the sqlachamy was not able to handle the server
restart anymore where any requests from my session if the restart fails
with:
{{{
(InterfaceError) connection already closed None None
}}}
I had a debugged the problem for a bit and it seems that the exception msg
raised by the postgresql server when its shutdown is changes from 8.4.3 to
8.4.12, where in 8.4.3 it was
{{{
OperationalError('terminating connection due to administrator
command\nserver closed the connection unexpectedly\n\tThis probably means
the server terminated abnormally\n\tbefore or while processing the
request.\n',)
}}}
while the msg in 8.4.12 is
{{{
OperationalError('terminating connection due to administrator
command\nFATAL: terminating connection due to administrator command\n',)
}}}
in the psycopg2.py in both the latest stable version and the development
version of sqlalchamy, the method check if the connection is lost is:
{{{
def is_disconnect(self, e, connection, cursor):
if isinstance(e, self.dbapi.OperationalError):
# these error messages from libpq: interfaces/libpq/fe-misc.c.
# TODO: these are sent through gettext in libpq and we can't
# check within other locales - consider using
connection.closed
return 'closed the connection' in str(e) or \
'connection not open' in str(e) or \
'could not receive data from server' in str(e)
elif isinstance(e, self.dbapi.InterfaceError):
# psycopg2 client errors, psycopg2/conenction.h,
psycopg2/cursor.h
return 'connection already closed' in str(e) or \
'cursor already closed' in str(e)
elif isinstance(e, self.dbapi.ProgrammingError):
# not sure where this path is originally from, it may
# be obsolete. It really says "losed", not "closed".
return "losed the connection unexpectedly" in str(e)
else:
return False
}}}
Notice that when the OperationalError is raised(which is the one raised on
server shutdown), the exception message is parsed to match of the expected
error msgs which does not match in postgresql 8.4.12
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2570>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|