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 1nSejC-0002mJ-Aq for pgsql-hackers@arkaria.postgresql.org; Fri, 11 Mar 2022 12:50:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nSej9-0006l7-OS for pgsql-hackers@arkaria.postgresql.org; Fri, 11 Mar 2022 12:50:39 +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 1nSej9-0006kx-1l for pgsql-hackers@lists.postgresql.org; Fri, 11 Mar 2022 12:50:39 +0000 Received: from mail-ej1-x62a.google.com ([2a00:1450:4864:20::62a]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nSej5-0003O8-Ky for pgsql-hackers@postgresql.org; Fri, 11 Mar 2022 12:50:37 +0000 Received: by mail-ej1-x62a.google.com with SMTP id dr20so18753144ejc.6 for ; Fri, 11 Mar 2022 04:50:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:in-reply-to:content-transfer-encoding; bh=9GzR/6Ike3z5zEja85//zAxOOJH5je8uz5L4JKLSgJM=; b=HeoxbgQS9ECC+NpBZarXaUj44+//NmgMPKbl48ZPAHUj/0L96JoPfnu5L1pTGTRJvO 8Rz8Uqb6MYuz3oJ0RJ0RIbOIYvQlcrAYmnEERGTkDAoH/PNWAgG3lZbJJr9WOqo0KYoO j2mJ8ddAw0C8S+co03xNq0tf2QXc9Xg1yZu1FksasfB1smUNYke2XycYPHKUuYvM5FkL 0GTOsiYtk9ScB0y/pQrm2fHfvuJYm/bR6nMdbAeEG5228hMuiu40dRHIKEboeWVtMMdY Q1h4RMRvOG85nGC5dmPVpNtIjMiWXW2+m5aMm5TOziiHZMuERc+oKCbzVgF/rjMeOmQM IdNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=9GzR/6Ike3z5zEja85//zAxOOJH5je8uz5L4JKLSgJM=; b=NElufIU+bRVU6C5ZNiAR2owteyizndJcRu2aTGDESwVbggoeVzfphpDwD9V8fO74wP C+r4XpZfv1Ch3B1pWKtdPVklpUcO5tPRdbYUinSy5A5zgdKF+m66rEOcHhIA36Oo5hxj 2Ehym1v/eM7u/ulvwIvYAlIe5IROkFdZQlCXM8FWJN8EvZ2ko2cw/m6wI/XabJesF0cs /gO2XDXiMQNMEPD3uu1HO6hoVdvp6gDXjRusVjSsFD6g4hfCGBRrzHSGKwziQ3keCf6b y84pClvMYwTqUPMon01nQ4ZMBO8kXKWocBByD7LpYJbGd1qSRXZtpfBeBIQEyzRw14qv Gu1g== X-Gm-Message-State: AOAM532GVltObOQeX3bLGJvpDxtcpXd42SsNkNIf8Nck66GtPlwqf/Ah MW6VH5u8cP/q9RLnWRTYI00E8nX03uvbdmtCTNUJWuB42D2HZg3D9YYq1jTqE6K/v4GR9nmmWuH +5bvhzuMarTl0zQMRh2mWj9AiGnwSrKdvH4exZX+gsIdUDyYPNlszSkez5HMxpftRrL9sS3sNkI tx7ULaknTRrmxGBBDZdwdAyesI63eeh1LURZD6 X-Google-Smtp-Source: ABdhPJz7XL8MA2n3haF9AT5ZJko7fpfRbwKhdrE9C4AbIZjOfFN5Er2JYwPBX0uGyYzQTFqNN473MA== X-Received: by 2002:a17:907:3e09:b0:6da:83e0:f2a4 with SMTP id hp9-20020a1709073e0900b006da83e0f2a4mr8719585ejc.758.1647003032950; Fri, 11 Mar 2022 04:50:32 -0800 (PST) Received: from [10.137.0.18] (ip-86-49-251-241.net.upcbroadband.cz. [86.49.251.241]) by smtp.gmail.com with ESMTPSA id u3-20020a17090657c300b006d01de78926sm2928577ejr.22.2022.03.11.04.50.31 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 11 Mar 2022 04:50:32 -0800 (PST) Message-ID: <2b8471f9-3849-c91f-ef82-9181d4bca0a7@enterprisedb.com> Date: Fri, 11 Mar 2022 13:50:29 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: Column Filtering in Logical Replication Content-Language: en-US To: Amit Kapila Cc: "houzj.fnst@fujitsu.com" , Peter Eisentraut , Alvaro Herrera , Justin Pryzby , Rahila Syed , Peter Smith , pgsql-hackers , "shiy.fnst@fujitsu.com" References: <202201120041.p24wvsfcsope@alvherre.pgsql> <78b8d385-57cb-9a3f-cfe5-9f300f15eced@enterprisedb.com> <822a8e40-287c-59ff-0ea9-35eb759f4fe6@enterprisedb.com> From: Tomas Vondra In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-CLOUD-SEC-AV-Info: enterprisedb,google_mail,monitor X-CLOUD-SEC-AV-Sent: true X-Gm-Spam: 0 X-Gm-Phishy: 0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 3/11/22 10:52, Amit Kapila wrote: > On Fri, Mar 11, 2022 at 7:26 AM Tomas Vondra > wrote: >> >> On 3/10/22 20:10, Tomas Vondra wrote: >>> >>> >>> FWIW I think the reason is pretty simple - pgoutput_row_filter_init is >>> broken. It assumes you can just do this >>> >>> rftuple = SearchSysCache2(PUBLICATIONRELMAP, >>> ObjectIdGetDatum(entry->publish_as_relid), >>> ObjectIdGetDatum(pub->oid)); >>> >>> if (HeapTupleIsValid(rftuple)) >>> { >>> /* Null indicates no filter. */ >>> rfdatum = SysCacheGetAttr(PUBLICATIONRELMAP, rftuple, >>> Anum_pg_publication_rel_prqual, >>> &pub_no_filter); >>> } >>> else >>> { >>> pub_no_filter = true; >>> } >>> >>> >>> and pub_no_filter=true means there's no filter at all. Which is >>> nonsense, because we're using publish_as_relid here - the publication >>> may not include this particular ancestor, in which case we need to just >>> ignore this publication. >>> >>> So yeah, this needs to be reworked. >>> >> >> I spent a bit of time looking at this, and I think a minor change in >> get_rel_sync_entry() fixes this - it's enough to ensure rel_publications >> only includes publications that actually include publish_as_relid. >> > > Thanks for looking into this. I think in the first patch before > calling get_partition_ancestors() we need to ensure it is a partition > (the call expects that) and pubviaroot is true. Does the call really require that? Also, I'm not sure why we'd need to look at pubviaroot - that's already considered earlier when calculating publish_as_relid, here we just need to know the relationship of the two OIDs (if one is ancestor/child of the other). > I think it would be > good if we can avoid an additional call to get_partition_ancestors() > as it could be costly. Maybe. OTOH we only should do this only very rarely anyway. > I wonder why it is not sufficient to ensure > that publish_as_relid exists after ancestor in ancestors list before > assigning the ancestor to publish_as_relid? This only needs to be done > in case of (if (!publish)). I have not tried this so I could be wrong. > I'm not sure what exactly are you proposing. Maybe try coding it? That's probably faster than trying to describe what the code might do ... regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company