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 1jobEG-0004PV-E4 for pgsql-hackers@arkaria.postgresql.org; Thu, 25 Jun 2020 23:24:24 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jobEF-0008CK-AT for pgsql-hackers@arkaria.postgresql.org; Thu, 25 Jun 2020 23:24:23 +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 1jobEF-0008CB-3U for pgsql-hackers@lists.postgresql.org; Thu, 25 Jun 2020 23:24:23 +0000 Received: from mail-qk1-x743.google.com ([2607:f8b0:4864:20::743]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jobEC-0004TK-Ny for pgsql-hackers@postgresql.org; Thu, 25 Jun 2020 23:24:21 +0000 Received: by mail-qk1-x743.google.com with SMTP id q198so7215720qka.2 for ; Thu, 25 Jun 2020 16:24:20 -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=nVisZyDITu+x3kcsSQy6I2/mx9LZqmhey+jQRaxwUmU=; b=yksUCjmm0hCKlkkXcEg7mvRVPwhkQBWRfIxUsWsGVJ/AMndU9eR2vNU6ZgVLbDO01h U6PYvgqdPzYZ06/Apf2Is9K+i0VDikJF/E5m73wKUBZhJHNO4finoVHKBG5l6GdGaXIk WrUvU8QOHbfZoiAyVF0306yORg+QfaF2pHYPK5CTlAfPJBuAd0WFBTnSD8B9r7mOUHGQ WXyVhdtcR2T341z8fcQNWgXvBOowb2TfC4gfEYjIw2Ow8bnjRU3O21nBi6Wk41oKhShG pGk/WOhFgAi3iiKvtbCQka0vwnWfgexVXnWOuiDiRVSyjFqcTOppHJzOqpmmztpNDBev MBFg== 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=nVisZyDITu+x3kcsSQy6I2/mx9LZqmhey+jQRaxwUmU=; b=tbEF9Tplz5XgNNV1o2ohgO77zmZ25RuBqyvOfHdxj/laIn9A0d8YXrK1behj5D/zGs eHh4OtKiYRC1zrAMoItekEJf1wwp2KeYjlMWTdzez5cI7/09s7VB8xZguSNY/EOQOE2R 5iKzBF79K/XCC51X+S3sgsh88WACgG/8suQsaOKeoxgedmaCo3HAw+Ttkfd2s+LRQMic /Ltph5pcnLxqb9wO8z2cMCS8d2bfiQFqwGmcC7XrYU1xrcgEw49G2sq6AJXwk5IFa7du spNZMeonanf5I6Vm5SQIgFk4Vg9/ZdQkAML/aMS9TTouYcuylJmS+KJ9XBFXh2Uom+8y JdsA== X-Gm-Message-State: AOAM532KMhbXljKnH4ei6+5asTDwA7JGu8TE4ZxerQOGXGMH6PJekYkC TXAqu1JqflNXIhmSSExcZuhPDw== X-Google-Smtp-Source: ABdhPJyo5Fz24fxmMWsnY343eQzJ1p4Pd112pvur7+z5NKEwvOBkJukUA+osvKufeIjfC+JJsxo1XA== X-Received: by 2002:a37:b541:: with SMTP id e62mr140434qkf.260.1593127460097; Thu, 25 Jun 2020 16:24:20 -0700 (PDT) Received: from perhan.alvh.no-ip.org ([190.95.18.252]) by smtp.gmail.com with ESMTPSA id m7sm7250771qti.6.2020.06.25.16.24.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jun 2020 16:24:19 -0700 (PDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 41F1D2A3A8F; Thu, 25 Jun 2020 19:24:17 -0400 (-04) Date: Thu, 25 Jun 2020 19:24:17 -0400 From: Alvaro Herrera To: Michael Paquier Cc: Amit Kapila , Fujii Masao , Kyotaro Horiguchi , pgsql-hackers Subject: Re: min_safe_lsn column in pg_replication_slots view Message-ID: <20200625232417.GA11415@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20200625225350.GA1504@paquier.xyz> 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-26, Michael Paquier wrote: > On Thu, Jun 25, 2020 at 11:24:27AM -0400, Alvaro Herrera wrote: > > I don't understand the proposal. Michael posted a patch that adds > > pg_wal_oldest_lsn(), and you say we should apply the patch except the > > part that adds that function -- so what part would be applying? > > I have sent last week a patch about only the removal of min_safe_lsn: > https://www.postgresql.org/message-id/20200619121552.GH453547@paquier.xyz > So this applies to this part. Well, I oppose that because it leaves us with no way to monitor slot limits. In his opening email, Masao-san proposed to simply change the value by adding 1. How you go from adding 1 to a column to removing the column completely with no recourse, is beyond me. Let me summarize the situation and possible ways forward as I see them. If I'm mistaken, please correct me. Problems: i) pg_replication_slot.min_safe_lsn has a weird definition in that all replication slots show the same value ii) min_safe_lsn cannot be used with pg_walfile_name, because it returns the name of the previous segment. Proposed solutions: a) Do nothing -- keep the min_safe_lsn column as is. Warn users that pg_walfile_name should not be used with this column. b) Redefine min_safe_lsn to be lsn+1, so that pg_walfile_name can be used and return a useful value. c) Remove min_safe_lsn; add functions that expose the same value d) Remove min_safe_lsn; add a new view that exposes the same value and possibly others e) Replace min_safe_lsn with a "distance" column, which reports restart_lsn - oldest valid LSN (Note that you no longer have an LSN in this scenario, so you can't call pg_walfile_name.) The original patch implemented (e); it was changed to its current definition because of this[1] comment. My proposal is to put it back. [1] https://postgr.es/m/20171106132050.6apzynxrqrzghb4r@alap3.anarazel.de -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services