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 1nR8WJ-0002B3-VX for pgsql-hackers@arkaria.postgresql.org; Mon, 07 Mar 2022 08:15:08 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nR8WI-0006W0-DQ for pgsql-hackers@arkaria.postgresql.org; Mon, 07 Mar 2022 08:15:06 +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 1nR8WI-0006Vq-1X for pgsql-hackers@lists.postgresql.org; Mon, 07 Mar 2022 08:15:06 +0000 Received: from mail-qt1-x82b.google.com ([2607:f8b0:4864:20::82b]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nR8WF-000768-CS for pgsql-hackers@lists.postgresql.org; Mon, 07 Mar 2022 08:15:05 +0000 Received: by mail-qt1-x82b.google.com with SMTP id 11so12571428qtt.9 for ; Mon, 07 Mar 2022 00:15:02 -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=Hb+YntqOWIhcRScwFEKjyQDTilo+cekQFNeCLH4L3o8=; b=bzbe0odBDKXC2rjjiBeGwGDmAfq1s70zUpMVaet8K7Gw/9o8VkZt6DyGvRXBZbvlVc XoDr8c2Bvz6jDKDdt1H9P4MFVyiSptBrtJnNFFov609F3Hf254ntmqGSPomZQ9FRZBgr z4Id26ZaQGNjCeJjcyeNgwb4bYEU+sCWz2zMsGsu7kTrYpUVXRfN3TFeWI4RP+r/1s2o qWSbBEYSWLvW+7KGniyA4EzIt0SUn/VPgMmFJpMVWgYQWpJrCapmTly+sOtsJzg9NlYO O23QTx9LHBgx2osqgA9rw/6bTRNpBV0E991Rin9Lfa5lkc9nWJGTatv+ez6dtU2DNaY4 XtXg== 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=Hb+YntqOWIhcRScwFEKjyQDTilo+cekQFNeCLH4L3o8=; b=HvUd02yXBzR5JT3SaLJQw1p0UZE5CDYoT3O58umMMv8TeSutJHu+1y9r3GNbc+iNrz oK9kX89MKNrgEOVHIXcyzqYwr7oz7K/QWbDcja13p3yr7CAkmJIv/yw88FxnUdC3S8lZ C2ujswza37zcBKkUXEctlJ8ipPBclAILVyl0DEiymS7iUYBEEjHgpst+V6onCjnDSJ1m iI0Rn6wdaHO0/BawHlZnjiOLP1gSqLWWs1YtaIa3NcMrSCfkRAEINHmasQSjbdnmq6PU dYhP8DTX5WTW2mA0lJYYK3RBNcs3JFo21XF/BiEc8TQvBlA43XWbm0v5FwmLCYZcwvlB yWJA== X-Gm-Message-State: AOAM533Ntd/OS5YlDRMtq2p7zPDK2arWF9NLz4kjfQjWG4kmemNASlem fjkxCA7ZGAsTtqIyyPWlP5chFr9Dij49pzQN5xk= X-Google-Smtp-Source: ABdhPJx32a0NOrTxG+P3Az2NiJiDhfqMXQ5FdRB6guT+RTlsqCVY6YP2+bPqGNHk9WRiV/jw3J5xGd0UUb7pyuXbgOM= X-Received: by 2002:ac8:5950:0:b0:2dc:a139:4f36 with SMTP id 16-20020ac85950000000b002dca1394f36mr8615014qtz.646.1646640901086; Mon, 07 Mar 2022 00:15:01 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Peter Smith Date: Mon, 7 Mar 2022 19:14:39 +1100 Message-ID: Subject: Re: Handle infinite recursion in logical replication setup To: vignesh C Cc: "kuroda.hayato@fujitsu.com" , PostgreSQL Hackers Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, Mar 7, 2022 at 6:17 PM vignesh C wrote: > > On Mon, Mar 7, 2022 at 11:45 AM Peter Smith wrote: > > > > On Mon, Mar 7, 2022 at 4:20 PM vignesh C wrote: > > > > > > On Mon, Mar 7, 2022 at 10:26 AM Peter Smith wrote: > > > > > > > > Hi Vignesh, I also have not looked at the patch yet, but I have what > > > > seems like a very fundamental (and possibly dumb) question... > > > > > > > > Basically, I do not understand the choice of syntax for setting things up. > > > > > > > > IMO that "only-local" option sounds very similar to the other > > > > PUBLICATION ("publish") options which decide the kinds of things that > > > > will be published. So it feels more natural for me to think of the > > > > publisher as being the one to decide what will be published. > > > > > > > > e.g. > > > > > > > > option 1: > > > > CREATE PUBLICATION p1 FOR TABLE t1; > > > > CREATE SUBSCRITION s1 ... FOR PUBLICATION p1 WITH (only_local = true); > > > > > > > > option 2: > > > > CREATE PUBLICATION p1 FOR TABLE t1 WEHRE (publish = 'only_local'); > > > > CREATE SUBSCRITION s1 ... FOR PUBLICATION p1; > > > > > > > > ~~ > > > > > > > > IIUC the patch is using option 1. My first impression was it feels > > > > back-to-front for the SUBSCRIPTION telling the PUBLICATION what to > > > > publish. > > > > > > > > So, why does the patch use syntax option 1? > > > > > > I felt the advantage with keeping it at the subscription side is that, > > > the subscriber from one node can subscribe with only_local option on > > > and a different subscriber from a different node can subscribe with > > > only_local option as off. This might not be possible with having the > > > option at publisher side. Having it at the subscriber side might give > > > more flexibility for the user. > > > > > > > OK. Option 2 needs two publications for that scenario. IMO it's more > > intuitive this way, but maybe you wanted to avoid the extra > > publications? > > Yes, I wanted to avoid the extra publication creation that you pointed > out. Option 1 can handle this scenario without creating the extra > publications: > node0: CREATE PUBLICATION p1 FOR TABLE t1; > node1: CREATE SUBSCRIPTION s1 ... FOR PUBLICATION p1 with (only_local = on); > node2: CREATE SUBSCRIPTION s1 ... FOR PUBLICATION p1 with (only_local = off); > > I'm ok with both the approaches, now that this scenario can be handled > by using both the options. i.e providing only_local option as an > option while creating publication or providing only_local option as an > option while creating subscription as Peter has pointed out at [1]. > option 1: > CREATE PUBLICATION p1 FOR TABLE t1; > CREATE SUBSCRITION s1 ... FOR PUBLICATION p1 WITH (only_local = true); > > option 2: > CREATE PUBLICATION p1 FOR TABLE t1 WITH (publish = 'only_local'); > CREATE SUBSCRITION s1 ... FOR PUBLICATION p1; > > Shall we get a few opinions on this and take it in that direction? > > [1] - https://www.postgresql.org/message-id/CAHut%2BPsAWaETh9VMymbBfMrqiE1KuqMq%2BwpBg0s7eMzwLATr%2Bw%40mail.gmail.com > > Regards, > Vignesh BTW here is a counter-example to your scenario from earlier. Let's say I have a publication p1 and p2 and want to subscribe to p1 with only_local=true, and p2 with only_local = false; Using the current OPtion 1 syntax you cannot do this with a single subscription because the option is tied to the subscription. But using syntax Option 2 you may be able to do it. Option 1: CREATE PUBLICATION p1 FOR TABLE t1; CREATE PUBLICATION p2 FOR TABLE t2; CREATE SUBSCRIPTION s1 ... FOR PUBLICATION p1 WITH (local_only = true); CREATE SUBSCRIPTION s2 ... FOR PUBLICATION p1 WITH (local_only = false); Option 2: CREATE PUBLICATION p1 FOR TABLE t1 WITH (publish = 'local_only'); CREATE PUBLICATION p2 FOR TABLE t2; CREATE SUBSCRIPTION s1 ... FOR PUBLICATION p1, p2; ------ Kind Regards, Peter Smith. Fujitsu Australia