Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create multiple logical replication slots #49

Open
MilenBlagojevic opened this issue Sep 16, 2024 · 0 comments
Open

Create multiple logical replication slots #49

MilenBlagojevic opened this issue Sep 16, 2024 · 0 comments

Comments

@MilenBlagojevic
Copy link

MilenBlagojevic commented Sep 16, 2024

Hello,

I have simple setup with primary and one streaming replica. pg_failover_slots extension on both of them is configured and working.

Then, I create 2 logical replication slots:

publisher=# SELECT * FROM pg_create_logical_replication_slot('logical_replication_slot_1', 'test_decoding');
         slot_name          |     lsn
----------------------------+-------------
 logical_replication_slot_1 | 7C/36191128
(1 row)


publisher=# SELECT * FROM pg_create_logical_replication_slot('logical_replication_slot_2', 'test_decoding');
         slot_name          |     lsn
----------------------------+-------------
 logical_replication_slot_2 | 7C/36191160
(1 row)

publisher=# 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
----------------------------+---------------+-----------+---------+----------+-----------+--------+------------+-----------+--------------+-------------+---------------------+------------+---------------
 logical_replication_slot_1 | test_decoding | logical   | 1037644 | publisher| f         | f      |            |           |    119372965 | 7C/361910F0 | 7C/36191128         | reserved   |
 logical_replication_slot_2 | test_decoding | logical   | 1037644 | publisher| f         | f      |            |           |    119372965 | 7C/36191128 | 7C/36191160         | reserved   |
 physical_repl              |               | physical  |         |          | f         | t      |      16192 | 119372999 |    119372999 | 7C/3715F4A8 |                     | reserved   |
(3 rows)

Streaming replica shows one of them:

publisher=# 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
----------------------------+---------------+-----------+---------+----------+-----------+--------+------------+------+--------------+-------------+---------------------+------------+---------------
 logical_replication_slot_1 | test_decoding | logical   | 1037644 | publisher| f         | t      |       3457 |      |    119372999 | 7C/3407FF88 |                     | reserved   |
(1 row)

And the failover_worker on it logs these warnings:

still waiting for remote slot logical_replication_slot_1 lsn (7C/361910F0) and catalog xmin (119372965) to pass local slot lsn (7C/3407FF88) and catalog xmin (119372999)

So, even if there are some changes for logical_replication_slot_2, its position is not being synced to streaming replica, because logical_replication_slot_1 is not consumed.

Should pg_failover_slots work like this?

I know the workaround would be to consume logical_replication_slot_1 one first and then create logical_replication_slot_2.

Regards,
Milen

@MilenBlagojevic MilenBlagojevic changed the title When creating multiple replication slots on primary, none of them gets sync-ed until the first one does not get subscriber. Create multiple logical replication slots Sep 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant