We are setting up logical replication between a Postgres 14 instance to a Postgres 15 instance. When we upgraded from 12 to 14, we never had this issue of over provisioning replication slots.
We have set max_sync_workers_per_subscription
to 6
on our destination database server. When we create a subscription, our subscription creates 6 replication slots initially, but slowly over time creates more replication slots and create 17 or more replication slots and attempts to create more replication slots than our max_replication_slots
limit.
[7415]:STATEMENT: CREATE_REPLICATION_SLOT "pg_85959_sync_82836_7356045360683676565" LOGICAL pgoutput USE_SNAPSHOT
[7416]:ERROR: all replication slots are in use
[7416]:HINT: Free one or increase max_replication_slots.
Why is the source database server attempting to create more replication slots than what is allowed?