Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qMvhJ-003cxr-1z for pgsql-bugs@arkaria.postgresql.org; Fri, 21 Jul 2023 19:21:52 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1qMvhH-006uXu-Fh for pgsql-bugs@arkaria.postgresql.org; Fri, 21 Jul 2023 19:21:51 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qMvhH-006uXl-76 for pgsql-bugs@lists.postgresql.org; Fri, 21 Jul 2023 19:21:51 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qMvhE-000ja4-P3 for pgsql-bugs@lists.postgresql.org; Fri, 21 Jul 2023 19:21:50 +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 36LJLkZs982077; Fri, 21 Jul 2023 15:21:46 -0400 From: Tom Lane To: Alexander Lakhin cc: Kyotaro Horiguchi , pgsql-bugs@lists.postgresql.org Subject: Re: BUG #18014: Releasing catcache entries makes schema_to_xmlschema() fail when parallel workers are used In-reply-to: <00e24aa6-5d03-99b6-ab41-495a35fc93f6@gmail.com> References: <20230720.162802.905550494964943231.horikyota.ntt@gmail.com> <20230720.164459.2183367718473165651.horikyota.ntt@gmail.com> <20230720.172924.535889842187000361.horikyota.ntt@gmail.com> <1a2d5aba-df29-ab8d-65ac-6ffd54d1ac62@gmail.com> <969017.1689960055@sss.pgh.pa.us> <00e24aa6-5d03-99b6-ab41-495a35fc93f6@gmail.com> Comments: In-reply-to Alexander Lakhin message dated "Fri, 21 Jul 2023 22:00:01 +0300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <982075.1689967306.1@sss.pgh.pa.us> Date: Fri, 21 Jul 2023 15:21:46 -0400 Message-ID: <982076.1689967306@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Alexander Lakhin writes: > 21.07.2023 20:20, Tom Lane wrote: >> I like #2 better if it's not hard to do cleanly. However, I'm not >> quite sure how we are getting to an inval during relation close; >> maybe that's not something we want to prevent. > Yes, there is a detailed comment in LockRelationOid(), that explains why > AcceptInvalidationMessages() is called. (I've tried to remove that call > now, just for testing, and get 6 tests failed during `make check`.) Yes, we certainly want to do that during LockRelationOid. But what seems to be happening here is an inval while we are closing/unlocking the catalog we got the syscache entry from. That is, the expected behavior here is: SearchSysCacheExists: * is entry present-and-valid? No, so... * open and lock relevant catalog (with possible inval) * scan catalog, find desired row, create valid syscache entry * close and unlock catalog * return success SearchSysCache1 (from pg_class_aclmask_ext): * is entry present-and-valid? Yes, so increment its refcount and return it There is no inval in the entry-already-present code path in syscache lookup. So if we are seeing this failure, ISTM it must mean that an inval is happening during "close and unlock catalog", which seems like something that we don't want. But I've not traced exactly how that happens. regards, tom lane