PostgreSQL Bugs

Collected from the PG bugs email list.

Bug ID16299
PG Version12.1
OSUbuntu
Opened2020-03-12 13:45:45+00
Reported byEric Cyr
StatusNew

Body of first available message related to this bug follows.

The following bug has been logged on the website:

Bug reference:      16299
Logged by:          Eric Cyr
Email address:      (redacted)
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

Messages

DateAuthorSubject
2020-03-12 13:45:45+00PG Bug reporting formBUG #16299: pg_subscription_rel inconsistency post create database from template with disabled subscription