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 1qOEpt-007ED3-Jj for pgsql-bugs@arkaria.postgresql.org; Tue, 25 Jul 2023 10:00:09 +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 1qOEpr-00Fkwm-3k for pgsql-bugs@arkaria.postgresql.org; Tue, 25 Jul 2023 10:00:07 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qOEpq-00FkwZ-Q3 for pgsql-bugs@lists.postgresql.org; Tue, 25 Jul 2023 10:00:06 +0000 Received: from mail-lf1-x134.google.com ([2a00:1450:4864:20::134]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1qOEpo-000EnW-I9 for pgsql-bugs@lists.postgresql.org; Tue, 25 Jul 2023 10:00:06 +0000 Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-4fdfefdf5abso1193994e87.1 for ; Tue, 25 Jul 2023 03:00:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690279203; x=1690884003; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=01/VzJOfyfOJvWXlRmPT9hPoQDJCyGq0D2lfek8+I1w=; b=KdGtMiSpoC1ju3i3EmN7af36yYwDrC0ka9cd68600k9Bnb5qVE4DZxqsa2eU7HOnPh 8a8VGwQeI//ofntbQib/L/T+ZvkJjHzL7ZbrYwFjzBGuA/znMNeTGW1wMMh8LdHQ8WgQ A1DVrxnioq25pLn6ijLo/YwN+g7fSKztndDwNhDMcTB+QJA0XUshXBPEwl5JyvvspQ7F noB+VlVW3925etJTIWiaom0m3CTVB/4qtoEwUThkTCvXe60eGO8hRTT6iXRaNgTO8wNc zSKh360umOd7ZEJXzdLDQd/Zji97/lfSCO2W20Y6VWcKqFFq5CtSMKZz6HaHPu/bZeyF ZLkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690279203; x=1690884003; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=01/VzJOfyfOJvWXlRmPT9hPoQDJCyGq0D2lfek8+I1w=; b=YIENL91JDP4R20NE443/2jNNQztvaaZUI7F1xfmM8wCeqB+E1oEn8DCuRMwu+hf3+Z FgNAFdwMHWmybtgWy/yoYj5VRJrWD5SFMmVNlrKeraVPf1eFKzUhTP6bj4JFG7Q5bSPV d6WM4FTaov+gNCquGGBNscyyX0eCJxexVdFUT05i9p1npfMxvXwk2eFfKS12PN2N/9aw i/uUxGRZvIdNVwQvBorv6HnVmnbrCPQVqX8QcsEJxUuhalexd3dGzBPnehOTypXwak81 cvP9JKbL5r6tsnxq4ps5yqurluegiGv1v5maCCpqmaNMx29LtpGycfhKbRjyNqbuNTCd wHHg== X-Gm-Message-State: ABy/qLZk/p4+pKwSDXjmWVVdVjxDF9xzcdHMVA6HUeA2vVunWn1zeBOk bfD7Y61QMPfrTZksU+ZNVA0= X-Google-Smtp-Source: APBJJlGXzlWGuy/RfRXYt/+cmWJWIC7n9uUomhIGN+Jgc3wK2JKQvn4n+RyhQNiCQMCqoeAh8CNzXA== X-Received: by 2002:a05:6512:3e05:b0:4fe:8c4:44f6 with SMTP id i5-20020a0565123e0500b004fe08c444f6mr813895lfv.56.1690279202786; Tue, 25 Jul 2023 03:00:02 -0700 (PDT) Received: from [1.0.0.7] ([178.155.25.194]) by smtp.gmail.com with ESMTPSA id d12-20020ac244cc000000b004fddb0eb960sm2680434lfm.165.2023.07.25.03.00.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 25 Jul 2023 03:00:02 -0700 (PDT) Message-ID: <5bd4cbfe-fc71-c576-851d-3bb21ef5c080@gmail.com> Date: Tue, 25 Jul 2023 13:00:00 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: BUG #18014: Releasing catcache entries makes schema_to_xmlschema() fail when parallel workers are used Content-Language: en-US To: Tom Lane Cc: Kyotaro Horiguchi , pgsql-bugs@lists.postgresql.org 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> <982076.1689967306@sss.pgh.pa.us> From: Alexander Lakhin In-Reply-To: <982076.1689967306@sss.pgh.pa.us> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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/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. 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() ->  ReleaseSysCache(tuple) -> ReleaseCatCache(tuple). So, while the construction "if (SearchSysCacheExists()) ... SearchSysCache1()" seems robust for normal conditions, it might be broken when catcache 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 (on level 1). Best regards, Alexander