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 1kEIWw-0001Sn-2b for pgsql-hackers@arkaria.postgresql.org; Fri, 04 Sep 2020 20:41: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 1kEIWv-0002LM-1Z for pgsql-hackers@arkaria.postgresql.org; Fri, 04 Sep 2020 20:41:53 +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 1kEIWu-0002LE-R2 for pgsql-hackers@lists.postgresql.org; Fri, 04 Sep 2020 20:41:52 +0000 Received: from mail-qv1-xf44.google.com ([2607:f8b0:4864:20::f44]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kEIWs-0007Os-F8 for pgsql-hackers@lists.postgresql.org; Fri, 04 Sep 2020 20:41:51 +0000 Received: by mail-qv1-xf44.google.com with SMTP id di5so3682547qvb.13 for ; Fri, 04 Sep 2020 13:41:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=CEGe/qodSkhTyHrHanHdc2EFSrIMc/jLW3ofuv6I4u0=; b=W0rwenndg5v9PPXZVYKr5+Te/pAhKASeYgXPQAsvvB45QW6kpwnJJAHmeZLRs4NH3W llpivfLr8dVwqUvrLc4gNVDh4JJH8zAhIQf7qQJItKd9mZeJLUoUffoCsR3tSd6lq9aT cTCyqRIWWqKn4M666frgd9rsz0uGT7WGnimA3whuxc9wc6A2St5iH1yP1SSADCG3eX4Z ThLYvbYsAlzMuqilcJnC3YgG7s2H4fH3DPNUGGVxVAMRjiJCNe7cfSWru9V+tpAQkHPh 5jqEbVc3PNBno/nTtWO/jBgYnrQghQ8GTevUkJdi03ucxFNFeMgNRInKOUlIhC6J5G07 KC7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=CEGe/qodSkhTyHrHanHdc2EFSrIMc/jLW3ofuv6I4u0=; b=iB885H48q0v+lhbcHz8/vNji6g84BvMFUhAv2cSvFbP8e2dHXr6sQASwcAV3Uqdn9q y4fIenrRun/ITJxuzRasD0fpew8cTWLsWmueN6BXSZIN2QG3cguBv9gsKezOZxmuUVwo LBLCOhskI/2Ab0Hoid0j2cS/W8MFIvstCUqyhHNSqIbtSpfEZ4cZ2GDuu4iLtZTZUeSy ZBS0PnGPKc4Vo1Ek2HSRCSP+jvL7SW+aRn1MGcy4OnfXlKU4hHf32XODZCrVCzTgVFxY 79/uDDRMYNDC58Co/sn5UNyQM7R+CB7sOAug/pAIYKQC/5kSTZ1r6G3oFwl4BxXq8lld Z9uw== X-Gm-Message-State: AOAM5331KG8t7JGGgJwcQcA9sIXQJRmjjr4nALgLQWM9qsHUlV6rKiVQ 5wt/9G0yDN3B0XLkihB8wmdNIA== X-Google-Smtp-Source: ABdhPJz+L7ixUXx9Tk47BqLvsD5imIAqiCE/wUJm2IOx/D7aziuVuGm/NVEqXKLr9UvqxEr91np2SQ== X-Received: by 2002:a0c:d6cf:: with SMTP id l15mr9363018qvi.164.1599252109613; Fri, 04 Sep 2020 13:41:49 -0700 (PDT) Received: from perhan.alvh.no-ip.org ([190.95.19.47]) by smtp.gmail.com with ESMTPSA id x198sm5373805qka.37.2020.09.04.13.41.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Sep 2020 13:41:49 -0700 (PDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 879462A1549; Fri, 4 Sep 2020 16:41:47 -0400 (-04) Date: Fri, 4 Sep 2020 16:41:47 -0400 From: Alvaro Herrera To: Tom Lane Cc: pgsql-hackers@lists.postgresql.org, Peter Eisentraut , Petr Jelinek Subject: Re: Questionable ping logic in LogicalRepApplyLoop Message-ID: <20200904204147.GA18660@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <959627.1599248476@sss.pgh.pa.us> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2020-Sep-04, Tom Lane wrote: > While playing around with clang's scan-build I noticed this warning: > > worker.c:2281:7: warning: Value stored to 'ping_sent' is never read > ping_sent = true; > ^ ~~~~ > > At first I thought it was a harmless unnecessary update, but looking > closer I wonder whether it isn't telling us there is a logic bug here. > Specifically, I wonder why the "ping_sent" variable is local to the > loop starting at line 2084, rather than having the same lifespan as > "last_recv_timestamp". Do we really want to forget that we sent a > ping anytime we have to wait for more data? Ah ... maybe this bug is the reason why the bug fixed by 470687b4a5bb did not affect logical replication. > In short, we could remove the ping_sent variable entirely without > changing this code's behavior. I'm not 100% sure what semantics > it's trying to achieve, but I don't think it's achieving them. I imagine that moving the variable one block-scope outwards (together with last_recv_timestamp) is what was intended. ... oh look! commit 3f60f690fac1 moved last_recv_timestamp without realizing that ping_sent had to get the same treatment. -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services