Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1s1yXE-00GSBy-SQ for pgsql-hackers@arkaria.postgresql.org; Wed, 01 May 2024 01:13:24 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1s1yXB-009kIp-TS for pgsql-hackers@arkaria.postgresql.org; Wed, 01 May 2024 01:13:22 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1s1yXB-009kIh-K1 for pgsql-hackers@lists.postgresql.org; Wed, 01 May 2024 01:13:22 +0000 Received: from mail-il1-x129.google.com ([2607:f8b0:4864:20::129]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1s1yX9-000r8U-Uq for pgsql-hackers@postgresql.org; Wed, 01 May 2024 01:13:21 +0000 Received: by mail-il1-x129.google.com with SMTP id e9e14a558f8ab-36c546b7d04so9314195ab.0 for ; Tue, 30 Apr 2024 18:13:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714525999; x=1715130799; darn=postgresql.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=iFn9y3XIBrnX/8ro3tqROHQafPF/MjELYR75w+iZ/ug=; b=hwOeh6DatVPkzqLL6o5aB/x0DVgs17zlLw4prXVMZqx3eA+BdSw+SxnjZ9Ftgl7td9 NdE/UBl3lMqUESidlQujSqAVilnWn0tOQ+pveQA3xR5akMASL4ZrGgvnR3aiMAW7ur0Q ++JLE/hJPyaaYt4SQ3MY6rQrzZEc2YIs7/J9Zo9Pa3aKvxloZJ1537mPc+h4toI8l4OF ioRfEht42QFc6/QbQyN7YhEuy6d1jGXACSFIwSQ928dLBa7goHLO1MTMKYGId+SAcqMP zf1rpTAhRPV5JwJ7vTLpZVLBMIrPJvHzKC/rqyfPazrKFEYBxKL/Jd/HtrKJ1Or56AtB MiBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714525999; x=1715130799; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=iFn9y3XIBrnX/8ro3tqROHQafPF/MjELYR75w+iZ/ug=; b=RtyhPeZZS7mkamWofs2DFuyWuLWpEULqIS+pvV95sXPor0xqeKcZOxnvmlyatt4Qf0 V41Y7DuHEcVOns2BzcNY+WYQDWBE/wTTbwVqsgj/RUmGueoudkOATyLzxxogK5L7MphF POSuexpDBpI7ndJqq/oNds7QA4NrGyqIi6111rGjMsIMjT45wtJc6Wkno9h60gEdwEda uMfh5TsF/SUA3+VGsHcLPLUPL5OPpswWZoTEAGRSt6VdRJjxx95K9W19/zmSUUgFf+v2 ni9DT8GzTANIx/uxr+Vmp3vKRg1jzJ8sCY6UNECgKXeM6j1BPbsiVaRK4HmksYcFAYGp rcZQ== X-Gm-Message-State: AOJu0Yw//dYo75JSBvFNN/dLEIIVT2ROVEPhjMWTG6Lpc/YDU6Mqzkt0 ctH6NXWALwB1e3UoAkwUVqXAHUoLYkG30yDFvPcx3IwQZTxPQByV X-Google-Smtp-Source: AGHT+IGJqXcMfJn0U5S/GthgotbErThiylFYbegCHh/OUej7MYVc3bsPwczyfrAJ39yhfN3iTx7UcQ== X-Received: by 2002:a05:6e02:1aa5:b0:36b:3a3b:b2c0 with SMTP id l5-20020a056e021aa500b0036b3a3bb2c0mr1475445ilv.32.1714525998983; Tue, 30 Apr 2024 18:13:18 -0700 (PDT) Received: from nathanxps13 (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id x3-20020a92cc83000000b0036c03b1ee38sm5069208ilo.37.2024.04.30.18.13.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Apr 2024 18:13:18 -0700 (PDT) Date: Tue, 30 Apr 2024 20:13:17 -0500 From: Nathan Bossart To: Tom Lane Cc: pgsql-hackers@postgresql.org Subject: Re: pg_sequence_last_value() for unlogged sequences on standbys Message-ID: <20240501011317.GC594666@nathanxps13> References: <20240501005730.GA594666@nathanxps13> <1846474.1714525564@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1846474.1714525564@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, Apr 30, 2024 at 09:06:04PM -0400, Tom Lane wrote: > Nathan Bossart writes: >> If you create an unlogged sequence on a primary, pg_sequence_last_value() >> for that sequence on a standby will error like so: >> postgres=# select pg_sequence_last_value('test'::regclass); >> ERROR: could not open file "base/5/16388": No such file or directory > >> As pointed out a few years ago [0], this function is undocumented, so >> there's no stated contract to uphold. I lean towards just returning NULL >> because that's what we'll have to put in the relevant pg_sequences field >> anyway, but I can see an argument for fixing the ERROR to align with what >> you see when you try to access unlogged relations on a standby (i.e., >> "cannot access temporary or unlogged relations during recovery"). > > Yeah, I agree with putting that logic into the function. Putting > such conditions into the SQL of a system view is risky because it > is really, really painful to adjust the SQL in a released version. > You could back-patch a fix for this if done at the C level, but > I doubt we'd go to the trouble if it's done in the view. Good point. I'll work on a patch along these lines, then. -- Nathan Bossart Amazon Web Services: https://aws.amazon.com