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 1pyyaA-0008TU-81 for pgsql-general@arkaria.postgresql.org; Tue, 16 May 2023 17:35:30 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pyya8-0000yV-OZ for pgsql-general@arkaria.postgresql.org; Tue, 16 May 2023 17:35:28 +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 1pyya8-0000xr-BT for pgsql-general@lists.postgresql.org; Tue, 16 May 2023 17:35:28 +0000 Received: from lana.depesz.com ([88.198.49.178] helo=depesz.com) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1pyya4-000AB9-5o for pgsql-general@lists.postgresql.org; Tue, 16 May 2023 17:35:27 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=depesz.com; s=20170201; h=In-Reply-To:Content-Type:MIME-Version:References:Reply-To: Message-ID:Subject:To:Sender:From:Date:Cc:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=PApJ1L4KgrNcjZoXBQeUQkEiUYHVNBN0272A/clglB4=; b=QYc+ofmkJG5YDoO4EBymX9b0BN qqSl/9btpPitFimnnqtShGf0/s5m2+1+tdheQIEfq9s/OYR2R8bPNM+TM6kgwkp5/iwDe9/zoSSfD CXvJePI/KfoEYXncYvu9RUoTxfVzg3dxOK5sds67i4MBEVPFTOhlUwk+af84YUNwZkZY=; Received: from depesz by depesz.com with local (Exim 4.94.2) (envelope-from ) id 1pyya0-00C9dE-Kk for pgsql-general@lists.postgresql.org; Tue, 16 May 2023 19:35:20 +0200 Date: Tue, 16 May 2023 19:35:20 +0200 From: hubert depesz lubaczewski Sender: depesz@depesz.com To: pgsql-general Subject: Re: How can I change replication slot's restart_lsn from SQL? Message-ID: Reply-To: depesz@depesz.com References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, May 16, 2023 at 04:23:02PM +0200, hubert depesz lubaczewski wrote: > Hi, > I'm working on a workaround for a bug in Pg > (https://www.postgresql.org/message-id/flat/Yz2hivgyjS1RfMKs%40depesz.com) > I want to create replication slot, and advance is manually, keeping it > always a bit lagging behind real replication slot. > > I can create slot, no problem: > select pg_create_logical_replication_slot('depesz', 'test_decoding'); > and then I can, theoretically, advance it to whatever position with > select * from pg_replication_slot_advance('depesz', '...'); > > *BUT* - it changes only confirmed_flush_lsn, leaving restart_lsn as it > was. > > How can I advance restart_lsn of a slot? > > Generally my idea is to get lsn from real replication slot, subtract, > let's say 1GB from it, and advance my "fake slot" to this value, this > keeping always buffer of 1GB in case the bug with removed wal happened > again. > > I will be doing this on Pg12, which can limit my options, but perhaps > there is some way to do it via plain(ish) SQL ? Hi, if doing it via SQL is not an option, is there any way to have replication slot and modify it's restart_lsn, regardless of whether it will b e physical, or logical, and what tool shoudl I use. I tried with pg_recvlogical, and read https://www.postgresql.org/docs/current/protocol-replication.html but I don't see how I can make restart_lsn advance to anything. Best regards, depesz