Re: Catalog_xmin is not advanced when a logical slot is lost
sirisha chamarthi <sirichamarthi22@gmail.com>
From: sirisha chamarthi <sirichamarthi22@gmail.com>
To: Alvaro Herrera <alvherre@alvh.no-ip.org>
Cc: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>,
pgsql-hackers@lists.postgresql.org, Amit Kapila <amit.kapila16@gmail.com>,
Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Date: 2022-11-21T16:49:08Z
Lists: pgsql-hackers
On Mon, Nov 21, 2022 at 8:05 AM Alvaro Herrera <alvherre@alvh.no-ip.org>
wrote:
> On 2022-Nov-21, sirisha chamarthi wrote:
>
> > > > I am a fan of stricter, all-assumption-covering conditions. In case
> we
> > > > don't want to check restart_lsn, an Assert might be useful to
> validate
> > > > our assumption.
> > >
> > > Agreed. I'll throw in an assert.
> >
> > Changed this in the patch to throw an assert.
>
> Thank you. I had pushed mine for CirrusCI to test, and it failed the
> assert I added in slot.c:
> https://cirrus-ci.com/build/4786354503548928
> Not yet sure why, looking into it.
>
Can this be because restart_lsn is not set to InvalidXLogRecPtr for the
physical slots? My repro is as follows:
select pg_create_physical_replication_slot('s5');
// Load some data to invalidate slot
postgres@pgvm:~$ /usr/local/pgsql/bin/pg_receivewal -S s5 -D .
pg_receivewal: error: unexpected termination of replication stream: ERROR:
requested WAL segment 0000000100000000000000EB has already been removed
pg_receivewal: disconnected; waiting 5 seconds to try again
pg_receivewal: error: unexpected termination of replication stream: ERROR:
requested WAL segment 0000000100000000000000EB has already been removed
pg_receivewal: disconnected; waiting 5 seconds to try again
^Cpostgres@pgvm:~$ /usr/local/pgsql/bin/psql
psql (16devel)
Type "help" for help.
postgres=# select * from pg_replication_slots;
slot_name | plugin | slot_type | datoid | database | temporary |
active | active_pid | xmin | catalog_xmin | restart_lsn |
confirmed_flush_lsn | wal_status | safe_wal_size | two_phase
-----------+---------------+-----------+--------+----------+-----------+--------+------------+------+--------------+-------------+---------------------+------------+---------------+-----------
s3 | test_decoding | logical | 5 | postgres | f | f
| | | 769 | | 0/A992E7D0
| lost | | f
s5 | | physical | | | f | f
| | | | 0/EB000000 |
| lost | | f
>
>
> --
> Álvaro Herrera PostgreSQL Developer —
> https://www.EnterpriseDB.com/
>
Commits
-
Ignore invalidated slots while computing oldest catalog Xmin
- 36eeb37cd611 13.10 landed
- 1b3ed757145d 14.7 landed
- 1ad033df16df 15.2 landed
- 0557e1770230 16.0 landed