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 1joJ0z-0004fH-HI for pgsql-hackers@arkaria.postgresql.org; Thu, 25 Jun 2020 03:57:29 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1joJ0x-0002vO-HH for pgsql-hackers@arkaria.postgresql.org; Thu, 25 Jun 2020 03:57:27 +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 1joJ0x-0002vG-AB for pgsql-hackers@lists.postgresql.org; Thu, 25 Jun 2020 03:57:27 +0000 Received: from mail-qt1-x836.google.com ([2607:f8b0:4864:20::836]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1joJ0u-0005xs-1g for pgsql-hackers@lists.postgresql.org; Thu, 25 Jun 2020 03:57:26 +0000 Received: by mail-qt1-x836.google.com with SMTP id z1so3654350qtn.2 for ; Wed, 24 Jun 2020 20:57:23 -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=ROZVgyeFuWi/vkK6oazf6mMsxrLwYijjKfmfgepeImQ=; b=uqObyILtgOBAmws4jsWcrMzp8st/l3sk7yhGNOLL5dj0dUo5upS2n8i3knxBsnlZVO x06fThnAQ6u1iDiIMS5F+DB6Ay++SDY1ZwVD4q6Gz6w5oihcq72Y+uGZkUrTEBUDmi/+ 5oeeQrnIKfe5gNP3a3vpMXByVE+yfeTZJfmkDo4Ehlj6VQOgTgs1BCXtIB/1EYReu15o q3z361PFz8ft+658GBlP9v/FcBn2Y9RlPem7nCAvz0lQjQC9Hz3ahcCje8drpnhI0E5k PT8hYeeJP7jfYVm7EBuyhDUG+s0H3YOXIooTx6I5fenwfK+VcyR66tGBIOThb5z946fz FkGw== 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=ROZVgyeFuWi/vkK6oazf6mMsxrLwYijjKfmfgepeImQ=; b=nj/fEng8y0KPJ4AQ6pShNvIMpmXao3RY5HOC51UY2CtnzFt9L1Bj1cM5gfFo8UagZz hqFlnvbdl4oKr5jOki7pPQKdLeIOBqbF0v2NeacTS4B1ctPQE0h0RRiv+XitbWtKd7Sx OMtXfjYWzQbNhf1nsOJAvyH+IObbZYbNm9Tore5X+2WjwLCurA1j3sdmt4VJ3mHl+pOb 4NmF6sfpQpZ+77dhazolNG2f54kCJsc9zc7ajuPWy0oVaBCWMy8YNEIURwjcYOOoERML AsJ9PxcX8tz97cxDhZNA1KeE7KtR7e9P8Cso7jIM4VlacZTAD1v2kDRZRp7/DWrIquYM OQug== X-Gm-Message-State: AOAM532DvIARAxDJt+TjeTp7siKTF/K9rFk9GsSieQKFzsXRnuiCw+91 DwKkfrAtlFbrzcPFzTxb7qDX/w== X-Google-Smtp-Source: ABdhPJzLphdrikgn9/X7meh3hdw6F0bhudf3yPgH55N6EtJ4c/uWjK2i8a3XOUjs6m/HxAT+MR1Ucg== X-Received: by 2002:ac8:34cc:: with SMTP id x12mr29318622qtb.314.1593057441628; Wed, 24 Jun 2020 20:57:21 -0700 (PDT) Received: from perhan.alvh.no-ip.org ([190.95.18.252]) by smtp.gmail.com with ESMTPSA id u6sm5459962qtc.34.2020.06.24.20.57.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jun 2020 20:57:20 -0700 (PDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id CEA1F2A3AA9; Wed, 24 Jun 2020 23:57:18 -0400 (-04) Date: Wed, 24 Jun 2020 23:57:18 -0400 From: Alvaro Herrera To: Fujii Masao Cc: Kyotaro Horiguchi , pgsql-hackers@lists.postgresql.org Subject: Re: Review for GetWALAvailability() Message-ID: <20200625035718.GA28721@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <17a69cfe-f1c1-a416-ee25-ae15427c69eb@oss.nttdata.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-25, Fujii Masao wrote: > /* > * Find the oldest extant segment file. We get 1 until checkpoint removes > * the first WAL segment file since startup, which causes the status being > * wrong under certain abnormal conditions but that doesn't actually harm. > */ > oldestSeg = XLogGetLastRemovedSegno() + 1; > > I see the point of the above comment, but this can cause wal_status to be > changed from "lost" to "unreserved" after the server restart. Isn't this > really confusing? At least it seems better to document that behavior. Hmm. > Or if we *can ensure* that the slot with invalidated_at set always means > "lost" slot, we can judge that wal_status is "lost" without using fragile > XLogGetLastRemovedSegno(). Thought? Hmm, this sounds compelling -- I think it just means we need to ensure we reset invalidated_at to zero if the slot's restart_lsn is set to a correct position afterwards. I don't think we have any operation that does that, so it should be safe -- hopefully I didn't overlook anything? Neither copy nor advance seem to work with a slot that has invalid restart_lsn. > Or XLogGetLastRemovedSegno() should be fixed so that it returns valid > value even after the restart? This seems more work to implement. -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services