OOPS reports should log database locks

Bug #461661 reported by Stuart Bishop
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Launchpad itself
Triaged
Low
Unassigned

Bug Description

If Launchpad times out while executing an INSERT or UPDATE, it might be because it was unable to grab a lock. If this happens, we should reset the connection and grab the lock information, appending it to the OOPS report. Note that this information may well be out of date by the time we access it, but it should still help track down scripts that conflict with normal Launchpad operations.

SELECT
    pg_locks.mode, pg_class.relname, pg_stat_activity.usename,
    current_timestamp - pg_stat_activity.xact_start as xact_age,
    pg_stat_activity.current_query
FROM pg_locks, pg_database, pg_class, pg_namespace, pg_stat_activity
WHERE
    pg_database.oid = pg_locks.database
    AND pg_class.oid = pg_locks.relation
    AND pg_namespace.oid = pg_class.relnamespace
    AND pg_stat_activity.procpid = pg_locks.pid
    AND pg_database.datname = current_database()
    AND pg_class.relkind='r'
    AND pg_namespace.nspname = 'public'
    AND pg_locks.granted IS TRUE
    AND pg_locks.mode like '%Exclusive%'
    AND pg_stat_activity.xact_start
        < CURRENT_TIMESTAMP - interval '5 seconds';

Gary Poster (gary)
tags: added: oops-tools
Changed in launchpad-foundations:
status: New → Triaged
importance: Undecided → Low
Gary Poster (gary)
Changed in launchpad-foundations:
assignee: nobody → Diogo Matsubara (matsubara)
Revision history for this message
Robert Collins (lifeless) wrote :

See also the recent suggestion that we have postgresql tell us on the resultset some info about what went on.

Gary Poster (gary)
tags: added: oops-infrastructure
removed: oops-tools
William Grant (wgrant)
Changed in launchpad:
assignee: Diogo Matsubara (matsubara) → nobody
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

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