Обсуждение: After an error - pg_replication_slot is dropped
Hi,
Please refer this straight forward scenario against latest sources of v11.
[centos@centos-cpula bin]$ ./psql postgres
psql (11devel)
Type "help" for help.
postgres=# SELECT * FROM
pg_create_logical_replication_slot('regression_slot1', 'test_decoding',
true);
slot_name | lsn
------------------+-----------
regression_slot1 | 0/40001E8
(1 row)
postgres=#
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
------------------+---------------+-----------+--------+----------+-----------+--------+------------+------+--------------+-------------+---------------------
regression_slot1 | test_decoding | logical | 13220 | postgres |
t | t | 28015 | | 557 | 0/40001B0 |
0/40001E8
(1 row)
--Try to again create the same slot , getting an error - which is expected
postgres=#
postgres=# SELECT * FROM
pg_create_logical_replication_slot('regression_slot1', 'test_decoding',
true);
ERROR: replication slot "regression_slot1" already exists
postgres=#
--No slot found
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
-----------+--------+-----------+--------+----------+-----------+--------+------------+------+--------------+-------------+---------------------
(0 rows)
--
regards,tushar
EnterpriseDB https://www.enterprisedb.com/
The Enterprise PostgreSQL Company
Hi,
On 16/02/18 10:51, tushar wrote:
> Hi,
>
> Please refer this straight forward scenario against latest sources of v11.
>
> [centos@centos-cpula bin]$ ./psql postgres
> psql (11devel)
> Type "help" for help.
>
> postgres=# SELECT * FROM
> pg_create_logical_replication_slot('regression_slot1', 'test_decoding',
> true);
> slot_name | lsn
> ------------------+-----------
> regression_slot1 | 0/40001E8
> (1 row)
>
> postgres=#
> 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
>
------------------+---------------+-----------+--------+----------+-----------+--------+------------+------+--------------+-------------+---------------------
>
> regression_slot1 | test_decoding | logical | 13220 | postgres |
> t | t | 28015 | | 557 | 0/40001B0 |
> 0/40001E8
> (1 row)
>
> --Try to again create the same slot , getting an error - which is expected
> postgres=#
> postgres=# SELECT * FROM
> pg_create_logical_replication_slot('regression_slot1', 'test_decoding',
> true);
> ERROR: replication slot "regression_slot1" already exists
> postgres=#
>
> --No slot found
> 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
>
-----------+--------+-----------+--------+----------+-----------+--------+------------+------+--------------+-------------+---------------------
>
> (0 rows)
>
It's because you are creating temporary slot. Temporary slots are
removed on error, that's a documented behavior.
--
Petr Jelinek http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services
On 02/16/2018 04:02 PM, Petr Jelinek wrote: > It's because you are creating temporary slot. Temporary slots are > removed on error, that's a documented behavior. Thanks for pointing out but It looks weird behavior - even a small mea culpa can remove the slot. Temporary table - doesn't go automatically after an error ? -- regards,tushar EnterpriseDB https://www.enterprisedb.com/ The Enterprise PostgreSQL Company
On 16/02/18 12:38, tushar wrote: > On 02/16/2018 04:02 PM, Petr Jelinek wrote: >> It's because you are creating temporary slot. Temporary slots are >> removed on error, that's a documented behavior. > > Thanks for pointing out but It looks weird behavior - even a small mea > culpa can remove the slot. Temporary table - doesn't go automatically > after an error ? > Temporary tables have transactional properties, slots don't (even the non-temporary). For example if you create replication slot in transaction and then abort it, the slot will survive. That's the price we pay for ability to create slots on standby. -- Petr Jelinek http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services