jackc / jackc/pglogrepl

is timeline relevant when starting a logical slot?

Open
#13 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
546
Forks
83
Avg merge
2d 21h
Merged PRs (30d)
1

Description

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](https://github.com/jackc/pglogrepl/blob/master/pglogrepl.go#L260)
```
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](https://github.com/jackc/pglogrepl/blob/master/pglogrepl.go#L247) be changed to:
```
if options.Timeline > 0 && options.Mode == PhysicalReplication {
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in pglogrepl.go around the option handling at line 247 and SQL assembly at line 260, then compare the logical and physical START_REPLICATION syntax shown in the issue. Done means logical replication no longer emits the TIMELINE option, while physical replication retains its existing timeline behavior; verify the resulting SQL against PostgreSQL syntax.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, postgresql
Domain
databases
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.