pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Michal Merta <michal.merta@greycortex.com>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: Deadlock while doing VACUUM and DROP
Date: Wed, 24 Oct 2018 15:02:17 +0100
Message-ID: <19803.1540389737@sss.pgh.pa.us> (raw)
In-Reply-To: <21fe894d-4fb8-974d-cdd6-2b252852ce76@greycortex.com>
References: <21fe894d-4fb8-974d-cdd6-2b252852ce76@greycortex.com>

Michal Merta <michal.merta@greycortex.com> writes:
> I encountered deadlock during DROP TABLE statement:

> 2018-10-23 14:49:55 CEST psql > ERROR:  deadlock detected
> 2018-10-23 14:49:55 CEST psql > DETAIL:  Process 89171 waits for 
> AccessExclusiveLock on relation 17582 of database 16390; blocked by 
> process 50837.
>   Process 50837 waits for AccessShareLock on relation 20767 of 
> database 16390; blocked by process 89171.
>   Process 89171: DROP TABLE IF EXISTS sm.tasks;
>   Process 50837: autovacuum: ANALYZE sm.tasks

Hm, there's more to that than meets the eye, because the locks were on
two different tables.  Have you checked which tables are involved,
eg "select 20767::regclass"?

> Is there anything I can do make sure that DDL statement won't be 
> canceled due to collision with autovaccum?

I suspect your DDL transaction was getting exclusive locks on multiple
tables.  That's always hazardous.  It might be easier to retry the
DDL than try to guarantee no deadlock.  Or break it up into separate
transactions for each table.

			regards, tom lane




view thread (2+ messages)

Message-ID: <19803.1540389737@sss.pgh.pa.us>
Permalink:  ../19803.1540389737@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/19803.1540389737@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: tgl@sss.pgh.pa.us, michal.merta@greycortex.com
  Subject: Re: Deadlock while doing VACUUM and DROP
  In-Reply-To: <19803.1540389737@sss.pgh.pa.us>
  References: <21fe894d-4fb8-974d-cdd6-2b252852ce76@greycortex.com> <19803.1540389737@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox