Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d0vKy-0002BW-8u for pgsql-bugs@arkaria.postgresql.org; Wed, 19 Apr 2017 19:32:24 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1d0vKx-0001M1-N5 for pgsql-bugs@arkaria.postgresql.org; Wed, 19 Apr 2017 19:32:23 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1d0vKw-0001LY-TD for pgsql-bugs@postgresql.org; Wed, 19 Apr 2017 19:32:23 +0000 Received: from sub4.mail.dreamhost.com ([69.163.253.135] helo=homiemail-a87.g.dreamhost.com) by magus.postgresql.org with esmtps (TLS1.1:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1d0vKt-0005UC-I3 for pgsql-bugs@postgresql.org; Wed, 19 Apr 2017 19:32:22 +0000 Received: from homiemail-a87.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a87.g.dreamhost.com (Postfix) with ESMTP id 84744C009F4E; Wed, 19 Apr 2017 12:32:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=cryptonector.com; h=date :from:to:subject:message-id:mime-version:content-type; s= cryptonector.com; bh=4nRNCTFWZFax3kKrnSEgNLC/htI=; b=wXpL77TwHJu K5nLcRVVGpUhrBU+5Z4Fz9i6+TM5X1S/WY8s+oHCJz8eBPBYXnp2YBpG+IJYsKnL eNnRLmF7rSs0URadc257JElJH/xIelrtaNSQ9qm8F5BTBIPRWf8m+w2k4dlaAAqE 6cqpxjD1JUt+PRJEbvE7htnUvzjmQToI= Received: from localhost (cpe-70-123-158-140.austin.res.rr.com [70.123.158.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: nico@cryptonector.com) by homiemail-a87.g.dreamhost.com (Postfix) with ESMTPSA id 00DEEC0026AA; Wed, 19 Apr 2017 12:32:15 -0700 (PDT) Date: Wed, 19 Apr 2017 14:32:13 -0500 From: Nico Williams To: pgsql-bugs@postgresql.org Subject: pg_dump(1) failures when concurrently refreshing mat views Message-ID: <20170419193212.GD2856@localhost> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) X-Pg-Spam-Score: -4.8 (----) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org 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