sql >> Base de Datos >  >> RDS >> PostgreSQL

¿Cómo liberar posibles bloqueos de fila de Postgres?

Es posible ver las cerraduras.

Aquí hay una vista para que sea un poco más fácil que usar pg_locks directamente:

CREATE OR REPLACE VIEW public.active_locks AS 
 SELECT t.schemaname,
    t.relname,
    l.locktype,
    l.page,
    l.virtualtransaction,
    l.pid,
    l.mode,
    l.granted
   FROM pg_locks l
   JOIN pg_stat_all_tables t ON l.relation = t.relid
  WHERE t.schemaname <> 'pg_toast'::name AND t.schemaname <> 'pg_catalog'::name
  ORDER BY t.schemaname, t.relname;

Luego simplemente seleccione de la vista:

SELECT * FROM active_locks;

Y mátalo con:

SELECT pg_cancel_backend('%pid%');

Otras soluciones:http://wiki.postgresql.org/wiki/Lock_Monitoring