From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: eric.cyr@gmail.com
Subject: BUG #16299: pg_subscription_rel inconsistency post create database from template with disabled subscription
Date: Thu, 12 Mar 2020 13:45:45 +0000
Message-ID: <16299-0e518acf3ff4956e@postgresql.org> (raw)
The following bug has been logged on the website:
Bug reference: 16299
Logged by: Eric Cyr
Email address: eric.cyr@gmail.com
PostgreSQL version: 12.1
Operating system: Ubuntu
Description:
Hi,
I stumbled upon what seems to be inconsistency in the pg_subscription_rel
catalog table.
This was noticed after creating a new database using a template which had
disabled subscription.
Although Im sending this to bug report, it didn't cause any issue so far.
Here are the steps to reproduce the situation:
--
CREATE ROLE usr_replication REPLICATION PASSWORD 'test' LOGIN;
--
CREATE DATABASE publisher;
\c publisher
CREATE SCHEMA test;
GRANT USAGE ON SCHEMA test TO usr_replication;
CREATE TABLE test.pub_table
(
id SERIAL,
val1 text
);
GRANT ALL ON TABLE test.pub_table TO usr_replication;
CREATE PUBLICATION pub FOR TABLE test.pub_table;
SELECT pg_create_logical_replication_slot('pub_rslot_1', 'pgoutput');
--
CREATE DATABASE subscriber;
\c subscriber
CREATE SCHEMA test;
GRANT USAGE ON SCHEMA test TO usr_replication;
CREATE TABLE test.pub_table
(
id SERIAL,
val1 text
);
GRANT ALL ON TABLE test.pub_table TO usr_replication;
CREATE SUBSCRIPTION sub
CONNECTION 'dbname=publisher user=usr_replication password=test'
PUBLICATION pub
WITH ( create_slot = FALSE, slot_name = 'pub_rslot_1' )
;
--
\c subscriber
ALTER SUBSCRIPTION sub DISABLE;
\c template1
CREATE DATABASE subscriber_from_template TEMPLATE subscriber;
\c subscriber_from_template
\dRs
-- 0 rows
SELECT * FROM pg_subscription WHERE subdbid = (SELECT oid FROM pg_database
WHERE datname = current_database());
-- 0 rows
SELECT * FROM pg_subscription_rel;
-- 1 rows
Thank you
Have a nice day
Eric
Side note
Maybe, in the meantime, a mention could be added to the documentation.
Reference:
51.54. pg_subscription_rel
"This catalog only contains tables known to the subscription after running
either CREATE SUBSCRIPTION or ALTER SUBSCRIPTION ... REFRESH PUBLICATION."
https://www.postgresql.org/docs/12/catalog-pg-subscription-rel.html
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: noreply@postgresql.org, eric.cyr@gmail.com
Subject: Re: BUG #16299: pg_subscription_rel inconsistency post create database from template with disabled subscription
In-Reply-To: <16299-0e518acf3ff4956e@postgresql.org>
References: <16299-0e518acf3ff4956e@postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox