jackc / pglogrepl

PostgreSQL logical replication library for Go.
MIT License
330 stars 62 forks source link

is timeline relevant when starting a logical slot? #13

Open kmulvey opened 3 years ago

kmulvey commented 3 years ago

I get an error when trying to include timeline in the start config for a logical slot. The postgres docs dont seem to mention anything about timeline with regard to logical, they do however for physical.

docs:

START_REPLICATION SLOT slot_name LOGICAL XXX/XXX [ ( option_name [ option_value ] [, ...] ) ]
vs
START_REPLICATION [ SLOT slot_name ] [ PHYSICAL ] XXX/XXX [ TIMELINE tli ] 

result of pglogrepl.IdentifySystem()

{"level":"info","msg":"SystemID: 6938529628705222694 Timeline: 1 XLogPos: 0/1765F08 DBName: postgres","time":"2021-03-11T22:43:05Z"}

sql print from here

sql: START_REPLICATION SLOT regression_slot LOGICAL 0/1765FF0 (TIMELINE 1)

error

failed to start replication: ERROR: syntax error (SQLSTATE 42601)

possible solution? Should this be changed to:

if options.Timeline > 0 && options.Mode == PhysicalReplication {
jackc commented 3 years ago

If timeline really shouldn't be set on a logical replication connection then shouldn't an error be generated somewhere? Maybe bubbling up from PG isn't the best but silently ignoring a bad argument is not ideal either.