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 1nSbwr-00067a-M7 for pgsql-hackers@arkaria.postgresql.org; Fri, 11 Mar 2022 09:52:37 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nSbwp-0007ZF-Ut for pgsql-hackers@arkaria.postgresql.org; Fri, 11 Mar 2022 09:52:35 +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 1nSbwp-0007Z5-Jn for pgsql-hackers@lists.postgresql.org; Fri, 11 Mar 2022 09:52:35 +0000 Received: from mail-yb1-xb2e.google.com ([2607:f8b0:4864:20::b2e]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nSbwm-0001zw-JC for pgsql-hackers@postgresql.org; Fri, 11 Mar 2022 09:52:34 +0000 Received: by mail-yb1-xb2e.google.com with SMTP id x200so16122425ybe.6 for ; Fri, 11 Mar 2022 01:52:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=yCipx7Q10Ne6/vGMzN548XuIBxqF0msHaj+AZZ+rZVI=; b=dK8Z60XjM5pIOUQQOx7F7Rfv9489edUzhYJ2xlNtwBYqlPjtyi684wd93dKs4UyL0d hA3F3pVNBfexH4V3ElO7T8SO/tZL3kb0KbA7UpOWIwWdI3K5STupVc2/6ZAQiezN+i6p KNJnMAmsAit2c70G+X7FbI4/HqCy0ZbNRNbrrqJaUKNFVJeGRgWhxuRRPUZzR0NRWGYG XnGB6sOH9lqt/D7pE1ZoUor6JjTa3Z8Q9KuAahQx7bv3MBzaF/bzSDdoqR2m98arlal0 Z6rRnWrQMmeDd3nNAVkGQb/u4Q10yskphqOdyPjsun/XKPwT5PZu5Op+SVODx6jdRRI2 KMFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=yCipx7Q10Ne6/vGMzN548XuIBxqF0msHaj+AZZ+rZVI=; b=TYJaiGLCcSMMmSyS4Se1VIRY2V19gUevzxOFerREgFFIXCQfrBUJ9cjMSMqyllDTsH IJglBEATJeP4qYYkCqUqnk0d+i83HDNu1SgYWDU6+bWa+Hq7pzc886tezk0/pzeXGIxa o3/dDOSvl2b7/o3UEBVvFO2lS+qwJODG3f2DTit4H/FVh6j/Uke+1WJv+OZDtHp1MM/I 08M8fBNHTEqMY3BASebFhSeWlymihDybbB7SQ/SKeWNGrlnAcqAilYZM6psnTKniBbX5 HITeMRWBLTwPiyS2JEIuGyHYEwZkrEIsP8/pAE71Ab+WOoaTrZ5xdyq3shEJypnYXPvs m2MQ== X-Gm-Message-State: AOAM5318sc+Y7AZcmgGEAu8DLrvO1YahHkGyxDmcPdSyDBEpM3X0HC3c XnrH+syL+rOsJEG5g0YnHSBDtJ/6qlRnoEHZc3c= X-Google-Smtp-Source: ABdhPJyFOlVOMSD61Kuwnf+rOtzAyu0Tm4v7gqtykFQxy5upA1V7THC8RC+62dcV+ZAZA+52/J/05JUxQc6bILJY878= X-Received: by 2002:a25:d987:0:b0:628:cdcc:8ab1 with SMTP id q129-20020a25d987000000b00628cdcc8ab1mr7556845ybg.448.1646992351243; Fri, 11 Mar 2022 01:52:31 -0800 (PST) MIME-Version: 1.0 References: <202201120041.p24wvsfcsope@alvherre.pgsql> <78b8d385-57cb-9a3f-cfe5-9f300f15eced@enterprisedb.com> <822a8e40-287c-59ff-0ea9-35eb759f4fe6@enterprisedb.com> In-Reply-To: <822a8e40-287c-59ff-0ea9-35eb759f4fe6@enterprisedb.com> From: Amit Kapila Date: Fri, 11 Mar 2022 15:22:19 +0530 Message-ID: Subject: Re: Column Filtering in Logical Replication To: Tomas Vondra Cc: "houzj.fnst@fujitsu.com" , Peter Eisentraut , Alvaro Herrera , Justin Pryzby , Rahila Syed , Peter Smith , pgsql-hackers , "shiy.fnst@fujitsu.com" Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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. I think it would be good if we can avoid an additional call to get_partition_ancestors() as it could be costly. 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. -- With Regards, Amit Kapila.