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 1qrJe5-003f0v-Md for pgsql-bugs@arkaria.postgresql.org; Fri, 13 Oct 2023 15: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 1qrJe3-001luo-Cv for pgsql-bugs@arkaria.postgresql.org; Fri, 13 Oct 2023 15:00:08 +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 1qrJe3-001ltX-4S for pgsql-bugs@lists.postgresql.org; Fri, 13 Oct 2023 15:00:07 +0000 Received: from mail-lf1-x136.google.com ([2a00:1450:4864:20::136]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1qrJe1-000JDM-Gz for pgsql-bugs@lists.postgresql.org; Fri, 13 Oct 2023 15:00:06 +0000 Received: by mail-lf1-x136.google.com with SMTP id 2adb3069b0e04-50433d8385cso2929898e87.0 for ; Fri, 13 Oct 2023 08:00:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697209204; x=1697814004; darn=lists.postgresql.org; 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=H/GObC3vQXpi/h1tlpj6Tosh3s+AMhrzMbafUBU6KlI=; b=g/3Iu26pDsZ+L7nl/CUEzNhBJBSmJiqVB23y4nMvNcmLqOLEzj8dbqJTNHvVPWkrp5 CkTzMVZVwDPZfvXmj3UZDYa9sS3HGX0+4sZO6QlDvs1mxfMMxfFlELIZmGcjr/I/mrvW YL1iejj0/UqkYcbmjXvo2NLQjq+1hvkzzTgUo17Ze4bfA3GIbCD1RayQftuxXh5pGxvN T0dxwFtcHk3IL0mobjIzc99pDh0fTavD3KuHqW/ftX/46BGVs1TXRw1Oxo8zC2EUbUYI nK2wWVC0Hu5tkHIKtYAC+4SiE4+wAaPNDFhiUcCr4ZnTqH0cOy68AOaz9mjPT6Zc/fBc E67w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697209204; x=1697814004; 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=H/GObC3vQXpi/h1tlpj6Tosh3s+AMhrzMbafUBU6KlI=; b=H06v0zsJV3LMfVORGSNL4mqvMT2CBoeZD0WoTsKFs+C4PHlFEu2HSlvboqQf9a0TMw 04SPdvxlUiGKkiiNpblUvPkmyliPMbNMCpLEhIY9TSvPz0Gx+OtE2Jq5X4+alWUdTopx KdOrmWJMMQKHGC5bpb8z+yFro3bV/NDkB4IFlqpYxuaqTkcsy3m9kGNd9Gwcdv4XwTTn fxR5fqhzuAvQIrN7PW+FE+J3egr4+zkymkY4HL6hQe14OrE/Uyf+vev8EH1uZjPRb1OS teoVIWOwrxW0iNECL+Uay2tdUb7IGzpPFKitFbZCSJUza6WLj6Y3P3/9vwWuSnl4AL9l L+2A== X-Gm-Message-State: AOJu0YxF5xKeViTkN9jRy+pmRqgOoDoQMHzlpXiZHLiS6Nu9Z5uNhnZp W5/7X0RyZotixP7HtuGfqP0= X-Google-Smtp-Source: AGHT+IHbdN68qXWCdm3NqnFU6NPFFAQS7ihwlUNQqjxbqPlIn6YpialsVJfGP1Te91lPOu10mlM7Ag== X-Received: by 2002:ac2:4f0f:0:b0:500:ac0b:8d58 with SMTP id k15-20020ac24f0f000000b00500ac0b8d58mr26524981lfr.18.1697209203660; Fri, 13 Oct 2023 08:00:03 -0700 (PDT) Received: from [1.0.0.7] ([81.23.166.137]) by smtp.gmail.com with ESMTPSA id m14-20020ac2428e000000b005032ebf8a00sm3355637lfh.197.2023.10.13.08.00.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 13 Oct 2023 08:00:02 -0700 (PDT) Message-ID: <5df89a35-a985-b287-7210-6ed7d2c31803@gmail.com> Date: Fri, 13 Oct 2023 18: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 , Michael Paquier Cc: Kyotaro Horiguchi , pgsql-bugs@lists.postgresql.org References: <00e24aa6-5d03-99b6-ab41-495a35fc93f6@gmail.com> <982076.1689967306@sss.pgh.pa.us> <5bd4cbfe-fc71-c576-851d-3bb21ef5c080@gmail.com> <20230726.112923.27361680552823861.horikyota.ntt@gmail.com> <1821881.1690339317@sss.pgh.pa.us> <1830960.1690343673@sss.pgh.pa.us> <1389919.1697144487@sss.pgh.pa.us> From: Alexander Lakhin In-Reply-To: <1389919.1697144487@sss.pgh.pa.us> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hello Tom, 13.10.2023 00:01, Tom Lane wrote: > I came back to this question today, and after more thought I'm going > to cast my vote for "let's not trust SearchSysCacheExists()+lookup". > It just seems like that's too fragile. The case reported in this > thread of it failing in parallel workers but not main should scare > anybody, and the future course of development seems far more likely > to introduce new problems than remove them. Thanks for digging into this! > I spent some time looking through existing SearchSysCacheExists calls, > and I could only find two sets of routines where we seem to be > depending on SearchSysCacheExists to protect a subsequent lookup > somewhere else, and there isn't any lock on the object in question. > Those are the has_foo_privilege functions discussed here, and the > foo_is_visible functions near the bottom of namespace.c. I'm not > sure why we've not heard complaints traceable to the foo_is_visible > family. Maybe nobody has tried hard to break them, or maybe they > are just less likely to be used in ways that are at risk. I'll try to research/break xxx_is_visible and share my findings tomorrow. > It turns out to not be that hard to get rid of the problem in the > has_foo_privilege family, as per attached patches. I've not looked > at fixing the foo_is_visible family, but that probably ought to be a > separate patch anyway. Yeah, the attached patches greatly improve consistency. The only inconsistency I've found in the patches is a missing comma here: + * Exported generic routine for checking a user's access privileges to an object + * with is_missing You removed "this case is not a user-facing error, so elog not ereport", and I think it's good for consistency too, as all aclmask/aclcheck functions now use ereport(). > BTW, while nosing around I found what seems like a very nasty related > bug. Suppose that a catalog tuple being loaded into syscache contains > some toasted fields. CatalogCacheCreateEntry will flatten the tuple, > involving fetches from toast tables that will certainly cause > AcceptInvalidationMessages calls. What if one of those should have > invalidated this tuple? We will not notice, because it's not in > the hashtable yet. When we do add it, we will mark it not-dead, > meaning that the stale entry looks fine and could persist for a long > while. Yeah, it's an interesting case that needs investigation, IMO. I'll try to look into this and construct the test case in the background. > 0001's changes in acl.c are straightforward, but it's worth noting > that the has_sequence_privilege functions hadn't gotten the memo > about not failing when a bogus relation OID is passed. I've looked through all functions has_*priv*_id and all they have "if (is_missing) PG_RETURN_NULL()" now (with the patches applied). Best regards, Alexander