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 1kIGuG-0006Ef-Uq for pgsql-hackers@arkaria.postgresql.org; Tue, 15 Sep 2020 19:46:24 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kIGuF-00049n-T5 for pgsql-hackers@arkaria.postgresql.org; Tue, 15 Sep 2020 19:46:23 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kIGuF-00049f-MT for pgsql-hackers@lists.postgresql.org; Tue, 15 Sep 2020 19:46:23 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kIGuD-0004v3-4L for pgsql-hackers@lists.postgresql.org; Tue, 15 Sep 2020 19:46:23 +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 08FJkIHf1353599 for ; Tue, 15 Sep 2020 15:46:18 -0400 From: Tom Lane To: pgsql-hackers@lists.postgresql.org Subject: Re: Subscription test 013_partition.pl fails under CLOBBER_CACHE_ALWAYS In-reply-to: <1032727.1600096803@sss.pgh.pa.us> References: <1032727.1600096803@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Mon, 14 Sep 2020 11:20:03 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1353597.1600199178.1@sss.pgh.pa.us> Date: Tue, 15 Sep 2020 15:46:18 -0400 Message-ID: <1353598.1600199178@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk I wrote: > [ $subject ] I found some time to trace this down, and what it turns out to be is that apply_handle_truncate() is making use of a LogicalRepRelMapEntry's localreloid field without any consideration for the possibility that that's been set to zero as a result of a cache flush. The visible symptom of "cache lookup failed for relation 0" comes from trying to invoke find_all_inheritors with a zero OID. Now, study of apply_handle_truncate doesn't immediately reveal where a cache flush could have occurred, but I realized that it's actually possible that the LogicalRepRelMapEntry is *already* marked invalid when logicalrep_rel_open() returns! That's because for some reason it does GetSubscriptionRelState last, after it's already marked the entry valid, and that function does plenty o' catalog accesses. It's not really clear to me why setting localreloid to zero is a sane way to represent "this entry needs to be revalidated". I think a separate flag would be more appropriate. Once we have lock on the target relation, it seems to me that no interesting changes should be possible as long as we have lock; so there's no very good reason to destroy useful state to remind ourselves that we should recheck it next time. regards, tom lane