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 1pzASu-0007RY-8H for pgsql-general@arkaria.postgresql.org; Wed, 17 May 2023 06:16:48 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pzASs-0006Lx-MU for pgsql-general@arkaria.postgresql.org; Wed, 17 May 2023 06:16:46 +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 1pzASs-0006LH-BX for pgsql-general@lists.postgresql.org; Wed, 17 May 2023 06:16:46 +0000 Received: from mail-ed1-x52a.google.com ([2a00:1450:4864:20::52a]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1pzASo-000I3t-DN for pgsql-general@lists.postgresql.org; Wed, 17 May 2023 06:16:45 +0000 Received: by mail-ed1-x52a.google.com with SMTP id 4fb4d7f45d1cf-50b37f3e664so631459a12.1 for ; Tue, 16 May 2023 23:16:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20221208.gappssmtp.com; s=20221208; t=1684304202; x=1686896202; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:from:to:cc:subject:date :message-id:reply-to; bh=OWGPb6QndNxun3ixoGKAXrvEWp4daqcGFnoEGhU10Gw=; b=OgbhqSoxL8HlppHGpF08XDKQio6ToE/o6s+Dx+iiwGVVtJZNXTawP5iJ3oYNp8Woyy CHdGvtwrfpTLBbj0tTVW7vcVz3qAP1mEfnwyXoauzA34w4iJZkBaUDELBB7GRvS0QrvO GjyFLPPcth9CBuARTC7/LO6bDbnEVCbutpU6n1TcSoSvQAIfDhOxvUuk+UtbaSMOsmKv AFq4tlWi7wyj4omfebved5BroEbqtqmWFLfjgmnBaucpIRYunFzYLh3TxqADv0WLlwzI e6sPQmnz5poHUmw9cC15PJH/Xb6K96WMG55ULMF9zkk+aGgvBH7Bel2/j2b9GUvBsk8Q pLew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684304202; x=1686896202; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=OWGPb6QndNxun3ixoGKAXrvEWp4daqcGFnoEGhU10Gw=; b=Guhr+K4bY442Y2hNu5py6Mk6Xt48kZtbrsxgn9nmXFOGcphgw7cqa14hGwpnVL8W3V HfKBKpYD/pYYWea17DWfZY+HpLUaEw92kkc5lO35hRKGGLDOkBpSCqctAJVIqcIaziCF LugHOf+zsE92LSgBcw9YinKYkpX3zRzRRhLGNmUx7nv5yn28lCrwO/nB3hKo39R2k08N xAovTlK/m+ji5XcItkqY8ql3+VTayhNqS6nUC2sj1NSYTKxXBtEtuf50xG84jmE48QoE e3cR4/wuW3kh/W7kaGFEKkqJX9t76iruafRfbAUf2EUrAzewJ1tIqsX5oExiIj2uJ6Ut sREQ== X-Gm-Message-State: AC+VfDyqE+Uk2B0gpOY1sLUNVBkDi6y50n1zd3IqwH+3YOJsn1rJC2s1 rGd9k9YUTOm9jR8HZFY62aN8Ra6muY6hhbGoZLmlSw== X-Google-Smtp-Source: ACHHUZ6zxQ9MAGZHEY7NNMHn/TL0Jz4n7XbBRotHy+8Q7WH7AG68LKGINy/HnMrl5ptyf5XuR9FYxw== X-Received: by 2002:a17:906:6a1b:b0:96a:54e5:55d6 with SMTP id qw27-20020a1709066a1b00b0096a54e555d6mr21194032ejc.48.1684304202056; Tue, 16 May 2023 23:16:42 -0700 (PDT) Received: from localhost.localdomain (178-190-179-50.adsl.highway.telekom.at. [178.190.179.50]) by smtp.gmail.com with ESMTPSA id n12-20020a1709065e0c00b0094f410225c7sm11654704eju.169.2023.05.16.23.16.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 May 2023 23:16:41 -0700 (PDT) Message-ID: Subject: Re: How can I change replication slot's restart_lsn from SQL? From: Laurenz Albe To: depesz@depesz.com, pgsql-general Date: Wed, 17 May 2023 08:16:41 +0200 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.46.4 (3.46.4-1.fc37) MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, 2023-05-16 at 19:35 +0200, hubert depesz lubaczewski wrote: > > I'm working on a workaround for a bug in Pg > > (https://www.postgresql.org/message-id/flat/Yz2hivgyjS1RfMKs%40depesz.c= om) > > I want to create replication slot, and advance is manually, keeping it > > always a bit lagging behind real replication slot. > >=20 > > 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', '...'); > >=20 > > *BUT* - it changes only confirmed_flush_lsn, leaving restart_lsn as it > > was. > >=20 > > How can I advance restart_lsn of a slot? > >=20 > > 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. > >=20 > > 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 ? >=20 > 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. >=20 > I tried with pg_recvlogical, and read > https://www.postgresql.org/docs/current/protocol-replication.html=C2=A0bu= t > I don't see how I can make restart_lsn advance to anything. You could shutdown the server and edit the file in "pg_replslot" with a hex editor. Not very convenient, and you'd have to study the source to understand the format of the file. Yours, Laurenz Albe