Re: Server Crashes if try to provide slot_name='none' at the time of creating subscription.

From: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
To: tushar <tushar(dot)ahuja(at)enterprisedb(dot)com>
Cc: Kuntal Ghosh <kuntalghosh(dot)2007(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Server Crashes if try to provide slot_name='none' at the time of creating subscription.
Date: 2017-05-17 02:21:37
Message-ID: CAD21AoBSjB2KmGRgPtbxmpBycBpTt9kkCpWrQDb7RhuKCpSDoA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, May 16, 2017 at 10:06 PM, tushar <tushar(dot)ahuja(at)enterprisedb(dot)com> wrote:
> On 05/16/2017 06:35 AM, Masahiko Sawada wrote:
>>
>> I've updated Kuntal's patch, added regression test for option
>> combination and updated documentation.
>
> While testing the patch - I found that after dump/restore , we are getting
> an error in the log file once we enable the subscription
>
> \\create subscription
>
> postgres=# CREATE SUBSCRIPTION m1 CONNECTION 'dbname=postgres port=5000 '
> PUBLICATION qdd WITH (slot_name='none');
> NOTICE: synchronized table states
> CREATE SUBSCRIPTION
>
> \\take the dump
> [centos(at)centos-cpula bin]$ ./pg_dump -Fp -p 9000 postgres > /tmp/d.c
> \\check the syntax
> [centos(at)centos-cpula bin]$ cat /tmp/d.c |grep 'create subsc*' -i
> CREATE SUBSCRIPTION m1 CONNECTION 'dbname=postgres port=5000 ' PUBLICATION
> qdd WITH (connect = false, slot_name = '');
> \\execute this same syntax against a new database
> postgres=# create database test;
> CREATE DATABASE
> postgres=# \c test
> You are now connected to database "test" as user "centos".
> test=# CREATE SUBSCRIPTION m1 CONNECTION 'dbname=postgres port=5000 '
> PUBLICATION qdd WITH (connect = false, slot_name = '');
> WARNING: tables were not subscribed, you will have to run ALTER
> SUBSCRIPTION ... REFRESH PUBLICATION to subscribe the tables
> CREATE SUBSCRIPTION
>
> test=# alter subscription m1 refresh publication ;
> ERROR: ALTER SUBSCRIPTION ... REFRESH is not allowed for disabled
> subscriptions
> test=# alter subscription m1 enable ;
> ALTER SUBSCRIPTION
>
> Check the message in log file
>
> 017-05-16 14:04:48.373 BST [18219] LOG: logical replication apply for
> subscription m1 started
> 2017-05-16 14:04:48.381 BST [18219] ERROR: could not start WAL streaming:
> ERROR: replication slot name "" is too short
> 2017-05-16 14:04:48.382 BST [17843] LOG: worker process: logical
> replication worker for subscription 16386 (PID 18219) exited with exit code
> 1
> 2017-05-16 14:04:53.388 BST [17850] LOG: starting logical replication
> worker for subscription "m1"
> 2017-05-16 14:04:53.396 BST [18224] LOG: logical replication apply for
> subscription m1 started
> 2017-05-16 14:04:53.403 BST [18224] ERROR: could not start WAL streaming:
> ERROR: replication slot name "" is too short
>
> Is this error message (ERROR: replication slot name "" is too short ) is
> expected now ?
>

I think there are two bugs; pg_dump should dump slot_name = NONE
instead of '' and subscription should not be created if given slot
name is invalid. The validation check for replication slot name is
done when creating it actually but I think it's more safer to check
when CREATE SUBSCRIPTION. The bug related to setting slot_name = NONE
should be fixed by attached 001 patch, and 002 patch prevents to be
specified invalid replication slot name when CREATE SUBSCRIPTION and
ALTER SUBSCRIPTION SET.

Regards,

--
Masahiko Sawada
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center

Attachment Content-Type Size
001_fix_bug_of_slot_name_none_v3.patch application/octet-stream 6.1 KB
002_disallow_invalid_slot_name.patch application/octet-stream 1.2 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Thomas Munro 2017-05-17 02:22:26 Re: transition table behavior with inheritance appears broken (was: Declarative partitioning - another take)
Previous Message Peter Eisentraut 2017-05-17 02:21:08 Re: synchronous_commit option is not visible after pressing TAB