Documentation Index
Fetch the complete documentation index at: https://powersync-mintlify-e254fcc3.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Logical Replication Slots
Postgres logical replication slots are used to keep track of replication progress (recorded as a LSN). Every time a new version of Sync Streams or Sync Rules is deployed, PowerSync creates a new replication slot. Once the new version is fully processed, PowerSync switches to use the new slot and deletes the old one. The replication slots can be viewed using this query:| slot_name | confirmed_flush_lsn | active | lag |
|---|---|---|---|
| powersync_1_c3c8cf21 | 0/70D8240 | 1 | 56 bytes |
| powersync_2_e62d7e0f | 0/70D8240 | 1 | 56 bytes |
Recovering from an Invalidated Slot
A replication slot becomes invalidated when itswal_status is lost. This happens when the WAL data needed by the slot has been removed, typically because the replication lag exceeded max_slot_wal_keep_size.
When this occurs, you will see an error such as:
Replication slot powersync_1_xxxx was invalidated (reason: wal_removed). Increase max_slot_wal_keep_size on the source database and delete the existing slot to recover.To recover:
-
Increase
max_slot_wal_keep_sizeon the source Postgres database to prevent re-occurrence. See Managing and Monitoring Replication Lag for sizing guidance. - Drop the invalidated slot:
powersync_1_xxxx with the actual slot name from the error message.
- Restart the PowerSync Service. It will create a new replication slot and begin replication from scratch.
If the slot was invalidated during the initial snapshot (before it completed), the PowerSync Service will not automatically retry. You must drop the invalidated slot manually before the service can recover.
idle_timeout (Postgres 18+), the slot was invalidated due to inactivity. In this case, increase idle_replication_slot_timeout on the source database instead.
Maximum Replication Slots
Postgres is configured with a maximum number of replication slots per server. Each PowerSync instance uses one replication slot for replication and an additional one while deploying a new Sync Streams or Sync Rules version. The maximum number of PowerSync instances you can connect to one Postgres server is equal to the maximum number of replication slots, minus one. If other clients are also using replication slots, this number is reduced further. To configure the maximum number of slots, setmax_replication_slots (though not all hosting providers expose this setting). Check the current value using: