This project is archived and is in readonly mode.
psycopg went psycotic without error set
-
Daniele Varrazzo
Hello, thank you for the report.
Could you please provide a couple of details? You said with recent releases you get a "psycopg went psycotic", while in 2.2.2 it wasn't "broken". What do you mean? I assume the connection is dropped anyway as it's the purpose of your test. What is the behaviour of 2.2.2? The "DisconnectionError" you test for is something raised by your wrapper: what is the psycopg does differently in the two versions?
Thank you very much.
-
Daniele Varrazzo
- State changed from new to resolved
The bug should be fixed in my devel branch: a DatabaseError should be raised instead of an Error when we hit that case.
-
Gavin Panella
Hi Daniele,
Sorry for the wait. I've tested Storm trunk (r427) with https://github.com/dvarrazzo/psycopg (2af563227a95a86e7d303716323d21294716b4a5) and it no longer goes psycotic \o/
Instead I get:
psycopg2.DatabaseError: error with no message from the libpqwhich seems fine. However, is this safe to treat as a disconnection error? I assume so, but perhaps there's something else I should be aware of.
Thank you enormously for working on this!
Gavin.
-
Daniele Varrazzo
The class and message you get is actually what intended, so the patch worked as expected.
DatabaseError is not actually a synonym for a disconnection: it's rather a catch-all - see the exceptions inheritance layout at http://initd.org/psycopg/docs/module.html#exceptions. It is relatively safe to assume that whatever error you get at connection time... is a connection error :) it's still too early to get more complicated errors :) (assuming we are talking about the catch statement at storm/database.py:347 - tell me if I'm wrong) However, in the DBAPI exception tree, Error is a yet more generic exception: catching it wouldn't have raised the problem in first place.
You have probably made more tests than me about what happens brutally disconnecting the connection. Without using pgbouncer I've not been able to reproduce the condition raising that exception - in fact the author thought if you got there it would have been a psycopg bug instead - hence the cheeky error message. I would have rather raised an InterfaceError, but now that we know there is actually a way to trick the libpq to return an error without a message, we will keep it as DatabaseError.
I can only ask you to report any weird behaviour you get in corner cases: I'll try to make psycopg the most consistent I can. Test cases are also welcome for inclusion in our test suite.
Cheers!