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 1p5lWs-0007Ir-3d for pgsql-hackers@arkaria.postgresql.org; Thu, 15 Dec 2022 10:31:54 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1p5lWq-0005LT-LI for pgsql-hackers@arkaria.postgresql.org; Thu, 15 Dec 2022 10:31:52 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p5lWq-0005LK-Af for pgsql-hackers@lists.postgresql.org; Thu, 15 Dec 2022 10:31:52 +0000 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1p5lWj-00047s-C4 for pgsql-hackers@postgresql.org; Thu, 15 Dec 2022 10:31:51 +0000 Received: by mail-wr1-x432.google.com with SMTP id h12so2534550wrv.10 for ; Thu, 15 Dec 2022 02:31:44 -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=g/t+fjd+3g470ABkgDD01MhR6InH/YEnLszGUhOHPpc=; b=TS5XubcnnjlqUxJMKMdmkPcJgPWggNbokyrYt4aDbuKGjJ9b7TZ++DG32bXaOOJ7oK jjfPLVbP9IPbcGeCoWg3Z5Anx0iae5Q8ZLvN1RL/oj646K/fv3/++CA+9gVjNzcC3a7q TRdDUrmAnsaZ+9MrPL5kYXNKVSVAzvfbrsHIQAQaxbXuNmfQni86jo4wVB1p8CCQeJDG qo2ieOoQ4dahpjtYBLvXAe8XbcfCSP/bwSs2ZrV1i2DlKmhEIIQvo0jJqkzg8Q/h1k6c zsj3enFWiZF1Hik6zFtDXd5VaL9reLKccYgsm/15ZAGl+Z3mWDCntO85Z0IaCZ81nJ+e XIZQ== 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=g/t+fjd+3g470ABkgDD01MhR6InH/YEnLszGUhOHPpc=; b=mqZ8a6yollBm3FSuCJFzm3vvPTKTahsmqj89XoSFOUk+L+0MuCgq+NuYjyBjhw1hs2 1B5SZbpWvOs4i2aq3LSiRU1aq6scjVPcNFhashSy9t2hjv1D6pkAqCBRwVAus9QLi3NB bc8Qc+kcHlirNcY0ipFPoNm8PL2A9xTfbP4SB/o+2TVwN1ZuohOQ+URmRRWcHC86xW80 IP25TX4PfX/jr4bfl7UcWBiSij4C9CqoymLPB2vbFSkI0KJJWsNmHTS5qk92e6gHZ9E0 HqWWZIcSeEQrjH8z2I4SnssQyIds/i5UfOBg68mkBYsD//8u/F1atVd1PY8sM91lpzaV F8mw== X-Gm-Message-State: ANoB5pldJBT6NmiHfK7rUtw1CP5xdQEmq/MxIFjcD7Ix73/QWuJFXja7 3JABHPgf1nnvCNITIMCXpKw= X-Google-Smtp-Source: AA0mqf7l7nX9KKSo5bxObtWj3hsQXpsoCNxQP0O93G6U2X2HPw2Mqff9kE6FUIgiHrzZRPPMH2CmBw== X-Received: by 2002:a5d:51cd:0:b0:242:17d3:a9f9 with SMTP id n13-20020a5d51cd000000b0024217d3a9f9mr17012048wrv.68.1671100303738; Thu, 15 Dec 2022 02:31:43 -0800 (PST) Received: from [192.168.12.242] ([54.239.6.185]) by smtp.gmail.com with ESMTPSA id a12-20020a5d4d4c000000b00241bd177f89sm5658628wru.14.2022.12.15.02.31.42 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 15 Dec 2022 02:31:43 -0800 (PST) Message-ID: Date: Thu, 15 Dec 2022 11:31:42 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.5.1 Subject: Re: Minimal logical decoding on standbys Content-Language: en-US To: Robert Haas Cc: Andres Freund , Alvaro Herrera , Ibrar Ahmed , Amit Khandekar , fabriziomello@gmail.com, tushar , Rahila Syed , pgsql-hackers References: <688cbedf-a172-f0d8-8352-d4ea223bceeb@amazon.com> <20211028210755.afmwcvpo6ajwdx6n@alap3.anarazel.de> <6711d09f-eaa9-264b-ec7f-88004218b075@amazon.com> <178cf7da-9bd7-e328-9c49-e28ac4701352@gmail.com> <4b19419f-2e7c-a76b-c948-26d10af6693d@gmail.com> <20221207175824.apmc5clnj2fdjkaq@awork3.anarazel.de> <09c26df0-c5f9-eae0-5a6a-10fb00b0522e@gmail.com> <9f0a021e-40e1-0ae6-8086-a4457c99749e@gmail.com> <0ae83e69-bda0-0eb8-ef4a-d169292e3f66@gmail.com> <47f5faf0-6a6d-602a-5d5b-9449ca74c6ad@gmail.com> From: "Drouvot, Bertrand" In-Reply-To: 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 12/14/22 4:55 PM, Robert Haas wrote: > On Wed, Dec 14, 2022 at 8:06 AM Drouvot, Bertrand> > Other comments: > > + if RelationIsAccessibleInLogicalDecoding(rel) > + xlrec.flags |= VISIBILITYMAP_ON_CATALOG_ACCESSIBLE_IN_LOGICAL_DECODING; > > This is a few parentheses short of where it should be. Hilariously it > still compiles because there are parentheses in the macro definition. Oops, thanks will fix. > > + xlrec.onCatalogAccessibleInLogicalDecoding = > RelationIsAccessibleInLogicalDecoding(relation); > > These lines are quite long. I think we should consider (1) picking a > shorter name for the xlrec field and, if it's such lines are going to > still routinely exceed 80 characters, (2) splitting them into two > lines, with the second one indented to match pgindent's preferences in > such cases, which I think is something like this: > > xlrec.onCatalogAccessibleInLogicalDecoding = > RelationIsAccessibleInLogicalDecoding(relation); > > As far as renaming, I think we could at least remove onCatalog part > from the identifier, as that doesn't seem to be adding much. And maybe > we could even think of changing it to something like > logicalDecodingConflict or even decodingConflict, which would shave > off a bunch more characters. I'm not sure I like the decodingConflict proposal. Indeed, it might be there is no conflict (depending of the xids comparison). What about "checkForConflict"? > > + if (heapRelation->rd_options) > + isusercatalog = ((StdRdOptions *) > (heapRelation)->rd_options)->user_catalog_table; > > Couldn't you get rid of the if statement here and also the > initialization at the top of the function and just write isusercatalog > = RelationIsUsedAsCatalogTable(heapRelation)? Or even just get rid of > the variable entirely and pass > RelationIsUsedAsCatalogTable(heapRelation) as the argument to > UpdateIndexRelation directly? > Yeah, that's better, will do, thanks! While at it, I'm not sure that isusercatalog should be visible in pg_index. I mean, this information could be retrieved with a join on pg_class (on the table the index is linked to), so the weirdness to have it visible. I did not check how difficult it would be to make it "invisible" though. What do you think? > I think this could use some test cases demonstrating that > indisusercatalog gets set correctly in all the relevant cases: table > is created with user_catalog_table = true/false, reloption is changed, > reloptions are reset, new index is added later, etc. > v31 already provides a few checks: - After index creation on relation with user_catalog_table = true - Propagation is done correctly after a user_catalog_table RESET - Propagation is done correctly after an ALTER SET user_catalog_table = true - Propagation is done correctly after an ALTER SET user_catalog_table = false In v32, I can add a check for index creation after each of the last 3 mentioned above and one when a table is created with user_catalog_table = false. Having said that, we would need a function to retrieve the isusercatalog value should we make it invisible. Regards, -- Bertrand Drouvot PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com