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 1pWZmI-0004q7-O8 for pgsql-hackers@arkaria.postgresql.org; Mon, 27 Feb 2023 09:26:38 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pWZmG-0002Od-U9 for pgsql-hackers@arkaria.postgresql.org; Mon, 27 Feb 2023 09:26:36 +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 1pWZmG-0002OT-IO for pgsql-hackers@lists.postgresql.org; Mon, 27 Feb 2023 09:26:36 +0000 Received: from mail-ot1-x330.google.com ([2607:f8b0:4864:20::330]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pWZmD-0006co-AZ for pgsql-hackers@postgresql.org; Mon, 27 Feb 2023 09:26:36 +0000 Received: by mail-ot1-x330.google.com with SMTP id h6-20020a9d7986000000b0068bd8c1e836so3192716otm.3 for ; Mon, 27 Feb 2023 01:26:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=t5tQ9xVT1ZXQr/ZnLe9EwleDQs04LkgoR6zKzhc2V3g=; b=NzIlNPufJCjYLOhDO87lXrnXQBPv6JCc2UakOdM4Y4FH5pleJWrYVCFtECD/m8gSMU IRcKVKa8dFEJD04fAlSIgKyGkznccLpvIVdKR5PXOBncXeTq4FudojxqHI5cs0iE4dH/ GSa/5Q+EVH78C+NTjZsSoXhinPH7CiO3qqficJ+4i5Hdr9d6Bc1vhcezkwvrXyRm+Pog j0I4qfHp7lB3nhHJJUHjRBiDh34Y6xCJ18hx785SOeaG4SreB7voK2pAPcyTxRYtzQTw tlLZZQqLv1clz1JpjCEMU80XchNkd/FAY4356EbZBeq2aIYTKDBAzWJ5Agh0yEtrMtYO PnbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=t5tQ9xVT1ZXQr/ZnLe9EwleDQs04LkgoR6zKzhc2V3g=; b=I0+mc+bj+cw5PFRYVPpB41BbePlIDMZxGRLwagGi0QKM+Bt7nyM16x9dqK1tjFQaI6 FZZ9MekUCyltc0MBLAaiyTGlsLAWzhXXxiHEgXMIUSfx5EAHThfmTVcmsYHdPhcpn78T y4EOy6CRYfuWWZZotXdQoPn3I1TcxK2paOHoJLVDSrj7WsSiSKhM5Ame7yAa5VeUB+L4 dZ/65WcvHRKGEl3LtbbScYiFfhRovkZhtQHHbYOlXc5XlyablroTemSYbQk7ywI0LIyh Pe8F6ovC77GYEN2w4rznEkaYuximF640ZL/9q++gpPvR/p2TlJ1Y6ra9drfFBykxEKOk QUkA== X-Gm-Message-State: AO0yUKXth2diIl68dPGhcxiHSgxffMd/r5VLx7+cIsKPtBqy+qVVBnFp +D2Ql8pm6MMZcwOgyuaVDLZmK6DE56ExSXKRcA8= X-Google-Smtp-Source: AK7set8BxvqELofLOVJkXpPRRPc3H0UUEeWFeNSho9DIVqMmNz6TCIR3+UQmdQsWaTVoNdiWXrBUjr7AzuXIXsxKCEk= X-Received: by 2002:a05:6830:39f1:b0:68b:ccee:5ead with SMTP id bt49-20020a05683039f100b0068bccee5eadmr4300584otb.3.1677489991167; Mon, 27 Feb 2023 01:26:31 -0800 (PST) MIME-Version: 1.0 References: <20230216.142101.1198410163394123325.horikyota.ntt@gmail.com> <20230216.175546.98020490115903046.horikyota.ntt@gmail.com> In-Reply-To: From: Amit Kapila Date: Mon, 27 Feb 2023 14:56:19 +0530 Message-ID: Subject: Re: Time delayed LR (WAS Re: logical replication restrictions) To: Masahiko Sawada Cc: "Hayato Kuroda (Fujitsu)" , "shiy.fnst@fujitsu.com" , Peter Smith , Kyotaro Horiguchi , "andres@anarazel.de" , "vignesh21@gmail.com" , "shveta.malik@gmail.com" , "Takamichi Osumi (Fujitsu)" , "dilipbalaut@gmail.com" , "euler@eulerto.com" , "m.melihmutlu@gmail.com" , "marcos@f10.com.br" , "pgsql-hackers@postgresql.org" 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 Mon, Feb 27, 2023 at 1:50=E2=80=AFPM Masahiko Sawada wrote: > > On Mon, Feb 27, 2023 at 3:34 PM Amit Kapila wro= te: > > > > > --- > > > Why do we not to delay sending COMMIT PREPARED messages? > > > > > > > I think we need to either add delay for prepare or commit prepared as > > otherwise, it will lead to delaying the xact more than required. > > Agreed. > > > The > > patch seems to add a delay before sending a PREPARE as that is the > > time when the subscriber will apply the changes. > > Considering the purpose of this feature mentioned in the commit > message "particularly to fix errors that might cause data loss", > delaying sending PREPARE would really help that situation? For > example, even after (mistakenly) executing PREPARE for a transaction > executing DELETE without WHERE clause on the publisher the user still > can rollback the transaction. They don't lose data on both nodes yet. > After executing (and replicating) COMMIT PREPARED for that > transaction, they lose the data on both nodes. IIUC the time-delayed > logical replication should help this situation by delaying sending > COMMIT PREPARED so that, for example, the user can stop logical > replication before COMMIT PREPARED message arrives to the subscriber. > So I think we should delay sending COMMIT PREPARED (and COMMIT) > instead of PREPARE. This would help users to correct data loss errors, > and would be more consistent with what recovery_min_apply_delay does. > The one difference w.r.t recovery_min_apply_delay is that here we will hold locks for the duration of the delay which didn't seem to be a good idea. This will also probably lead to more bloat as we will keep transactions open for a long time. Doing it before DecodePrepare won't have such problems. This is the reason that we decide to perform a delay at the start of the transaction instead at commit/prepare in the subscriber-side approach. --=20 With Regards, Amit Kapila.