How can I change replication slot's restart_lsn from SQL? - Mailing list pgsql-general

From hubert depesz lubaczewski
Subject How can I change replication slot's restart_lsn from SQL?
Date
Msg-id ZGORxidIQbYlZObB@depesz.com
Whole thread Raw
Responses Re: How can I change replication slot's restart_lsn from SQL?  (hubert depesz lubaczewski <depesz@depesz.com>)
List pgsql-general
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 ?

Best regards,

depesz




pgsql-general by date:

Previous
From: Evgeny Morozov
Date:
Subject: Re: "PANIC: could not open critical system index 2662" - twice
Next
From: "Elstermann, Mike"
Date:
Subject: Packed raster data in postgresql?