pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Laurenz Albe <laurenz.albe@cybertec.at>
To: James Sewell <james.sewell@jirotech.com>
To: pgsql-general <pgsql-general@postgresql.org>
Subject: Re: Lock leaking out of Transaction?
Date: Wed, 15 Jan 2020 07:34:22 +0100
Message-ID: <ea3109b1c140458aca663b0ffb6a3d262144f700.camel@cybertec.at> (raw)
In-Reply-To: <CAANVwEvmqbDqbFW1Vdo8zP-bpHa0MECwDHiwC4goSu9DT0Kojw@mail.gmail.com>
References: <CAANVwEvmqbDqbFW1Vdo8zP-bpHa0MECwDHiwC4goSu9DT0Kojw@mail.gmail.com>

On Wed, 2020-01-15 at 10:42 +1100, James Sewell wrote:
> I am trying to chase down a locking issue - it looks like a materialized view refresh is being
> held up by a relation  lock which is held by an out of transaction session. My understanding was that
> this was not possible (see SQL output below).
> 
> The locking session is making progress (I can see query_start advancing), which makes it even more confusing.
> 
> Any advice?
> 
> # select * from pg_locks l join pg_stat_activity a on l.pid = a.pid where relation = 1438729::regclass;
> -[ RECORD 1 ]------+---------------------------------------------------------------------------------
> locktype | relation
> database | 16428
> relation | 1438729
> mode | ShareUpdateExclusiveLock
> granted | f
> fastpath | f
> pid | 88955
> wait_event_type | Lock
> wait_event | relation
> state | active
> query | autovacuum: VACUUM supply_nodes (to prevent wraparound)
> backend_type | autovacuum worker
> -[ RECORD 2 ]------+---------------------------------------------------------------------------------
> locktype | relation
> database | 16428
> relation | 1438729
> mode | ExclusiveLock
> granted | f
> pid | 6839
> wait_event_type | Lock
> wait_event | relation
> state | active
> query | REFRESH MATERIALIZED VIEW CONCURRENTLY supply_nodes ;
> backend_type | client backend
> -[ RECORD 3 ]------+---------------------------------------------------------------------------------
> locktype | relation
> database | 16428
> relation | 1438729
> mode | ExclusiveLock
> granted | t
> pid | 65447
> application_name | PostgreSQL JDBC Driver
> wait_event_type | Client
> wait_event | ClientRead
> state | idle
> query | COMMIT
> backend_type | client backend

I cannot explain that either; could it be shared memory corruption?

What I would try is

   SELECT pg_terminate_backend(65447);

and see if the session and its lock go away.

If that does not do the trick, I would restart PostgreSQL, which should get
rid of any possible memory corruption.

Then perhaps the anti-wraparoung autovacuum can succeed.
This autovacuum would also block you, but you should let it finish, since
it is an important system task.

Yours,
Laurenz Albe
-- 
Cybertec | https://www.cybertec-postgresql.com






view thread (2+ messages)

Message-ID: <ea3109b1c140458aca663b0ffb6a3d262144f700.camel@cybertec.at>
Permalink:  ../ea3109b1c140458aca663b0ffb6a3d262144f700.camel@cybertec.at/
Also on:    postgresql.org/message-id/ea3109b1c140458aca663b0ffb6a3d262144f700.camel@cybertec.at

 · 

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: laurenz.albe@cybertec.at, james.sewell@jirotech.com
  Subject: Re: Lock leaking out of Transaction?
  In-Reply-To: <ea3109b1c140458aca663b0ffb6a3d262144f700.camel@cybertec.at>
  References: <CAANVwEvmqbDqbFW1Vdo8zP-bpHa0MECwDHiwC4goSu9DT0Kojw@mail.gmail.com> <ea3109b1c140458aca663b0ffb6a3d262144f700.camel@cybertec.at>

* 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