Re: Nicer error when connecting to standby with hot_standby=off

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: James Coleman <jtc331(at)gmail(dot)com>
Cc: Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>, Magnus Hagander <magnus(at)hagander(dot)net>, David Steele <david(at)pgmasters(dot)net>, David Zhang <david(dot)zhang(at)highgo(dot)ca>, PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Nicer error when connecting to standby with hot_standby=off
Date: 2021-03-23 16:20:11
Message-ID: 20210323162011.GA14590@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2021-Mar-23, James Coleman wrote:

> On Tue, Mar 23, 2021 at 1:46 AM Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com> wrote:

> > Therefore for now what we've not reached the consensus is what message
> > should be logged at PM_STARTUP. I'm thinking it's better to log
> > "the database system is starting up" in that case because of the reasons
> > that I explained upthread.

> I understand your point now, and I agree, that makes sense.

Please note that PM_STARTUP mode is very very short-lived. It only
starts happening when postmaster launches the startup process, and
before the startup process begins WAL replay (as changed by
sigusr1_handler in postmaster.c). Once WAL replay begins, the PM status
changes to PM_RECOVERY. So I don't think we really care all that much
what message is logged in this case. It changes very quickly into the
CAC_NOTCONSISTENT message anyway. For this state, it seems okay with
either what James submitted in v7, or what Fujii said.

However, for this one

+ case CAC_NOTCONSISTENT:
+ if (EnableHotStandby)
+ ereport(FATAL,
+ (errcode(ERRCODE_CANNOT_CONNECT_NOW),
+ errmsg("the database system is not accepting connections"),
+ errdetail("Consistent recovery state has not been yet reached.")));

Maybe it makes sense to say "... is not accepting connections *yet*".
That'd be a tad redundant with what the DETAIL says, but that seems
acceptable.

--
Álvaro Herrera 39°49'30"S 73°17'W

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Stephen Frost 2021-03-23 16:24:46 Re: Change default of checkpoint_completion_target
Previous Message Tom Lane 2021-03-23 15:45:37 Re: Add Nullif case for eval_const_expressions_mutator