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 1ngcjd-0002YB-S4 for pgsql-hackers@arkaria.postgresql.org; Tue, 19 Apr 2022 01:32:54 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ngcjc-0002on-Lp for pgsql-hackers@arkaria.postgresql.org; Tue, 19 Apr 2022 01:32:52 +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 1ngcjc-0002oe-7r for pgsql-hackers@lists.postgresql.org; Tue, 19 Apr 2022 01:32:52 +0000 Received: from mail-pg1-x529.google.com ([2607:f8b0:4864:20::529]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1ngcjV-00028j-Ax for pgsql-hackers@lists.postgresql.org; Tue, 19 Apr 2022 01:32:51 +0000 Received: by mail-pg1-x529.google.com with SMTP id u2so22071108pgq.10 for ; Mon, 18 Apr 2022 18:32:45 -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; bh=q+o3SrDkw4eGSPrZ3umAr88Mc5z0VmsXDHEwHnR4iSk=; b=GXTuUtHnVf5J8JNTo4fSXPfkBClGawBHGIWuy4Xh1J3Wkds5jm1jqPAwHB+2hw0Wnj gTx3KNdA8S4sq+ujHKDMqTU9SoA+eC1VlrbaKXSOsgs0REzgB8tFS46NASJeXObdQL/s FkJTPBUxDs3GZpbqeQG5oL4APFlBlpJi6/8uc1YpI3ytq4aloaQyTr6oWPRPs43f7sAN cq3a1xNvxJG+3aLs+CzbezLFG7+4fX1faiE3y9kof4Itdv9bLQmW/jhE8r4YP9Ex15Kr 06J43L+bMY69c1X67cSrOuaA6JE3qx9yvYol/EDI90btRt0qQM0W1jArLtzkS74k74WC q6qw== 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; bh=q+o3SrDkw4eGSPrZ3umAr88Mc5z0VmsXDHEwHnR4iSk=; b=zWbE7Y4Rry0/Jl9nZ3ZW1vonf/uOgikaNnyyqhNyUdaqezqIcHSEw7ba3Mhfcwyf4i XKFtplN+NeYYHRIdGQQNHJD2pzPutD7ADcyxR9GHzp4pH2d3705CUis8z+vD2oe1I4dU KXk8H8b1KNOWlV9KfHhAKFgjkF7L1of3KHIM45/mWJ4Cl93quifhYe5pcTm/Cg+bqdP7 fI6qnS35B9Z5B3VMVehw8f5FY2E5j2XSPnrAtXfaFjT2dLjL+dFUHzxYjhlTTgR7tPMQ tI7NpX9+AMXmnquQAZHB8jFNZMRRS0cg2YCNMhOyNtEF6YAJbrwgepTnZENqM4dUggUj PAhg== X-Gm-Message-State: AOAM533HalvUWF9anc4BLOQDDsRRYnqkMmEAlMUSd6/rmizMd9wbKK4s WSwlkCcravg4ykfhc7MvDWttCQViKen35/MkwrY= X-Google-Smtp-Source: ABdhPJwX42FOyS+/bhYBAcWlHYy84Q3hxnfPPwoZUV6G4LpvTCWey4TUJ20HSfV/Nb18nqVmaSvLAtgYAu5N27y/d88= X-Received: by 2002:a65:524b:0:b0:383:1b87:2d21 with SMTP id q11-20020a65524b000000b003831b872d21mr12443889pgp.482.1650331963448; Mon, 18 Apr 2022 18:32:43 -0700 (PDT) MIME-Version: 1.0 References: <0271e197-2cfe-4627-9c11-47535cc7fdf3@www.fastmail.com> <8cc4f31f-240a-4590-94a8-a50bdf4f4d1c@www.fastmail.com> In-Reply-To: From: Masahiko Sawada Date: Tue, 19 Apr 2022 10:32:07 +0900 Message-ID: Subject: Re: Logical replication timeout problem To: "wangw.fnst@fujitsu.com" Cc: 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" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, Apr 18, 2022 at 3:16 PM wangw.fnst@fujitsu.com wrote: > > On Mon, Apr 18, 2022 at 00:35 PM Masahiko Sawada wrote: > > On Mon, Apr 18, 2022 at 1:01 PM Amit Kapila wrote: > > > > > > On Thu, Apr 14, 2022 at 5:50 PM Masahiko Sawada > > wrote: > > > > > > > > On Wed, Apr 13, 2022 at 7:45 PM Amit Kapila > > wrote: > > > > > > > > > > On Mon, Apr 11, 2022 at 12:09 PM wangw.fnst@fujitsu.com > > > > > wrote: > > > > > > > > > > > > So I skip tracking lag during a transaction just like the current HEAD. > > > > > > Attach the new patch. > > > > > > > > > > > > > > > > Thanks, please find the updated patch where I have slightly > > > > > modified the comments. > > > > > > > > > > Sawada-San, Euler, do you have any opinion on this approach? I > > > > > personally still prefer the approach implemented in v10 [1] > > > > > especially due to the latest finding by Wang-San that we can't > > > > > update the lag-tracker apart from when it is invoked at the transaction end. > > > > > However, I am fine if we like this approach more. > > > > > > > > Thank you for updating the patch. > > > > > > > > The current patch looks much better than v10 which requires to call > > > > to > > > > update_progress() every path. > > > > > > > > Regarding v15 patch, I'm concerned a bit that the new function name, > > > > update_progress(), is too generic. How about > > > > update_replation_progress() or something more specific name? > > > > > > > > > > Do you intend to say update_replication_progress()? The word > > > 'replation' doesn't make sense to me. I am fine with this suggestion. > > > > Yeah, that was a typo. I meant update_replication_progress(). > Thanks for your comments. > > > > > Regarding v15 patch, I'm concerned a bit that the new function name, > > > > update_progress(), is too generic. How about > > > > update_replation_progress() or something more specific name? > Improve as suggested. Change the name from update_progress to > update_replication_progress. > > > > > --- > > > > + if (end_xact) > > > > + { > > > > + /* Update progress tracking at xact end. */ > > > > + OutputPluginUpdateProgress(ctx, skipped_xact, end_xact); > > > > + changes_count = 0; > > > > + return; > > > > + } > > > > + > > > > + /* > > > > + * After continuously processing CHANGES_THRESHOLD changes, > > > > we try to send > > > > + * a keepalive message if required. > > > > + * > > > > + * We don't want to try sending a keepalive message after > > > > processing each > > > > + * change as that can have overhead. Testing reveals that there is no > > > > + * noticeable overhead in doing it after continuously > > > > processing 100 or so > > > > + * changes. > > > > + */ > > > > +#define CHANGES_THRESHOLD 100 > > > > + if (++changes_count >= CHANGES_THRESHOLD) > > > > + { > > > > + OutputPluginUpdateProgress(ctx, skipped_xact, end_xact); > > > > + changes_count = 0; > > > > + } > > > > > > > > Can we merge two if branches since we do the same things? Or did you > > > > separate them for better readability? > Improve as suggested. Merge two if-branches. > > Attach the new patch. > 1. Rename the new function(update_progress) to update_replication_progress. [suggestion by Sawada-San] > 2. Merge two if-branches in new function update_replication_progress. [suggestion by Sawada-San.] > 3. Improve comments to make them clear. [suggestions by Euler-San.] Thank you for updating the patch. + * For a large transaction, if we don't send any change to the downstream for a + * long time(exceeds the wal_receiver_timeout of standby) then it can timeout. + * This can happen when all or most of the changes are either not published or + * got filtered out. + */ + if(end_xact || ++changes_count >= CHANGES_THRESHOLD) + { We need a whitespace before '(' at above two places. The rest looks good to me. Regards, -- Masahiko Sawada EDB: https://www.enterprisedb.com/