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

Commit16671ba

Browse files
committed
Move canAcceptConnections check from ProcessStartupPacket to caller.
The check is not about processing the startup packet, so the callingfunction seems like a more natural place. I'm also working on a patchthat moves 'canAcceptConnections' out of the Port struct, and thismakes that refactoring more convenient.Reviewed-by: Tristan PartinDiscussion:https://www.postgresql.org/message-id/7a59b073-5b5b-151e-7ed3-8b01ff7ce9ef@iki.fi
1 parentc7c801e commit16671ba

File tree

1 file changed

+43
-43
lines changed

1 file changed

+43
-43
lines changed

‎src/backend/postmaster/postmaster.c

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -2281,49 +2281,6 @@ ProcessStartupPacket(Port *port, bool ssl_done, bool gss_done)
22812281
*/
22822282
MemoryContextSwitchTo(oldcontext);
22832283

2284-
/*
2285-
* If we're going to reject the connection due to database state, say so
2286-
* now instead of wasting cycles on an authentication exchange. (This also
2287-
* allows a pg_ping utility to be written.)
2288-
*/
2289-
switch (port->canAcceptConnections)
2290-
{
2291-
caseCAC_STARTUP:
2292-
ereport(FATAL,
2293-
(errcode(ERRCODE_CANNOT_CONNECT_NOW),
2294-
errmsg("the database system is starting up")));
2295-
break;
2296-
caseCAC_NOTCONSISTENT:
2297-
if (EnableHotStandby)
2298-
ereport(FATAL,
2299-
(errcode(ERRCODE_CANNOT_CONNECT_NOW),
2300-
errmsg("the database system is not yet accepting connections"),
2301-
errdetail("Consistent recovery state has not been yet reached.")));
2302-
else
2303-
ereport(FATAL,
2304-
(errcode(ERRCODE_CANNOT_CONNECT_NOW),
2305-
errmsg("the database system is not accepting connections"),
2306-
errdetail("Hot standby mode is disabled.")));
2307-
break;
2308-
caseCAC_SHUTDOWN:
2309-
ereport(FATAL,
2310-
(errcode(ERRCODE_CANNOT_CONNECT_NOW),
2311-
errmsg("the database system is shutting down")));
2312-
break;
2313-
caseCAC_RECOVERY:
2314-
ereport(FATAL,
2315-
(errcode(ERRCODE_CANNOT_CONNECT_NOW),
2316-
errmsg("the database system is in recovery mode")));
2317-
break;
2318-
caseCAC_TOOMANY:
2319-
ereport(FATAL,
2320-
(errcode(ERRCODE_TOO_MANY_CONNECTIONS),
2321-
errmsg("sorry, too many clients already")));
2322-
break;
2323-
caseCAC_OK:
2324-
break;
2325-
}
2326-
23272284
returnSTATUS_OK;
23282285
}
23292286

@@ -4360,6 +4317,49 @@ BackendInitialize(Port *port)
43604317
*/
43614318
status=ProcessStartupPacket(port, false, false);
43624319

4320+
/*
4321+
* If we're going to reject the connection due to database state, say so
4322+
* now instead of wasting cycles on an authentication exchange. (This also
4323+
* allows a pg_ping utility to be written.)
4324+
*/
4325+
switch (port->canAcceptConnections)
4326+
{
4327+
caseCAC_STARTUP:
4328+
ereport(FATAL,
4329+
(errcode(ERRCODE_CANNOT_CONNECT_NOW),
4330+
errmsg("the database system is starting up")));
4331+
break;
4332+
caseCAC_NOTCONSISTENT:
4333+
if (EnableHotStandby)
4334+
ereport(FATAL,
4335+
(errcode(ERRCODE_CANNOT_CONNECT_NOW),
4336+
errmsg("the database system is not yet accepting connections"),
4337+
errdetail("Consistent recovery state has not been yet reached.")));
4338+
else
4339+
ereport(FATAL,
4340+
(errcode(ERRCODE_CANNOT_CONNECT_NOW),
4341+
errmsg("the database system is not accepting connections"),
4342+
errdetail("Hot standby mode is disabled.")));
4343+
break;
4344+
caseCAC_SHUTDOWN:
4345+
ereport(FATAL,
4346+
(errcode(ERRCODE_CANNOT_CONNECT_NOW),
4347+
errmsg("the database system is shutting down")));
4348+
break;
4349+
caseCAC_RECOVERY:
4350+
ereport(FATAL,
4351+
(errcode(ERRCODE_CANNOT_CONNECT_NOW),
4352+
errmsg("the database system is in recovery mode")));
4353+
break;
4354+
caseCAC_TOOMANY:
4355+
ereport(FATAL,
4356+
(errcode(ERRCODE_TOO_MANY_CONNECTIONS),
4357+
errmsg("sorry, too many clients already")));
4358+
break;
4359+
caseCAC_OK:
4360+
break;
4361+
}
4362+
43634363
/*
43644364
* Disable the timeout, and prevent SIGTERM again.
43654365
*/

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp