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 1qOUHR-007zkq-Py for pgsql-bugs@arkaria.postgresql.org; Wed, 26 Jul 2023 02:29:37 +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 1qOUHP-001hEH-0D for pgsql-bugs@arkaria.postgresql.org; Wed, 26 Jul 2023 02:29:35 +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 1qOUHO-001hE9-N4 for pgsql-bugs@lists.postgresql.org; Wed, 26 Jul 2023 02:29:34 +0000 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1qOUHH-001bBr-Q9 for pgsql-bugs@lists.postgresql.org; Wed, 26 Jul 2023 02:29:33 +0000 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1bba54f7eefso3158055ad.1 for ; Tue, 25 Jul 2023 19:29:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690338566; x=1690943366; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:from:subject:cc:to:message-id:date:from:to:cc:subject :date:message-id:reply-to; bh=3HXem0kzeQgYAyq2fUvHtsXcr6ntl69r+oDwTYVFTqA=; b=FKyRymQkBDeH0EQLqOa/9P4ENU8BX9Zm1U7Bzs/06RCC5Vdc2g1hkhv9enD00T1vXZ 2PYCAYZtv2slQxPDi28G14W19VoXx9SjatRXiuEs80fDu2130zvl5xGGgs2XT3CK/B9t 2hwE2VKPDCpze9763zm/NeAdrcgBPMeWvygEO443wCGfWNVJvt2wzU11iUn053k6wCBc ABGFAvGwXO187qYk6JBnFQNFQv8TTn6pPIcTPuadUpsdzov0B8Icv9+iCmMH/l7lxHh/ lUtmHkJflbKwdscVELcpZe8R+4XkbtRLETBs8tUXce7mxwUMEBVqKSItWpOge5aOUJyn Z6xw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690338566; x=1690943366; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:from:subject:cc:to:message-id:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=3HXem0kzeQgYAyq2fUvHtsXcr6ntl69r+oDwTYVFTqA=; b=SbQ9pWWTS0jaVfb8tZute9FtUUPcAZ2XbxIzjfvBG74NhvQC32XMvkvdPggdDMc/HI yC+C/O/fVR54lmbnYsQW7yFVEz26Jh6m5U+kUABohOJ6m5nafWmb+G3uuPyOWprZN4xW ybF46/QESXPuUhJcxCMWTPcpJkhkTofVpk/DatiGTtl7ZOxESlwcjmWxVY+X0LaDeS6E 5JCUQFBj/gi1wh9+rzPYk4p/IgYgxHuTYVJi+GTPNuI40RPdr6WPzx2dNgaeYXehOd/C GP+dIpbHbJMDzVapNOx/SsgJk9BLZENheGSM8fYYNKw/feMCBEtkV1U+ImT8VgJn9rmg n3pA== X-Gm-Message-State: ABy/qLa67OL/sTvrKnCAfLUjx1TLynM+2p8s0eCCz1Toh8Jr5xe0TGwR XfySYpwjsxq2WQP3Ry5NW/s= X-Google-Smtp-Source: APBJJlGF2wgDi0EYDJEuL32a9ZBTFbkG0BJmFiWexAnLQNgsyJYaUl35CdX+I7TTQtIEWkk9H5Opgg== X-Received: by 2002:a17:902:dac3:b0:1b8:6952:5381 with SMTP id q3-20020a170902dac300b001b869525381mr1204232plx.9.1690338566312; Tue, 25 Jul 2023 19:29:26 -0700 (PDT) Received: from localhost (KD036014041111.ppp-bb.dion.ne.jp. [36.14.41.111]) by smtp.gmail.com with ESMTPSA id p8-20020a170902b08800b001b531e8a000sm282486plr.157.2023.07.25.19.29.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jul 2023 19:29:25 -0700 (PDT) Date: Wed, 26 Jul 2023 11:29:23 +0900 (JST) Message-Id: <20230726.112923.27361680552823861.horikyota.ntt@gmail.com> To: exclusion@gmail.com Cc: tgl@sss.pgh.pa.us, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #18014: Releasing catcache entries makes schema_to_xmlschema() fail when parallel workers are used From: Kyotaro Horiguchi In-Reply-To: <5bd4cbfe-fc71-c576-851d-3bb21ef5c080@gmail.com> References: <00e24aa6-5d03-99b6-ab41-495a35fc93f6@gmail.com> <982076.1689967306@sss.pgh.pa.us> <5bd4cbfe-fc71-c576-851d-3bb21ef5c080@gmail.com> User-Agent: Mew version 6.8 on Emacs 27.2 Mime-Version: 1.0 Content-Type: Text/Plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk At Tue, 25 Jul 2023 13:00:00 +0300, Alexander Lakhin wrote in = > Hi Tom, > = > 21.07.2023 22:21, Tom Lane wrote: > > Yes, we certainly want to do that during LockRelationOid. But what= > > seems to be happening here is an inval while we are closing/unlocki= ng > > 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 syscach= e > > lookup. So if we are seeing this failure, ISTM it must mean that a= n > > inval is happening during "close and unlock catalog", which seems l= ike > > something that we don't want. But I've not traced exactly how that= > > happens. > = > Yes, but here we deal with -DCATCACHE_FORCE_RELEASE (added to > config_env > on prion), so the cache entry, that was just found in > SearchSysCacheExists(), is removed immediately because of > SearchSysCacheExists() ->=A0 ReleaseSysCache(tuple) -> > ReleaseCatCache(tuple). > = > So, while the construction "if (SearchSysCacheExists()) > ... SearchSysCache1()" > seems robust for normal conditions, it might be broken when catcache I agree about the safety of the construct. > entries > released forcefully. Thus, if the worst consequence of the issue is > sporadic > test failures on prion, then may be fix it in a least invasive way (o= n > level 1). > 1) test xmlmap fails sporadically due to the catalog changes caused b= y > parallel tests activity > 2) schema_to_xmlschemaX() can fail when parallel workers are used > 3) has_table_privilegeX() can fail sporadically when executed within = a > parallel worker Doesn't this imply that the function isn't parallel-safe? The issue is gone by marking it and all variants as parallel-restricted. It seems to be a reasolable way to address this issue. > 4) SearchSysCacheX(RELOID, ...) can switch to a newer catalog snapsho= t, > when repeated in a parallel worker regards. -- = Kyotaro Horiguchi NTT Open Source Software Center