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 1lvWUF-0007mb-IA for pgsql-hackers@arkaria.postgresql.org; Tue, 22 Jun 2021 02:50:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lvWUE-0001bO-IQ for pgsql-hackers@arkaria.postgresql.org; Tue, 22 Jun 2021 02:50: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 1lvWUE-0001aa-6d for pgsql-hackers@lists.postgresql.org; Tue, 22 Jun 2021 02:50:02 +0000 Received: from mail-pg1-x536.google.com ([2607:f8b0:4864:20::536]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lvWUB-0007Wl-LA for pgsql-hackers@lists.postgresql.org; Tue, 22 Jun 2021 02:50:01 +0000 Received: by mail-pg1-x536.google.com with SMTP id d12so1328979pgd.9 for ; Mon, 21 Jun 2021 19:49: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=jvAqhmzF1iXFczlhmNUVCMrSUu9iyQrUjpxUM552m/0=; b=DLA+ADVWC8KkRa3wPwtxaHUuUvqsPrG+c0Kf/T8ymisS0YAF72vD3xNbzGykkZGYq1 GSHu5q9vtBg7Eej2t8Bm1VgH99uZqoMlx2YeqELB+WTWpLQRybdwyX3ywoj7yqiPk1d0 sIpvmANg7+3OQXyaNV1hOzfYPBiRbW4jp/aPBLrqsclYXGVQdrkxXcIcf/zTFSIoAVPq Q8T9H2PFdYeAkWgbf94U3IbM7Dqfv1EKCCUWSNVkh2tGiL4dwFkWSPyNZMY+9Z6bqjVO zAGkDZEDNyQiq6jvawjMCE9gVPjbkO+hv5iXfSLYf3Nkq3ysnw+P7h4a61pJ/m2ipdUd SSKQ== 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=jvAqhmzF1iXFczlhmNUVCMrSUu9iyQrUjpxUM552m/0=; b=pRcDk1pPXY1UgWKZDP3hjXSSqhoNsMspu4sSdrAGcTcaZxCOb1z8TazUoM+k1VyHa1 Ox9Fiq7d3QFwg35vhX4CJphm1La/bkPH+7lg5ZLwH2be5pXBBeBjfs1coONIz5dr/umM ZnwJzUlmEwhzVGVgBwbRvMDvS+SRpPRv9RcKAbmtSozDVMXnMkIPtVJbAX4u0mBjMowg KZFcivFoTB+HSlQftTyR3pdOkm38fr2LjbnanQ9O0THaFGKNCS67TNf3E3wdGvZEIXXc 9XzhKWUPoAuLQSmRzW3saNkFsSNNUu9fsnfJ6A9Uo3vjensaV7j+gims3q9FEokrTDY7 LTQg== X-Gm-Message-State: AOAM530pBGYi2rekgEUYnKdQERwBiR1efZC/U5DMq1han1viTfX1wzgi hYVMkwcsJi5SdNLxJWFkm7hSKC5Rx+384wIpzn9twLFTRbN7YzHOSJZpZCarRhwxJsIhuj8mFAn iWuRqRsg4OPCVovVGwl9rDc7AHf9nd/x4pgzFQGQsfwKQjPKiYuFaHVHmyGGazNQGsugJ2MYu96 0nZZA1u8+LaZ0QpX05zjW4z51tl8N6iYtYdPNdh028K+kU9XAMnVUtv3dYxscv X-Google-Smtp-Source: ABdhPJyG1Q/+bG5oUoBWU0RDVuiioxNYihUtzV6cJnQY03vkG2Uq5rbkSQWCtimEEOSFkuQNwHNzdw== X-Received: by 2002:a05:6a00:9a8:b029:2f1:b41b:21cd with SMTP id u40-20020a056a0009a8b02902f1b41b21cdmr1341950pfg.41.1624330198345; Mon, 21 Jun 2021 19:49:58 -0700 (PDT) Received: from ?IPv6:2600:6c50:157f:eb87:312a:3853:88ca:1561? ([2600:6c50:157f:eb87:312a:3853:88ca:1561]) by smtp.gmail.com with ESMTPSA id l7sm17897329pgb.19.2021.06.21.19.49.57 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Jun 2021 19:49: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: Mon, 21 Jun 2021 19:49:56 -0700 Cc: Amit Kapila , Masahiko Sawada , "Smith, Peter" , PostgreSQL Hackers Content-Transfer-Encoding: quoted-printable Message-Id: <0646E5E0-EDF2-4D74-89DD-1C9BF0D7EA67@enterprisedb.com> References: <14738A39-8000-463E-A0BA-6729930A32DA@enterprisedb.com> To: Peter Smith 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 21, 2021, at 5:57 PM, Peter Smith = wrote: >=20 > * Is the goal to prevent some *unattended* SUBSCRIPTION from going bad > at some point in future and then going into a relaunch loop for > days/weeks and causing 1000's of errors without the user noticing. In > that case, this patch seems to be quite useful, but for this goal > maybe you don't want to be checking the tablesync workers at all, but > should only be checking the apply worker like your original v1 patch > did. Yeah, my motivation was preventing an infinite loop, and providing a = clean way for the users to know that replication they are waiting for = won't ever complete, rather than having to infer that it will never = halt.=20 > * Is the goal just to be a convenient way to disable the subscription > during the CREATE SUBSCRIPTION phase so that the user can make > corrections in peace without the workers re-launching and making more > error logs? No. This is not and never was my motivation. It's an interesting = question, but that idea never crossed my mind. I'm not sure what = changes somebody would want to make *after* creating the subscription. = Certainly, there may be problems with how they have things set up, but = they won't know that until the first error happens. > Here the patch is helpful, but only for simple scenarios > like 1 faulty table. Imagine if there are 10 tables (all with PK > violations at DATASYNC copy) then you will encounter them one at a > time and have to re-enable the subscription 10 times, after fixing > each error in turn. You are assuming disable_on_error=3Dtrue. It is false by default. But = ok, let's accept that assumption for the sake of argument. Now, will = you have to manually go through the process 10 times? I'm not sure. = The user might figure out their mistake after seeing the first error. > So in this scenario the new option might be more > of a hindrance than a help because it would be easier if the user just > did "ALTER SUBSCRIPTION sub DISABLE" manually and fixed all the > problems in one sitting before re-enabling. Yeah, but since the new option is off by default, I don't see any = sensible complaint. >=20 > * etc >=20 > ////////// >=20 > Finally, here is one last (crazy?) thought-bubble just for > consideration. I might be wrong, but my gut feeling is that the Stats > Collector is intended more for "tracking" and for "metrics" rather > than for holding duplicates of logged error messages. At the same > time, I felt that disabling an entire subscription due to a single > rogue error might be overkill sometimes. I'm happy to entertain criticism of the particulars of how my patch = approaches this problem, but it is already making a distinction between = transient errors (resources, network, etc.) vs. ones that are = non-transient. Again, I might not have drawn the line in the right = place, but the patch is not intended to disable subscriptions in = response to transient errors. > But I wonder if there is a > way to combine those two ideas so that the Stats Collector gets some > new counter for tracking the number of worker re-launches that have > occurred, meanwhile there could be a subscription option which gives a > threshold above which you would disable the subscription. > e.g. > "disable_on_error_threshold=3D0" default, relaunch forever > "disable_on_error_threshold=3D1" disable upon first error encountered. > (This is how your patch behaves now I think.) > "disable_on_error_threshold=3D500" disable if the re-launch errors go > unattended and happen 500 times. That sounds like a misfeature to me. You could have a subscription that = works fine for a month, surviving numerous short network outages, but = then gets autodisabled after a longer network outage. I'm not sure why = anybody would want that. You might argue for exponential backoff, where = it never gets autodisabled on transient errors, but retries less = frequently. But I don't want to expand the scope of this patch to = include that, at least not without a lot more evidence that it is = needed. =E2=80=94 Mark Dilger EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company