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 1ludjR-0007wU-10 for pgsql-hackers@arkaria.postgresql.org; Sat, 19 Jun 2021 16:22:05 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ludjO-0002QE-Vk for pgsql-hackers@arkaria.postgresql.org; Sat, 19 Jun 2021 16:22:02 +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 1ludjO-0002Nw-Ld for pgsql-hackers@lists.postgresql.org; Sat, 19 Jun 2021 16:22:02 +0000 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1ludjL-0001Wh-KS for pgsql-hackers@lists.postgresql.org; Sat, 19 Jun 2021 16:22:01 +0000 Received: by mail-pl1-x62e.google.com with SMTP id y13so136059plc.8 for ; Sat, 19 Jun 2021 09:21:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb-com.20150623.gappssmtp.com; s=20150623; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=fmiEH6QllLVzpmN3Tbkyp4eZuaY8O3xLkvPHFVz0Hns=; b=AIb0of/BIwId7qcK4uG/JWAHtwPIaMxRQQz4mqQQn2S1z+6ZYhDk7d8BgOAreDTtlP 5ewctwaqTqS3/Nr8Pdj0DBh7Ka7v/hhUzlIw/Incz5sXZUPQo4ieRIqWB3UG8bBTDASd 45LiE0nGfcdZMQZ+UaU3zO+TmUTxqFZ62xte7nf8arbZQNi0NyXmQ8wiBQDSoCb/sC8M whyJSwB/yK+Ewa6aRGRqCnGs6bfDrqvCmLXiwzmOYlVUgrT+KDHhAFAVXXQYVfQ7Xy2r CEYDghj+Jh6EVgRMteJ1WsRI0LC5+09bQhsQl8hiFVlAd+bHC2G6CVLRbTdZTclRp/rA P/FA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=fmiEH6QllLVzpmN3Tbkyp4eZuaY8O3xLkvPHFVz0Hns=; b=n36/ndxScyhxeWkmNpZL6UOgMgv4m67VybAA1auBFtjMdOawSBtUJT55TnRrTXV7yz gehvK0Z6m8z7FjDDk336mpqtjolRkydbmmNWJqYS7knzeKxInrI/pCPlw8g8exA9/LXR h1xVi09TbLUgt8jhk6BpT0Mpy0DBJWTKZC4dc0/X4c6iqF7PDgyR8OGGTvEVJICo1At4 m6HFdit8WzVklxS9LJ+dc0dstHNdDoTDUB5iPqjCD5Tbz7++DQC6WSbozpeATN6fHDjd VVQQk1xoVirWNFuu93GJR3AAORRRRKFSmtP3H6O94azcca08TkJNiR2LLZoleIAxUN+X 4cbw== X-Gm-Message-State: AOAM530Mtge1eMGyvBft+boy82qQxUksp39FuH20gNOjjOlVX3RAkHfT GddC1/kO1wBK/DD79YL2ZNZzEl64tuLsyxpSeJ/yLBuPIbXT1mDYcyt5qvIXX6VHGjVIkcXCR8D hP75Zdaz3Syym4nsjp6KLZNa+lAlb//hBt+IvM8jlqSWY5Exq6C05unoxSphbYw8qs/P5QHp56u EYiBBCBrxv+fjgCafxKoSL8IaZ2/PtPNWOGgZ6XFglepJlBRseHz+o X-Google-Smtp-Source: ABdhPJxfd4JLLLyB0rCpSj/svfCZ8gqgK0hEEwueJ7amVC4jW6+1gD7kH2hSDTtXj0TKu8K8WIiuVw== X-Received: by 2002:a17:902:c111:b029:122:6927:6e50 with SMTP id 17-20020a170902c111b029012269276e50mr4880355pli.6.1624119718323; Sat, 19 Jun 2021 09:21:58 -0700 (PDT) Received: from ?IPv6:2600:6c50:157f:eb87:bc67:19e:dd88:dd1f? ([2600:6c50:157f:eb87:bc67:19e:dd88:dd1f]) by smtp.gmail.com with ESMTPSA id k9sm12086472pgq.27.2021.06.19.09.21.57 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 19 Jun 2021 09:21:57 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.6\)) Subject: Re: Optionally automatically disable logical replication subscriptions on error From: Mark Dilger In-Reply-To: Date: Sat, 19 Jun 2021 09:21:56 -0700 Cc: Sawada Masahiko , "Smith, Peter" , PostgreSQL Hackers Content-Transfer-Encoding: quoted-printable Message-Id: <3DDDA96A-D335-4122-A332-4E1D3F060CF3@enterprisedb.com> References: To: Amit Kapila X-Mailer: Apple Mail (2.3608.120.23.2.6) 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 Jun 19, 2021, at 7:44 AM, Mark Dilger = wrote: >=20 > Wouldn't the user rather skip just the problematic rows? I understand = that on the subscriber side it is difficult to do so, but if you are = going to implement this sort of thing, it makes more sense to allow the = user to filter out data that is problematic rather than filtering out = xids that are problematic, and the filter shouldn't just be an in-or-out = filter, but rather a mapping function that can redirect the data = someplace else or rewrite it before inserting or change the pre-existing = conflicting data prior to applying the problematic data or whatever. Thinking about this some more, it seems my patch already sets the stage = for this sort of thing. We could extend the concept of triggers to something like ErrorTriggers = that could be associated with subscriptions. I already have the code = catching errors for subscriptions where disable_on_error is true. We = could use that same code path for subscriptions that have one or more = BEFORE or AFTER ErrorTriggers defined. We could pass the trigger all = the error context information along with the row and subscription = information, and allow the trigger to either modify the data being = replicated or make modifications to the table being changed. I think = having support for both BEFORE and AFTER would be important, as a common = design pattern might be to move aside the conflicting rows in the BEFORE = trigger, then reconcile and merge them back into the table in the AFTER = trigger. If the xid still cannot be replicated after one attempt using = the triggers, the second attempt to disable the subscription instead. There are a lot of details to consider, but to my mind this idea is much = more user friendly than the idea that users should muck about with xids = for arbitrarily many conflicting transactions. =E2=80=94 Mark Dilger EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company