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 1lucCu-0004UB-0k for pgsql-hackers@arkaria.postgresql.org; Sat, 19 Jun 2021 14:44:24 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lucCs-0001SC-J8 for pgsql-hackers@arkaria.postgresql.org; Sat, 19 Jun 2021 14:44:22 +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 1lucCs-0001Rv-60 for pgsql-hackers@lists.postgresql.org; Sat, 19 Jun 2021 14:44:22 +0000 Received: from mail-pg1-x535.google.com ([2607:f8b0:4864:20::535]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lucCo-0006Yi-Fx for pgsql-hackers@lists.postgresql.org; Sat, 19 Jun 2021 14:44:21 +0000 Received: by mail-pg1-x535.google.com with SMTP id t17so10328493pga.5 for ; Sat, 19 Jun 2021 07:44:17 -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=EcV+iIBW2FWk/DznJ0HOjOhtRV04ZpjMPzv7bSgpo1A=; b=fNDdvVsYX1zf40yOsU0tJRIXgtPh1CE54ecRiTHaQYg1vtxWP53jFCDaccFPIZRcTm BddAimkQIysI0xLdahoBvyEFmZB1WwVVZZIi358m0DnJCjJIHkEBXVkUEhEQlhKOwq3u aSgrBm5fC5I7QRCV4otrixcesZ1Ab7ulpHolvhdcDYklh6NMAJlqPFQzHvg+bvCzETsO hDod11wRrhv1yFBQBdnVzXUjteHmyOdNbpMusr6VnWjYlUoOvI7OlmNVOBXWQ5rtyT4i Bgtx9QnBEuruT95RHNaj9MIQNgqhGdzqW6/Oa3IdhVL0Kda4CSDZGFg2L4KveKoYYpEw rx7g== 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=EcV+iIBW2FWk/DznJ0HOjOhtRV04ZpjMPzv7bSgpo1A=; b=RXig2smGHtBaHwLoXXrEeHp3fOqALS83S1klTSDGQD66vcbH0tF5f2vJ+Dbnz6hOqj Pl5GEXl+20UcA3qhi24nOx0z5OJ+bHl+INDkOPm0ZdjPR1R3vzO25SXl5CHqqINsceWm nVR88Um3M0mw/fuIDS9E5x4q+DfmtgllUIQ5tK+1kLbhbruxmcmILkh6JiXnTHPFqMVI gJm8Cnq8Mg3SxVTlLxZ2utRsBUI4C4n+w4At3xDt0wwiBIQivRbkuYKFUbKLxd8Gis/K ywKYu4FYX9XsyZ/dRHmSFWsV7D7dYBz9gfhjsOsyKBphySAhc3XDW/+/x7Pjf2uIwKjZ fC6g== X-Gm-Message-State: AOAM533eq2ww3A9kRMcX0If8NlTBwgXJ+IbOdJ2BbhXqHwIQseJBHd1K x36cpKqK1Ye/xj7c84NMMLK2z7jS3+Lfds+SpdAF/kEdzWs/B8ck2Rn58mwFj3amV5l9HQmyJTA hkxbkyGBJ0IhQErwcQJK6gVCtjrXY48O8PxMiiuQwknmDOLrzeO2bBpI17YemzK9BmNUsu6Di7O vtDak0ZsVhJ8EzS/nTFuEUF3qJsZHjKFhE93MhusukrcLSUWIVuwFp X-Google-Smtp-Source: ABdhPJzKfyTkAg7GHVAuU3zMQF1aGJg79mLvN+n4udQMUEdERz9qMO4O0NqzZp6Q8cI09gwG52c7NQ== X-Received: by 2002:a65:6a0f:: with SMTP id m15mr15345927pgu.253.1624113853986; Sat, 19 Jun 2021 07:44:13 -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 s1sm11979067pgg.49.2021.06.19.07.44.12 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 19 Jun 2021 07:44:12 -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 07:44:11 -0700 Cc: Sawada Masahiko , "Smith, Peter" , PostgreSQL Hackers Content-Transfer-Encoding: quoted-printable Message-Id: 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 3:17 AM, Amit Kapila = wrote: >=20 > Right, but there are things that could be common from the design > perspective. I went to reconcile my patch with that from [1] only to discover there = is no patch on that thread. Is there one in progress that I can see? I don't mind trying to reconcile this patch with what you're discussing = in [1], but I am a bit skeptical about [1] becoming a reality and I = don't want to entirely hitch this patch to that effort. This can be = committed with or without any solution to the idea in [1]. The original = motivation for this patch was that the TAP tests don't have a great way = to deal with a subscription getting into a fail-retry infinite loop, = which makes it harder for me to make progress on [2]. That doesn't = absolve me of the responsibility of making this patch a good one, but it = does motivate me to keep it simple. > For example, why is it mandatory to update this conflict > ( error) information in the system catalog instead of displaying it > via some stats view? The catalog must be updated to disable the subscription, so placing the = error information in the same row doesn't require any independent = touching of the catalogs. Likewise, the catalog must be updated to = re-enable the subscription, so clearing the error from that same row = doesn't require any independent touching of the catalogs. The error information does not *need* to be included in the catalog, but = placing the information in any location that won't survive server = restart leaves the user no information about why the subscription got = disabled after a restart (or crash + restart) happens. Furthermore, since v2 removed the "disabled_by_error" field in favor of = just using subenabled + suberrmsg to determine if the subscription was = automatically disabled, not having the information in the catalog would = make it ambiguous whether the subscription was manually or automatically = disabled. > Also, why not also log the xid of the failed > transaction? We could also do that. Reading [1], it seems you are overly focused on = user-facing xids. The errdetail in the examples I've been using for = testing, and the one mentioned in [1], contain information about the = conflicting data. I think users are more likely to understand that a = particular primary key value cannot be replicated because it is not = unique than to understand that a particular xid cannot be replicated. = (Likewise for permissions errors.) For example: 2021-06-18 16:25:20.139 PDT [56926] ERROR: duplicate key value violates = unique constraint "s1_tbl_unique" 2021-06-18 16:25:20.139 PDT [56926] DETAIL: Key (i)=3D(1) already = exists. 2021-06-18 16:25:20.139 PDT [56926] CONTEXT: COPY tbl, line 2=20 This tells the user what they need to clean up before they can continue. = Telling them which xid tried to apply the change, but not the change = itself or the conflict itself, seems rather unhelpful. So at best, the = xid is an additional piece of information. I'd rather have both the = ERROR and DETAIL fields above and not the xid than have the xid and lack = one of those two fields. Even so, I have not yet included the DETAIL = field because I didn't want to bloat the catalog. For the problem in [1], having the xid is more important than it is in = my patch, because the user is expected in [1] to use the xid as a = handle. But that seems like an odd interface to me. Imagine that a = transaction on the publisher side inserted a batch of data, and only a = subset of that data conflicts on the subscriber side. What advantage is = there in skipping the entire transaction? 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. That's a huge effort, of course, but = if the idea in [1] goes in that direction, I don't want my patch to have = already added an xid field which ultimately nobody wants. [1] - = https://www.postgresql.org/message-id/CAD21AoDeScrsHhLyEPYqN3sydg6PxAPVBbo= K%3D30xJfUVihNZDA%40mail.gmail.com [2] - = https://www.postgresql.org/message-id/flat/915B995D-1D79-4E0A-BD8D-3B26792= 5FCE9%40enterprisedb.com#dbbce39c9e460183b67ee44b647b1209 =E2=80=94 Mark Dilger EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company