pglogrepl icon indicating copy to clipboard operation
pglogrepl copied to clipboard

Please add support for new CREATE_REPLICATION_SLOT statement format

Open thedolphin opened this issue 1 year ago • 2 comments

In PostgreSQL 15, a new format for the CREATE_REPLICATION_SLOT statement was introduced, supporting arbitrary options. In PostgreSQL 17, a great new option, FAILOVER, was added for synchronizing replication slots between servers.

Support for these changes seems to break backward compatibility, but that would be great. It would also be great if all variants of the CREATE_REPLICATION_SLOT statement from different PostgreSQL versions were supported.

thedolphin avatar Nov 12 '24 10:11 thedolphin

For further discussion, quote the formats from the official doc: https://www.postgresql.org/docs/17/protocol-replication.html#PROTOCOL-REPLICATION-CREATE-REPLICATION-SLOT

Old format

CREATE_REPLICATION_SLOT slot_name [ TEMPORARY ] { PHYSICAL [ RESERVE_WAL ] | LOGICAL output_plugin [ EXPORT_SNAPSHOT | NOEXPORT_SNAPSHOT | USE_SNAPSHOT ] }

New format

CREATE_REPLICATION_SLOT slot_name [ TEMPORARY ] { PHYSICAL | LOGICAL output_plugin } [ ( option [, ...] ) ] 

diabloneo avatar Nov 14 '24 01:11 diabloneo

I was able to use the new syntax and set FAILOVER to true using the below value for opts.

createSlotOpts := pglogrepl.CreateReplicationSlotOptions{
		Temporary:      false,
		Mode:           pglogrepl.LogicalReplication,
		SnapshotAction: "(SNAPSHOT 'nothing', FAILOVER TRUE)",
	}

While I would still like to see proper support for the new syntax I can live with the workaround for now.

The-East-Wind avatar Jul 24 '25 08:07 The-East-Wind