On 2021/03/24 16:59, Alvaro Herrera wrote:
On 2021-Mar-24, Fujii Masao wrote:
On 2021/03/24 5:59, Tom Lane wrote:
Alvaro Herrera <alvhe...@alvh.no-ip.org> writes:
FATAL: the database system is starting up
DETAIL: WAL is being applied to recover from a system crash.
or
DETAIL: The system is applying WAL to recover from a system crash.
or
DETAIL: The startup process is applying WAL to recover from a system crash.
I don't think the postmaster has enough context to know if that's
actually true. It just launches the startup process and waits for
results. If somebody saw this during a normal (non-crash) startup,
they'd be justifiably alarmed.
Yes, so logging "the database system is starting up" seems enough to me.
No objection.
Thanks! So I changed the message reported at PM_STARTUP to that one,
based on v8 patch that James posted upthread. I also ran pgindent for
the patch. Attached is the updated version of the patch.
Barring any objection, I will commit this.
Regards,
--
Fujii Masao
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION
diff --git a/src/backend/postmaster/postmaster.c
b/src/backend/postmaster/postmaster.c
index ef0be4ca38..4a3ca78c1b 100644
--- a/src/backend/postmaster/postmaster.c
+++ b/src/backend/postmaster/postmaster.c
@@ -2294,6 +2294,18 @@ retry1:
(errcode(ERRCODE_CANNOT_CONNECT_NOW),
errmsg("the database system is
starting up")));
break;
+ case CAC_NOTCONSISTENT:
+ if (EnableHotStandby)
+ ereport(FATAL,
+
(errcode(ERRCODE_CANNOT_CONNECT_NOW),
+ errmsg("the database system is
not yet accepting connections"),
+ errdetail("Consistent recovery
state has not been yet reached.")));
+ else
+ ereport(FATAL,
+
(errcode(ERRCODE_CANNOT_CONNECT_NOW),
+ errmsg("the database system is
not accepting connections"),
+ errdetail("Hot standby mode is
disabled.")));
+ break;
case CAC_SHUTDOWN:
ereport(FATAL,
(errcode(ERRCODE_CANNOT_CONNECT_NOW),
@@ -2435,10 +2447,11 @@ canAcceptConnections(int backend_type)
{
if (Shutdown > NoShutdown)
return CAC_SHUTDOWN; /* shutdown is pending */
- else if (!FatalError &&
- (pmState == PM_STARTUP ||
- pmState == PM_RECOVERY))
+ else if (!FatalError && pmState == PM_STARTUP)
return CAC_STARTUP; /* normal startup */
+ else if (!FatalError && pmState == PM_RECOVERY)
+ return CAC_NOTCONSISTENT; /* not yet at
consistent recovery
+
* state */
else
return CAC_RECOVERY; /* else must be crash recovery
*/
}
diff --git a/src/include/libpq/libpq-be.h b/src/include/libpq/libpq-be.h
index 30fb4e613d..891394b0c3 100644
--- a/src/include/libpq/libpq-be.h
+++ b/src/include/libpq/libpq-be.h
@@ -70,7 +70,12 @@ typedef struct
typedef enum CAC_state
{
- CAC_OK, CAC_STARTUP, CAC_SHUTDOWN, CAC_RECOVERY, CAC_TOOMANY,
+ CAC_OK,
+ CAC_STARTUP,
+ CAC_SHUTDOWN,
+ CAC_RECOVERY,
+ CAC_NOTCONSISTENT,
+ CAC_TOOMANY,
CAC_SUPERUSER
} CAC_state;