Question: should we block loopback logical replication to the same database? - Mailing list pgsql-hackers

From Chao Li
Subject Question: should we block loopback logical replication to the same database?
Date
Msg-id 25C3F6A7-DC52-48AE-B43C-0D8665CAB74A@gmail.com
Whole thread Raw
List pgsql-hackers
Hi,

While testing a patch today, I tried to set up logical replication on the same cluster. Although I have done that many
timesbefore, I made a mistake this time: I accidentally ran the CREATE SUBSCRIPTION command in the source database
session,and the subscription was created successfully: 
```
evantest=# CREATE SUBSCRIPTION mysub CONNECTION 'host=localhost dbname=evantest user=repl password=secret' PUBLICATION
mypubWITH (create_slot = false); 
CREATE SUBSCRIPTION
```

After that, something weird started to happen. The destination table was empty, but the logs kept reporting
duplicate-keyerrors. It took me a while to realize that the problem was this mistake. 

This made me wonder whether we should block this kind of loopback logical replication to the same database. I am not
awareof a way to use different destination table names, so this setup does not seem useful. Blocking it could help
preventthis kind of unnecessary mistake. 

Before working on a patch, I wanted to check with hackers first. If there are no objections, I can propose a patch.
Pleaselet me know if I am missing something. 

Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/







pgsql-hackers by date:

Previous
From: Andrei Lepikhov
Date:
Subject: Re: Clean up remove_rel_from_query() after self-join elimination commit
Next
From: Ilya Cherdakov
Date:
Subject: Re: Environment variable to disable diffs file output