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 1pDjPl-00011Z-KG for pgsql-hackers@arkaria.postgresql.org; Fri, 06 Jan 2023 09:53:29 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pDjPk-0000Zx-02 for pgsql-hackers@arkaria.postgresql.org; Fri, 06 Jan 2023 09:53:28 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pDjPj-0000Yu-GL for pgsql-hackers@lists.postgresql.org; Fri, 06 Jan 2023 09:53:27 +0000 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pDjPg-0007Xq-Ry for pgsql-hackers@postgresql.org; Fri, 06 Jan 2023 09:53:26 +0000 Received: by mail-wm1-x334.google.com with SMTP id g25-20020a7bc4d9000000b003d97c8d4941so3157980wmk.4 for ; Fri, 06 Jan 2023 01:53:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=jT+vXhJX3qXdM4VEHZmSf3OzOf6/eiF561PiOrjqlWI=; b=aeOd8DC8yzApOdg828TI0OQ/1nHDGQDBTrzLQNJLaqmvEkFK3chMS5lJvywlrIzyVX TjKKdwjbOh2j44X25BQ3Gt9X60RRD5gd4spszq83FMoFDnjBoDZPyWpRNOPKDqb0QmCM Pr+3YE207d0ffAnj+fns9tLbZJqfbaAumAVvx5VsG2M32S2ZQ6WxvN+Olpp2AjrK2LMd NlXOCLRABfdVmY9FGNn1r2dp/a09R/dEyxIjW3o/0fqw2xmiaY2KlYuKyPTL6xGn+2yg miYogIskGsPy25DPmRvsNPoNPV1EDHBcqf5pNPhFDoL9MB0+1fY5bBcXveVuAQk1LmsG RUZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=jT+vXhJX3qXdM4VEHZmSf3OzOf6/eiF561PiOrjqlWI=; b=aALYUDVRnRQq72vmV5Uaj5uGPDzBN54f0M40ZJOY6X613dxKNxGoXC5Ixlz702HlV/ l8D6YWI39yqpCu83HzJ/nRYJwS94GKp0gTMvhL0zR4fimU3lme1uNwWIMgupilV+Q/KG 0+wvfomY0q3hbqQlMC8H9XeTAapSpxcoatUKm+iMfndU66IXHKdqnI/1YrccMVqTW4fG 3Wqse+LvKiDKc4n12lI70sXDjT72A2eHfOAfk0yhZz1XjUeA9jqbEGmWtZNol/rev1/Q Y8SblPvY2+/E2j1mJDiwYTrM+7FF1hhO99L6kqsNBzWUM2qLlzCe5lwsD3EMwJYi1br/ jjng== X-Gm-Message-State: AFqh2krVz34ixeDXHPQ1d4bg/Zg8zQmApW0rTmgvTDoBbqXGNKcafORg jdzIL0RibLttVq+5R4wl24w= X-Google-Smtp-Source: AMrXdXvkgG2X6eX5Kxq7b5r7w8Gu9EHfQiF1ZMNUdaVCyf7CDSCoNqGKK8TCUwKzQmLsrMA33mMPQA== X-Received: by 2002:a05:600c:1f12:b0:3d2:267d:64bd with SMTP id bd18-20020a05600c1f1200b003d2267d64bdmr46770647wmb.3.1672998803194; Fri, 06 Jan 2023 01:53:23 -0800 (PST) Received: from [192.168.13.142] ([54.239.6.186]) by smtp.gmail.com with ESMTPSA id m18-20020a05600c4f5200b003c6b70a4d69sm1208099wmq.42.2023.01.06.01.53.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 06 Jan 2023 01:53:22 -0800 (PST) Message-ID: <5c5151a6-a1a3-6c38-7d68-543c9faa22f4@gmail.com> Date: Fri, 6 Jan 2023 10:52:06 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 Subject: Re: Minimal logical decoding on standbys Content-Language: en-US To: Andres Freund , Robert Haas , Thomas Munro Cc: Alvaro Herrera , Ibrar Ahmed , Amit Khandekar , fabriziomello@gmail.com, tushar , Rahila Syed , pgsql-hackers References: <20221214173552.sshklqvwezeo52h3@alap3.anarazel.de> <1f2ad9fd-53ff-74cc-a602-72d45423bcab@gmail.com> <05c0c4f3-82eb-bc6d-c876-5a265c05927b@gmail.com> <20230106034036.2m4qnn7ep7b5ipet@awork3.anarazel.de> From: "Drouvot, Bertrand" In-Reply-To: <20230106034036.2m4qnn7ep7b5ipet@awork3.anarazel.de> 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 Hi, On 1/6/23 4:40 AM, Andres Freund wrote: > Hi, > > Thomas, there's one point at the bottom wrt ConditionVariables that'd be > interesting for you to comment on. > > > On 2023-01-05 16:15:39 -0500, Robert Haas wrote: >> On Tue, Jan 3, 2023 at 2:42 AM Drouvot, Bertrand >> wrote: >>> Please find attached v36, tiny rebase due to 1de58df4fe. >> >> 0001 looks committable to me now, though we probably shouldn't do that >> unless we're pretty confident about shipping enough of the rest of >> this to accomplish something useful. > Thanks for your precious help reaching this state! > Cool! > > ISTM that the ordering of patches isn't quite right later on. ISTM that it > doesn't make sense to introduce working logic decoding without first fixing > WalSndWaitForWal() (i.e. patch 0006). What made you order the patches that > way? > Idea was to ease the review: 0001 to 0005 to introduce the feature and 0006 to deal with this race condition. I thought it would be easier to review that way (given the complexity of "just" adding the feature itself). > 0001: >> 4. We can't rely on the standby's relcache entries for this purpose in >> any way, because the WAL record that causes the problem might be >> replayed before the standby even reaches consistency. > > The startup process can't access catalog contents in the first place, so the > consistency issue is secondary. > Thanks for pointing out, I'll update the commit message. > > ISTM that the commit message omits a fairly significant portion of the change: > The introduction of indisusercatalog / the reason for its introduction. Agree, will do (or create a dedicated path as you are suggesting below). > > Why is indisusercatalog stored as "full" column, whereas we store the fact of > table being used as a catalog table in a reloption? I'm not adverse to moving > to a full column, but then I think we should do the same for tables. > > Earlier version of the patches IIRC sourced the "catalogness" from the > relation. What lead you to changing that? I'm not saying it's wrong, just not > sure it's right either. That's right it's started retrieving this information from the relation. Then, Robert made a comment in [1] saying it's not safe to call table_open() while holding a buffer lock. Then, I worked on other options and submitted the current one. While reviewing 0001, Robert's also thought of it (see [2])) and finished with: " So while I do not really like the approach of storing the same property in different ways for tables and for indexes, it's also not really obvious to me how to do better. " That's also my thought. > > It'd be good to introduce cross-checks that indisusercatalog is set > correctly. RelationGetIndexList() seems like a good candidate. > Good point, will look at it. > I'd probably split the introduction of indisusercatalog into a separate patch. You mean, completely outside of this patch series or a sub-patch in this series? If the former, I'm not sure it would make sense outside of the current context. > > Why was HEAP_DEFAULT_USER_CATALOG_TABLE introduced in this patch? > > To help in case of reset on the table (ensure the default gets also propagated to the indexes). > I wonder if we instead should compute a relation's "catalogness" in the > relcache. That'd would have the advantage of making > RelationIsUsedAsCatalogTable() cheaper and working for all kinds of > relations. > Any idea on where and how you'd do that? (that's one option I explored in vain before submitting the current proposal). It does look like that's also an option explored by Robert in [2]: " Yet a third way is to have the index fetch the flag from the associated table, perhaps when the relcache entry is built. But I see no existing precedent for that in RelationInitIndexAccessInfo, which I think is where it would be if we had it -- and that makes me suspect that there might be good reasons why this isn't actually safe. " > > VISIBILITYMAP_ON_CATALOG_ACCESSIBLE_IN_LOGICAL_DECODING is a very long > identifier. Given that the field in the xlog records is just named > isCatalogRel, any reason to not just name it correspondingly? > Agree, VISIBILITYMAP_IS_CATALOG_REL maybe? I'll look at the other comments too and work on/reply later on. [1]: https://www.postgresql.org/message-id/CA%2BTgmobgOLH-JpBoBSdu4i%2BsjRdgwmDEZGECkmowXqQgQL6WhQ%40mail.gmail.com [2]: https://www.postgresql.org/message-id/CA%2BTgmoY0df9X%2B5ENg8P0BGj0odhM45sdQ7kB4JMo4NKaoFy-Vg%40mail.gmail.com Thanks for your help, Regards, -- Bertrand Drouvot PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com