Re: Danger of automatic connection reset in psql

From: Haribabu Kommi <kommi(dot)haribabu(at)gmail(dot)com>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: Oleksandr Shulgin <oleksandr(dot)shulgin(at)zalando(dot)de>, Robert Haas <robertmhaas(at)gmail(dot)com>, Jim Nasby <Jim(dot)Nasby(at)bluetreble(dot)com>, Ashutosh Bapat <ashutosh(dot)bapat(at)enterprisedb(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Danger of automatic connection reset in psql
Date: 2016-12-02 06:44:01
Message-ID: CAJrrPGe9ZtfB8huXt1BN5NR8m=HG8_NVwL2RO0Z4D9tWQ0ibnQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Nov 22, 2016 at 11:06 PM, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
wrote:

>
>
> 2016-11-22 13:02 GMT+01:00 Oleksandr Shulgin <oleksandr(dot)shulgin(at)zalando(dot)de
> >:
>
>> On Tue, Nov 22, 2016 at 5:28 AM, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
>> wrote:
>>
>>>
>>> 2016-11-22 3:46 GMT+01:00 Robert Haas <robertmhaas(at)gmail(dot)com>:
>>>
>>>> On Mon, Nov 21, 2016 at 4:55 AM, Oleksandr Shulgin
>>>> <oleksandr(dot)shulgin(at)zalando(dot)de> wrote:
>>>> > On Tue, Nov 15, 2016 at 4:10 PM, Jim Nasby <Jim(dot)Nasby(at)bluetreble(dot)com>
>>>> wrote:
>>>> >>
>>>> >> On 11/14/16 5:41 AM, Oleksandr Shulgin wrote:
>>>> >>>
>>>> >>> Automatic connection reset is a nice feature for server development,
>>>> >>> IMO. Is it really useful for anything else is a good question.
>>>> >>
>>>> >>
>>>> >> I use it all the time for application development; my rebuild script
>>>> will
>>>> >> forcibly kick everyone out to re-create the database. I put that in
>>>> because
>>>> >> I invariably end up with a random psql sitting somewhere that I
>>>> don't want
>>>> >> to track down.
>>>> >>
>>>> >> What currently stinks though is if the connection is dead and the
>>>> next
>>>> >> command I run is a \i, psql just dies instead of re-connecting. It'd
>>>> be nice
>>>> >> if before reading the script it checked connection status and
>>>> attempted a
>>>> >> reconnect.
>>>> >>
>>>> >>> At least an option to control that behavior seems like a good idea,
>>>> >>> maybe even set it to 'no reconnect' by default, so that people who
>>>> >>> really use it can make conscious choice about enabling it in their
>>>> >>> .psqlrc or elsewhere.
>>>> >>
>>>> >>
>>>> >> +1, I don't think it needs to be the default.
>>>> >
>>>> >
>>>> > So if we go in this direction, should the option be specified from
>>>> command
>>>> > line or available via psqlrc (or both?) I think both make sense.
>>>> >
>>>> > What should be the option and control variable names? Something like:
>>>> > --reconnect and RECONNECT? Should we allow reconnect in
>>>> non-interactive
>>>> > mode? I have no use case for that, but it might be different for
>>>> others.
>>>> > If non-interactive is not supported then it could be a simple boolean
>>>> > variable, otherwise we might want something like a tri-state: on /
>>>> off /
>>>> > interactive (the last one being the default).
>>>>
>>>> I think it should just be another psql special variable, like
>>>> AUTOCOMMIT or VERBOSITY. If the user wants to set it on the command
>>>> line, they can just use -v. We don't need a separate, dedicated
>>>> option for this, I think.
>>>>
>>>
>> That makes sense to me.
>>
>> In this case depends on a default. For almost all scripts the sensible
>>> value is "without reconnect". It be unfriendly to use this setting via -v
>>> variable.
>>>
>>
>> Well, if you're running a script it should not be affected as long as
>> default value for this new variable is "interactive" or "off" (and you
>> didn't override it in psqlrc). If you really want to get a "reconnect even
>> from the script" type of behavior, then you'll have to use -v or set the
>> variable from inside the script itself to "on".
>>
>
> ok
>
>
Closed in 2016-11 commitfest with "returned with feedback" status.
Please feel free to update the status once you submit the updated patch.

Regards,
Hari Babu
Fujitsu Australia

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Haribabu Kommi 2016-12-02 06:46:48 Re: [PATCH] Better logging of COPY queries if log_statement='all'
Previous Message Haribabu Kommi 2016-12-02 06:40:27 Re: proposal: psql \setfileref