0

I have a publisher and a subscriber. Every so often I get:

ERROR:  could not receive data from WAL stream: server closed the connection unexpectedly
This probably means the server terminated abnormally before or while processing the request.

I can guess why it terminates abnormally, one of the computers turn off. However, when the two computers are connected again, it doesn't restart automatically.

The only thing that works is to truncate all the tables in the subscription, delete the subscription and publication and create the subscription and publication again.

I tried looking at the WAL, they're very nice. Not sure what to do otherwise.

Here are some pictures:

sub table stuff pub table stuff sub log pub log

Laurenz Albe
  • 209,280
  • 17
  • 206
  • 263

1 Answers1

0

It should not be necessary to re-initialize logical replication just because there was a connection problem. The logical replication slot on the primary will make sure that all required information is retained on the server so that replication can be resumed later on.

Reading you primary log, it looks like you are just hitting a timeout because there is nothing to replicate. That shouldn't be a problem, but you can set wal_sender_timeout = 0 on the primary to disable the timeout.

Laurenz Albe
  • 209,280
  • 17
  • 206
  • 263