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 1jld8g-0002fW-Mb for pgsql-hackers@arkaria.postgresql.org; Wed, 17 Jun 2020 18:50:22 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jld8f-0007yV-J2 for pgsql-hackers@arkaria.postgresql.org; Wed, 17 Jun 2020 18:50:21 +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 1jld8f-0007xs-CM for pgsql-hackers@lists.postgresql.org; Wed, 17 Jun 2020 18:50:21 +0000 Received: from mail-qk1-x742.google.com ([2607:f8b0:4864:20::742]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jld8d-0005a0-6w for pgsql-hackers@lists.postgresql.org; Wed, 17 Jun 2020 18:50:20 +0000 Received: by mail-qk1-x742.google.com with SMTP id f18so3108419qkh.1 for ; Wed, 17 Jun 2020 11:50:19 -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=u1lyyio2Xf4hhoakCnnA5Vp2JNRKteUSjFjoSVFxU5w=; b=VMV0P28f9MatlOo5vGuAqrbzMNu5hdfakV4rHNuhzCPUT6CYS3lZnYQyJ92hNYzAKu +ewWBImqCTi1ASQYW2/XKG1S71XtLiNSEjgfrUEnb0c9X/oonvrM5bsu3hYts16slUSd 8yYyU/oo9O0Lks+2P2QFTMYtc8Ed7Ln25C+f9I1F0FiKCFuoPNYMBM6DiL+BvBT7/ED+ NffdyLaAr9BwVK0FwRu9t3EfFNy2bb6Fm1tt51Dwv10sTP4l6mfUcgsM7CVgxLEOxCVw jUDbw9yn2uBfl9yDIPMUBfEJXMov0fDM+1zvfJDjiQZxnL3Q3zPMTRED+RaXiGjVn5k6 OTcw== 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=u1lyyio2Xf4hhoakCnnA5Vp2JNRKteUSjFjoSVFxU5w=; b=b17fQVznXQRD5TbdoToXOjcb/jon4BnPPrTym4PMwHW4tdhw37KUjHef+58jWHVVpT kYPIx2pbCPIGZxVy9IeOVjkU6B9RdqiAPCCPzhhV9JIj77EF3pkCTY5oGAwf7ALNsZwF bcMGPbgGboi93Ch3b9Bw9HyRKDEQI3S/mUEAWwhOnhmblx949gGtrHNHilta+ewMc05w DUjRIsnQWaJMDl01Xtc4YqYJ1+aMgcCGNGyBK2eyCcf/i4Rr5wTeX9sgmJkQwi9zErJB KQJMf8C7sdR9zA7yA5dCbQkwmIz7P2fCo/uraD5aItDQ37eyfoSERE3Zlg0GZ5saWo4s +n/g== X-Gm-Message-State: AOAM531G58g6w0i9kZAFlSoRLJACU+hp+3vxqiDmtY8QtKR1wdTw7om1 IEapZWJmwmOw6IDBbsheDIi/XA== X-Google-Smtp-Source: ABdhPJxVPAYxDW3hBox+PULHCad4MGYRmaplJ9k6tSweM7IzxMw5SyENBJpECYOv8KSWjM7VH2yl7g== X-Received: by 2002:a37:2f07:: with SMTP id v7mr26302qkh.265.1592419818386; Wed, 17 Jun 2020 11:50:18 -0700 (PDT) Received: from perhan.alvh.no-ip.org ([190.95.18.252]) by smtp.gmail.com with ESMTPSA id m126sm748746qkd.108.2020.06.17.11.50.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jun 2020 11:50:17 -0700 (PDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id F0DF32A3AD3; Wed, 17 Jun 2020 14:50:14 -0400 (-04) Date: Wed, 17 Jun 2020 14:50:14 -0400 From: Alvaro Herrera To: Kyotaro Horiguchi Cc: masao.fujii@oss.nttdata.com, pgsql-hackers@lists.postgresql.org Subject: Re: Review for GetWALAvailability() Message-ID: <20200617185014.GA3714@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20200617.135607.687059791532071892.horikyota.ntt@gmail.com> 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-Jun-17, Kyotaro Horiguchi wrote: > @@ -342,7 +351,14 @@ pg_get_replication_slots(PG_FUNCTION_ARGS) > else > nulls[i++] = true; > > - walstate = GetWALAvailability(slot_contents.data.restart_lsn); > + /* use last_invalidated_lsn when the slot is invalidated */ > + if (XLogRecPtrIsInvalid(slot_contents.data.restart_lsn)) > + targetLSN = slot_contents.last_invalidated_lsn; > + else > + targetLSN = slot_contents.data.restart_lsn; > + > + walstate = GetWALAvailability(targetLSN, last_removed_seg, > + slot_contents.active_pid != 0); Yeah, this approach seems better overall. I'll see if I can get this done after lunch. -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services