Re: Deadlock between VACUUM and ALTER TABLE commands - Mailing list pgsql-general

From Alexey Bashtanov
Subject Re: Deadlock between VACUUM and ALTER TABLE commands
Date
Msg-id 570619F8.40601@imap.cc
Whole thread Raw
In response to Deadlock between VACUUM and ALTER TABLE commands  (Kevin Burke <burke@shyp.com>)
List pgsql-general
Hello Kevin,

On 06/04/16 23:22, Kevin Burke wrote:
Why mess around with DISABLE/ENABLE TRIGGER instead of TRUNCATE? We observed that TRUNCATE took about 200ms, but this method takes about 13ms. Over a our test suite TRUNCATE is going to more or less double the length of the suite.

We could resolve some kind of foreign key dependency tree, issue the DELETE FROM's in the right order, and skip DISABLE TRIGGER etc., but haven't invested the time to do this or figured out how to maintain it/update it as we add new tables.
I'd suggest one more method: SET CONSTRAINTS ALL DEFERRED and DELETE FROM all tables in arbitrary order (will require making constraints deferrable)
Specifically we kick off the ALTER TABLE ... DELETE, a second later (our deadlock_timeout) a log message appears that the ALTER TABLE is waiting for an AccessExclusiveLock held by process 16936... which is later revealed to be an autovacuum process of the "events" table.
this only indicates that 16936 does not allow ALTER TABLE to acquire AccessExclusiveLock
this does not necessarily mean that
16936 has acquired AccessExclusiveLock, it means that 16936 has acquired some lock conflicting with AccessExclusiveLock you can use this table to determine what locks are conflicting one with another Regards, Alexey Bashtanov

pgsql-general by date:

Previous
From: John R Pierce
Date:
Subject: Re: PostgreSQL 9.5.1 -> PG_REWIND NOT FOUND
Next
From: Berend Tober
Date:
Subject: Re: what database schema version management system to use?