[storm] Database disconnection detection
James Henstridge
james at jamesh.id.au
Wed Oct 31 22:48:47 GMT 2007
Hi,
I've just merged support for handling database disconnections in Storm.
As there is no standard exception to raise for this condition, it does
require some support from the database back end to detect such errors.
At the moment only Postgres is supported, but it should be easy to
extend to MySQL.
There are a few caveats though:
1. the disconnection tests try to connect to the test database via
TCP. You will probably need to edit pg_hba.conf to allow this.
2. the latest released version of psycopg2 does not correctly report
disconnection errors. See
http://initd.org/tracker/psycopg/ticket/186.
With this feature in place, database disconnections are reported by
the new DisconnectionError exception. Storm will leave the connection
in a disconnected state until you call rollback() on it. On the first
operation in the next transaction, it will attempt to reconnect.
The intent is that you'd retry a transaction on DisconnectionError in
the same way you would on integrity errors, serialisation errors or
deadlocks.
As an example, you might convert DisconnectionErrors to Retry
exceptions in the Zope publication handle_exception() method.
James.
More information about the storm
mailing list