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 1nbcU3-0005wY-UJ for pgsql-hackers@arkaria.postgresql.org; Tue, 05 Apr 2022 06:16:07 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nbcU2-0005AG-Bt for pgsql-hackers@arkaria.postgresql.org; Tue, 05 Apr 2022 06:16: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 1nbcU1-0005A7-WC for pgsql-hackers@lists.postgresql.org; Tue, 05 Apr 2022 06:16:06 +0000 Received: from mail-yb1-xb32.google.com ([2607:f8b0:4864:20::b32]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nbcTz-0006f7-CH for pgsql-hackers@lists.postgresql.org; Tue, 05 Apr 2022 06:16:05 +0000 Received: by mail-yb1-xb32.google.com with SMTP id o62so6562182ybo.2 for ; Mon, 04 Apr 2022 23:16:02 -0700 (PDT) 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=DT0SxiVEHxyJBjl9Ti5JspCWME4MZy+TrVea1n0IXCs=; b=R3e6Shqcm0jwXRErXvXQrBJA4NDYLFxZK5EYoe8yoySfhhF1i3sxXr6CJZ47ovjDSu 1VetDm3yRf8ORHTTne20b0iHTKqcz5bkkULenw2xXC6Agz4OML+wQs+n8ziaBKfN05j5 ukLLBBp2czbZuazD7BirPhXO6fip6nMVmN4w3h1gIBTmvFXeW3Fldccv7CM3+/9vp51L ay2kK87T+ViFhr3/8PdanUnhOhIIc2lB41cMgY0nLon3wo7zwY2KHK4oe5UVYCZ4YU+Q Yw9TJYX9Pg7mW9CWQQvaqOVy6UgQN2E4QbY0MfV5wEbw323siE5cjUuSzA6TwVoXOLts 1XSw== 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=DT0SxiVEHxyJBjl9Ti5JspCWME4MZy+TrVea1n0IXCs=; b=w3Xeu/MVwP/ON7+kpoFz+DXJc9VtSbU0J8PCvw0UcMY7qH49IcWO8CL0roG+9HBlJj J7Htzk3N4Vl5kr2XgUHC3PlJS8sqX1FobMHmpUjbVdN86knUEvYlRoUJf/ktWipNxBjm 9Hi3dPUcwcLKKd3F0JPU5RXunBZLeAdEfsnCAP532RIFWJ4nsxh75pS0TouHZ2xKl7PA pO86SH7hMKHxOHgZdeQVf+nQlOKz9nejEkYfpv+XYCmXKJH45r9qXPJ3ARcaKJv98Nf1 /xaKFfz+vzc9zgcc6UF1dFuMkp2o0Thso92TecegpY7DnPhQMqPL1ua9wEksKqm01pJb 0RyQ== X-Gm-Message-State: AOAM530gL9mcAyHVkm0Z/WGtnMrpxCKfkba2qyC9aNwCrK61GgJpLMvC ewfv9kRwT1lsgNSsroLCJy8L/ogh90+28Eindfc= X-Google-Smtp-Source: ABdhPJwo5s6BcgwFglzlLvHmmObpvZuD1vA87XZ69uKLpD3S/gCGv8ouWatatOWSDZIFnQyCe2Jw/VDVY2fFn1giSBE= X-Received: by 2002:a25:7bc2:0:b0:634:6678:b034 with SMTP id w185-20020a257bc2000000b006346678b034mr1365296ybc.495.1649139361220; Mon, 04 Apr 2022 23:16:01 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Amit Kapila Date: Tue, 5 Apr 2022 11:45:50 +0530 Message-ID: Subject: Re: Handle infinite recursion in logical replication setup To: Peter Smith Cc: vignesh C , 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 Tue, Apr 5, 2022 at 8:17 AM Peter Smith wrote: > > Here are my comments for the latest patch v6-0002. > > PATCH v6-0002 comments > ====================== > > 2.1 General - should this be an independent patch? > I think both the patches are dependent and might get committed together if the concept proved to be useful and doesn't have flaws. > In many ways, I think most of this patch is unrelated to the other > "local_only" patch (v6-0001). > > For example, IIUC even in the current HEAD, we could consider it to be > a user error if multiple SUBSCRIPTIONS or multiple PUBLICATIONS of the > same SUBSCRIPTION are replicating to the same TABLE on the same node > and using "copy_data = on". > > So I think it would be ok to throw an ERROR if such a copy_data clash > is detected, and then the user will have to change to use "copy_data = > off" for some/all of them to avoid data duplication. > > The "local_only" option only adds some small logic to this new ERROR, > but it's not really a prerequisite at all. > > e.g. this whole ERROR part of the patch can be a separate thread. > > ~~~ > > 2.2 General - can we remove the "force" enum? > > Now, because I consider the clashing "copy_data = on" ERROR to be a > user error, I think that is something that the user can already take > care of themselves just using the copy_data = off. > > I did not really like the modifying of the "copy_data" option from > just boolean to some kind of hybrid boolean + "force". > > a) It smells a bit off to me. IMO replication is supposed to end up > with the same (replicated) data on the standby machine but this > "force" mode seems to be just helping the user to break that concept > and say - "I know what I'm doing, and I don't care if I get lots of > duplicated data in the replica table - just let me do it"... > > b) It also somehow feels like the new "force" was introduced mostly to > make the code ERROR handling implementation simpler, rather than to > make the life of the end-user better. Yes, if force is removed maybe > the copy-clash-detection-code will need to be internally quite more > complex than it is now, but that is how it should be, instead of > putting extra burden on the user (e.g. by complicating the PG docs and > giving them yet more alternatives to configure). I think any clashing > copy_data options really is a user error, but also I think the current > boolean copy_data true/false already gives the user a way to fix it. > > c) Actually, your new error hint messages are similar to my > perspective: They already say "Use CREATE/ALTER SUBSCRIPTION with > copy_data = off or force". All I am saying is remove the "force", and > the user can still fix the problem just by using "copy_data = off" > appropriately. > How will it work if there is more than one table? copy_data = "off" means it won't copy any of the other tables in the corresponding publication(s). I think it is primarily to give the user some option where she understands the logical replication setup better and understands that this won't be a problem. -- With Regards, Amit Kapila.