Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdf93844

Browse files
committed
Improve connection denied error message during recovery.
Previously when an archive recovery or a standby was starting andreached the consistent recovery state but hot_standby was configuredto off, the error message when a client connectted was "the databasesystem is starting up", which was needless confusing and not reallyall that accurate either.This commit improves the connection denied error message duringrecovery, as follows, so that the users immediately know that theirservers are configured to deny those connections.- If hot_standby is disabled, the error message "the database system is not accepting connections" and the detail message "Hot standby mode is disabled." are output when clients connect while an archive recovery or a standby is running.- If hot_standby is enabled, the error message "the database system is not yet accepting connections" and the detail message "Consistent recovery state has not been yet reached." are output when clients connect until the consistent recovery state is reached and postmaster starts accepting read only connections.This commit doesn't change the connection denied error message of"the database system is starting up" during normal server startup andcrash recovery. Because it's still suitable for those situations.Author: James ColemanReviewed-by: Alvaro Herrera, Andres Freund, David Zhang, Tom Lane, Fujii MasaoDiscussion:https://postgr.es/m/CAAaqYe8h5ES_B=F_zDT+Nj9XU7YEwNhKhHA2RE4CFhAQ93hfig@mail.gmail.com
1 parentb34ca59 commitdf93844

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

‎src/backend/postmaster/postmaster.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2294,6 +2294,18 @@ ProcessStartupPacket(Port *port, bool ssl_done, bool gss_done)
22942294
(errcode(ERRCODE_CANNOT_CONNECT_NOW),
22952295
errmsg("the database system is starting up")));
22962296
break;
2297+
caseCAC_NOTCONSISTENT:
2298+
if (EnableHotStandby)
2299+
ereport(FATAL,
2300+
(errcode(ERRCODE_CANNOT_CONNECT_NOW),
2301+
errmsg("the database system is not yet accepting connections"),
2302+
errdetail("Consistent recovery state has not been yet reached.")));
2303+
else
2304+
ereport(FATAL,
2305+
(errcode(ERRCODE_CANNOT_CONNECT_NOW),
2306+
errmsg("the database system is not accepting connections"),
2307+
errdetail("Hot standby mode is disabled.")));
2308+
break;
22972309
caseCAC_SHUTDOWN:
22982310
ereport(FATAL,
22992311
(errcode(ERRCODE_CANNOT_CONNECT_NOW),
@@ -2435,10 +2447,11 @@ canAcceptConnections(int backend_type)
24352447
{
24362448
if (Shutdown>NoShutdown)
24372449
returnCAC_SHUTDOWN;/* shutdown is pending */
2438-
elseif (!FatalError&&
2439-
(pmState==PM_STARTUP||
2440-
pmState==PM_RECOVERY))
2450+
elseif (!FatalError&&pmState==PM_STARTUP)
24412451
returnCAC_STARTUP;/* normal startup */
2452+
elseif (!FatalError&&pmState==PM_RECOVERY)
2453+
returnCAC_NOTCONSISTENT;/* not yet at consistent recovery
2454+
* state */
24422455
else
24432456
returnCAC_RECOVERY;/* else must be crash recovery */
24442457
}

‎src/include/libpq/libpq-be.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,12 @@ typedef struct
7070

7171
typedefenumCAC_state
7272
{
73-
CAC_OK,CAC_STARTUP,CAC_SHUTDOWN,CAC_RECOVERY,CAC_TOOMANY,
73+
CAC_OK,
74+
CAC_STARTUP,
75+
CAC_SHUTDOWN,
76+
CAC_RECOVERY,
77+
CAC_NOTCONSISTENT,
78+
CAC_TOOMANY,
7479
CAC_SUPERUSER
7580
}CAC_state;
7681

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp