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 1nlLPq-0006No-Qd for pgsql-hackers@arkaria.postgresql.org; Mon, 02 May 2022 02:03:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nlLPo-0004oE-DL for pgsql-hackers@arkaria.postgresql.org; Mon, 02 May 2022 02:03:56 +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 1nlLPo-0004nt-1g for pgsql-hackers@lists.postgresql.org; Mon, 02 May 2022 02:03:56 +0000 Received: from mail-pg1-x533.google.com ([2607:f8b0:4864:20::533]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nlLPj-00022M-Uq for pgsql-hackers@lists.postgresql.org; Mon, 02 May 2022 02:03:55 +0000 Received: by mail-pg1-x533.google.com with SMTP id z21so10708693pgj.1 for ; Sun, 01 May 2022 19:03:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=OJ6ymjq6VZsS+3RAHPG5oYwAL+5thH7LAHBaLs9uIHE=; b=mP3UoTUa8yF85YoEKVbWhugWIHcNCDyrTiOroI16Lgf2cs1F3TxGO131Jl5lRnccm4 rkhVbJy2NDkyuYU+Wdoxivsbr5K/IjkGgjkhmWLvhvnXUAD1VamLCmZB8bsatSH0bYyN tmDR9F54SIIjqWYPFxF267XZMH+1Fr0MX1Q47ALDR72RZZWGIpTNJ1EKxdy0gGB7Hyfh 3/AWyBzv/Uvq2/zsJmT8w4vDSq8/a+qGQOdxq1uNX5bDffbf8KeQ0bhJi3NiS4K2uwQS QXLrap9h8E+eyDs/NMyQ4gAz6hJYWrLM5dhxjgHGM7P2+o/Tt2umUmWYpriz7i3C2Jfk exAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=OJ6ymjq6VZsS+3RAHPG5oYwAL+5thH7LAHBaLs9uIHE=; b=lzUg9gbcq9ZVqURGjoadKsCsdFFI/7jTobXC19L/vrUpoA9X84/UJREqC2v7zcCt+8 07F/W0u8EdjmAl41JzMXyhYyEGeKaYNzaepsGpaz7y7rEzlnDHUVyz4VKC8tGmfR9ScX U9ULVu4dY1tdCaV2aecUjNRNConATiH8YELA5j6+3/ZX9/yTFdoeyejJldk6JZht5/A5 jyxoNMSqwiX3otQFyjsrN+ero3lYMdxdAeTG08bcFXwqbhjeYbSk5t5/vlrJtEzyq+9J CvKYf7oDVGK14CFl6GseNoCFKGD6BjarQkTUDFSUcn+KQSOJTWzgy35goamxssWMcvAr 4zlQ== X-Gm-Message-State: AOAM532CUwRKWq/FZJxxi87ZselasoAALyKa5H0hhauZmIv6F9Iiwbrk OD+erDUUeOpKj1lm8rr5uk8YF/r0RRj6O6whiPY= X-Google-Smtp-Source: ABdhPJyBq1jAqMLdW0o3c7FlggKBgI85+wl7ZFq4wUsWTbfxYULV0tOD5666fqu+giBB1gpoRp7xgqfaZi+zQC7/+Yc= X-Received: by 2002:a05:6a00:1a4d:b0:50d:5921:1a8f with SMTP id h13-20020a056a001a4d00b0050d59211a8fmr9017112pfv.64.1651457029938; Sun, 01 May 2022 19:03:49 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Masahiko Sawada Date: Mon, 2 May 2022 11:03:13 +0900 Message-ID: Subject: Re: Logical replication timeout problem To: "houzj.fnst@fujitsu.com" Cc: "wangw.fnst@fujitsu.com" , Amit Kapila , Euler Taveira , "kuroda.hayato@fujitsu.com" , Peter Smith , Fabrice Chapuis , Simon Riggs , Petr Jelinek , "tanghy.fnst@fujitsu.com" , PostgreSQL Hackers , Ajin Cherian 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 Thu, Apr 28, 2022 at 7:01 PM houzj.fnst@fujitsu.com wrote: > > On Wednesday, April 20, 2022 3:21 PM Masahiko Sawada wrote: > > > > BTW the changes in > > REL_14_v1-0001-Fix-the-logical-replication-timeout-during-large-.patch, > > adding end_xact to LogicalDecodingContext, seems good to me and it > > might be better than the approach of v17 patch from plugin developers= =E2=80=99 > > perspective? This is because they won=E2=80=99t need to pass true/false= to > > end_xact of OutputPluginUpdateProgress(). Furthermore, if we do what > > we do in update_replication_progress() in > > OutputPluginUpdateProgress(), what plugins need to do will be just to > > call OutputPluginUpdate() in every callback and they don't need to > > have the CHANGES_THRESHOLD logic. What do you think? > > Hi Sawada-san, Wang > > I was looking at the patch and noticed that we moved some logic from > update_replication_progress() to OutputPluginUpdateProgress() like > your suggestion. > > I have a question about this change. In the patch we added some > restriction in this function OutputPluginUpdateProgress() like below: > > + /* > + * If we are at the end of transaction LSN, update progress tracking. > + * Otherwise, after continuously processing CHANGES_THRESHOLD changes, w= e > + * try to send a keepalive message if required. > + */ > + if (ctx->end_xact || ++changes_count >=3D CHANGES_THRESHOLD) > + { > + ctx->update_progress(ctx, ctx->write_location, ctx->write_xid, > + skipped_xact); > + changes_count =3D 0; > + } > > After the patch, we won't be able to always invoke the update_progress() = if the > caller are at the middle of transaction(e.g. end_xact =3D false). The beb= avior of the > public function OutputPluginUpdateProgress() is changed. I am thinking is= it ok to > change this at back-branches ? > > Because OutputPluginUpdateProgress() is a public function for the extensi= on > developer, just a little concerned about the behavior change here. Good point. As you pointed out, it would not be good if we change the behavior of OutputPluginUpdateProgress() in back branches. Also, after more thought, it is not a good idea even for HEAD since there might be background workers that use logical decoding and the timeout checking might not be relevant at all with them. BTW, I think you're concerned about the plugins that call OutputPluginUpdateProgress() at the middle of the transaction (i.e., end_xact =3D false). We have the following change that makes the walsender not update the progress at the middle of the transaction. Do you think it is okay since it's not common usage to call OutputPluginUpdateProgress() at the middle of the transaction by the plugin that is used by the walsender? #define WALSND_LOGICAL_LAG_TRACK_INTERVAL_MS 1000 - if (!TimestampDifferenceExceeds(sendTime, now, + if (end_xact && TimestampDifferenceExceeds(sendTime, now, WALSND_LOGICAL_LAG_TRACK_INTERVAL_MS)) - return; + { + LagTrackerWrite(lsn, now); + sendTime =3D now; + } Regards, -- Masahiko Sawada EDB: https://www.enterprisedb.com/