Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kAiZe-0002lo-U5 for pgsql-admin@arkaria.postgresql.org; Tue, 25 Aug 2020 23:41:54 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kAiZd-0002sh-Sr for pgsql-admin@arkaria.postgresql.org; Tue, 25 Aug 2020 23:41:53 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kAiZd-0001ti-Jr for pgsql-admin@lists.postgresql.org; Tue, 25 Aug 2020 23:41:53 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kAiIY-0001ft-4E for pgsql-admin@postgresql.org; Tue, 25 Aug 2020 23:24:21 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 07PNO4FF2775008; Tue, 25 Aug 2020 19:24:04 -0400 From: Tom Lane To: Wells Oliver cc: Stephen Frost , Alvaro Herrera , pgsql-admin Subject: Re: Odd pg dump error: cache lookup failure In-reply-to: <2763002.1598385281@sss.pgh.pa.us> References: <20200824231338.GA30623@alvherre.pgsql> <20200824231621.GA29590@tamriel.snowman.net> <2748788.1598376276@sss.pgh.pa.us> <2760667.1598382327@sss.pgh.pa.us> <2762015.1598384009@sss.pgh.pa.us> <2763002.1598385281@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Tue, 25 Aug 2020 15:54:41 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2775006.1598397844.1@sss.pgh.pa.us> Date: Tue, 25 Aug 2020 19:24:04 -0400 Message-ID: <2775007.1598397844@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk I wrote: > Wells Oliver writes: >> It doesn't exist any longer, which lead me to try to think of things that >> might be dropped during the dump process. > Hm, if you're actually *dropping* matviews during the dump then it's > not so hard to explain this error. They'd have to be ones that were > selected to be dumped though. I experimented a bit to try to reproduce this problem. I cannot get any sort of error from REFRESH (with or without CONCURRENTLY) in parallel with a pg_dump. If I drop a view or matview, I can easily get an error, but I've not managed to reproduce one that looks like yours; it tends to be more like pg_dump: error: query failed: ERROR: could not open relation with OID 45698 What I found that *would* reproduce "cache lookup failed for attribute" from pg_get_indexdef() is to explicitly drop a matview's index just before pg_dump gets to it. So I wonder if you are doing that in your "refresh" procedure. The timing is not terribly tight; the drop has to happen between where pg_dump acquires its transaction snapshot and where it tries to investigate the matview's indexes, which could be some while in a database with many objects. Also, if the transaction doing the index drop also takes out any exclusive locks on regular tables, that could make it much easier to send pg_dump down this rabbit hole, since it'd block on those locks till the damage was done. regards, tom lane