Connection permanently broken if transaction begin times out or fails

Bug #939287 reported by Stuart Bishop
16
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Launchpad itself
Triaged
High
Unassigned
Storm
Invalid
High
Unassigned

Bug Description

If starting the transaction fails, such as the statement timeout kicking in, no abort is issued. At least with PostgreSQL, this leaves the connection in a broken state, as all future attempts to begin the transaction fail when trying to issue a BEGIN statement on a broken transaction.

Revision history for this message
Stuart Bishop (stub) wrote :

We could attempt to catch the failure as it happens and issue an abort. However, the abort might also fail and we can't loop for ever.

The best approach is to abort the broken transaction before attempting to start a new one. Modern versions of psycopg2 may let us interrogate the connection state and abort it if necessary. We could also unconditionally issue an ABORT before the BEGIN, but this will create log spam in the PostgreSQL logs.

Stuart Bishop (stub)
Changed in storm:
importance: Undecided → High
status: New → Confirmed
Stuart Bishop (stub)
Changed in storm:
status: Confirmed → New
Revision history for this message
Stuart Bishop (stub) wrote :

From the PostgreSQL logs, this is what put Launchpad into this state:

<lpnet132@launchpad_prod_3:18158> 2012-02-23 06:18:23 UTC LOG: duration: 14486.797 ms statement: BEGIN; SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
<lpnet132@launchpad_prod_3:18158> 2012-02-23 06:18:23 UTC ERROR: canceling statement due to user request

Revision history for this message
Stuart Bishop (stub) wrote :

Those statements are issued by psycopg2 when a transaction is implicitly started. Because the start of a transaction is not explicitly started, there is nowhere to hook in to repair the transaction if it is broken.

I'm not sure how we managed to trigger this state in Launchpad.

Changed in launchpad:
status: New → Confirmed
Changed in storm:
status: New → Incomplete
Curtis Hovey (sinzui)
Changed in launchpad:
status: Confirmed → Triaged
importance: Undecided → High
Revision history for this message
Stuart Bishop (stub) wrote :

Not a Storm bug. An exception is raised if the implicit transaction cannot be started. Somehow, Launchpad managed to not catch this and rollback the transaction like it should have.

Changed in storm:
status: Incomplete → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.