BUG #16299: pg_subscription_rel inconsistency post create database from template with disabled subscription

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: eric(dot)cyr(at)gmail(dot)com
Subject: BUG #16299: pg_subscription_rel inconsistency post create database from template with disabled subscription
Date: 2020-03-12 13:45:45
Message-ID: 16299-0e518acf3ff4956e@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 16299
Logged by: Eric Cyr
Email address: eric(dot)cyr(at)gmail(dot)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

Browse pgsql-bugs by date

  From Date Subject
Next Message Demarest, Jamie 2020-03-12 14:35:35 RE: Postgresql create a core while trying log a message to syslog
Previous Message Richard Guo 2020-03-12 10:22:25 Re: Optimizer Doesn't Push Down Where Expressions on Rollups