More info here: chtd/psycopg2cffi#49 In the nutshell - connecion is not marked as closed properly.
There was bug in reconnect logic. Retries were only performed if operation attempt failes synchrnously. However typically this is not the case. The most obvouis case for reconnects is when database server restarts. However client does not detects that server went await up until `connection.poll()`. I.e. `cursor.execute` finishes successfully. Unfortunately in such cases Momoko simply progated the error to the caller, practically rendering reconnection code useless. The bug existed primarily to the fact, that I did not find a good and simple way to simulate sever going away and coming back in my unitests. Now I've integrated third-party tcproxy package that I launch and restart when needed from unittest code. So finally, I have all the tools to fix and verify all reconnection logic.