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 1lu6Q7-0008Ao-99 for pgsql-hackers@arkaria.postgresql.org; Fri, 18 Jun 2021 04:47:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lu6Q3-0003Xt-L7 for pgsql-hackers@arkaria.postgresql.org; Fri, 18 Jun 2021 04:47:51 +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 1lu6Q3-0003Xk-AW for pgsql-hackers@lists.postgresql.org; Fri, 18 Jun 2021 04:47:51 +0000 Received: from mail-qk1-x730.google.com ([2607:f8b0:4864:20::730]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lu6Q0-000252-Rn for pgsql-hackers@lists.postgresql.org; Fri, 18 Jun 2021 04:47:50 +0000 Received: by mail-qk1-x730.google.com with SMTP id 5so7893405qkc.8 for ; Thu, 17 Jun 2021 21:47:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=0yQ0ftSoJ2TzkpcVlhrBP5diI9wl0cy1JE88mtZvhBg=; b=SbK8IjG9T4FyxC00J6ltZJ/dYgIDP2sCByz5f4TVTWXmMWWrMMRsGDyPpdD4UXjasP XuUvZOGHo3UTRKqawDdpD/AwlseBlpoE4i/Ck4PN2erLNsSfSrZbYRSg9Wm11E41h6fN n59t+qNxbaKhYJ6uSm6Ry/N0ankmHF4+2l5Wa8JZqwydMlsNkapGPgqxpdyCAq6eNPM6 zXsBaZKpgTPnV72f/eXYlITXoensBJG3OIqCkZktAILXV+T60jU+kQCa8lWoCg/qq/Ul JUX066KOIjanvAXJhkw+TqpDe+JGXDpY7QRByo0jXKilOXoAnB7DZxcpRV0anat5kVd1 KBgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=0yQ0ftSoJ2TzkpcVlhrBP5diI9wl0cy1JE88mtZvhBg=; b=qTSL9U3pjFpct4YktgR7V7LFJZcrkfu2VKeARGcM5kjN7f81vbBEbrY2cpmbQQYMRl YH9x+UKAJ4m4cf7wqLF3ah3IN6/RLH0AZvEfn02Nq2HRFIOpd9nSXYBk9okF5SmodX/l DYqUMCdA0UARcxzIb6JVRSNGFdeirLGSgKXL3MM08CXViQwfm1b4Q9xo3eHATj8vAizl kGwMr4qrwN6imgxpOTB1rIv0TqC/IEEq7Up8Qv9ynbQkHQVitZvgVcMxKhkY0vAKoa6s TwX/iKygPRFpy/wsSKF0FxKGh+CXCw0eUYDdwYWkGSHNHVlqNwPDdL2DSW3k7UuO4cJy aGrg== X-Gm-Message-State: AOAM53368M2Au5lyJtmyl36MZmBR5u0biyAmXoQlE7AWCCP2hfX1FzeW nXbLiUhsD1m2uI4ub+8RJa2H5QyEDZIz1RmIXtc= X-Google-Smtp-Source: ABdhPJw7Tutt669jwNhietMO5Fv6loKBEstIyyEUtl+lK2n7UjGjB5CI99JTkDjnIAr3EnJwE42IzgrJX6QfMKl/A0w= X-Received: by 2002:a25:1e43:: with SMTP id e64mr11521245ybe.489.1623991667676; Thu, 17 Jun 2021 21:47:47 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Amit Kapila Date: Fri, 18 Jun 2021 10:17:36 +0530 Message-ID: Subject: Re: Optionally automatically disable logical replication subscriptions on error To: Mark Dilger , Sawada Masahiko Cc: PostgreSQL Hackers Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, Jun 18, 2021 at 1:48 AM Mark Dilger wrote: > > Hackers, > > Logical replication apply workers for a subscription can easily get stuck= in an infinite loop of attempting to apply a change, triggering an error (= such as a constraint violation), exiting with an error written to the subsc= ription worker log, and restarting. > > As things currently stand, only superusers can create subscriptions. Ong= oing work to delegate superuser tasks to non-superusers creates the potenti= al for even more errors to be triggered, specifically, errors where the app= ly worker does not have permission to make changes to the target table. > > The attached patch makes it possible to create a subscription using a new= subscription_parameter, "disable_on_error", such that rather than going in= to an infinite loop, the apply worker will catch errors and automatically d= isable the subscription, breaking the loop. The new parameter defaults to = false. When false, the PG_TRY/PG_CATCH overhead is avoided, so for subscri= ptions which do not use the feature, there shouldn't be any change. Users = can manually clear the error after fixing the underlying issue with an ALTE= R SUBSCRIPTION .. ENABLE command. > I see this idea has merits and it will help users to repair failing subscriptions. Few points on a quick look at the patch: (a) The patch seem to be assuming that the error can happen only by the apply worker but I think the constraint violation can happen via one of the table sync workers as well, (b) What happens if the error happens when you are updating the error information in the catalog table. I think instead of seeing the actual apply time error, the user might see some other for which it won't be clear what is an appropriate action. We are also discussing another action like skipping the apply of the transaction on an error [1]. I think it is better to evaluate both the proposals as one seems to be an extension of another. Adding Sawada-San, as he is working on the other proposal. [1] - https://www.postgresql.org/message-id/CAD21AoDeScrsHhLyEPYqN3sydg6PxA= PVBboK%3D30xJfUVihNZDA%40mail.gmail.com --=20 With Regards, Amit Kapila.