pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Nico Williams <nico@cryptonector.com>
To: pgsql-bugs@postgresql.org
Subject: pg_dump(1) failures when concurrently refreshing mat views
Date: Wed, 19 Apr 2017 14:32:13 -0500
Message-ID: <20170419193212.GD2856@localhost> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>


pg_dump(1) gets an EXCLUSIVE LOCK with NOWAIT and fails if a
not-UNLOGGED, not-TEMP TABLE is locked.  Materialized views (from code
inspection) make not-UNLOGGED, not-TEMP materialization tables, and
REFRESH .. CONCURRENTLY acquires an EXCLUSIVE LOCK on the table.

This means that REFRESH .. CONCURRENTLY can cause a pg_dump(1) to fail.

We've observed this with our alternative view materialization SQL [0],
which is patterned after PostgreSQL's MATERIALIZED VIEWS.

The workaround is to use the -T option to list tables to not dump, and
just not dump materialization tables.

Some possible fixes:

 - dump the TEMP table from which a locked materialization table is
   being concurrently refreshed

 - skip locked materialization tables; cause a refresh on reload

 - never dump materialization tables; cause a refresh on reload

Some possible additional options:

 - make materialization tables optionally UNLOGGED

 - add an option to pg_dump(1) to wait for locks

   (A bad idea if pg_dump(1) acquires all the locks before doing any
   work.)

[0] https://github.com/twosigma/postgresql-contrib/blob/master/pseudo_mat_views.sql

Nico
-- 


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



view thread (4+ messages)  latest in thread

Message-ID: <20170419193212.GD2856@localhost>
Permalink:  ../20170419193212.GD2856@localhost/
Also on:    postgresql.org/message-id/20170419193212.GD2856@localhost

 · 

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-bugs@postgresql.org
  Cc: nico@cryptonector.com
  Subject: Re: pg_dump(1) failures when concurrently refreshing mat views
  In-Reply-To: <20170419193212.GD2856@localhost>
  References: <20170419193212.GD2856@localhost>

* 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