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

Commitc1d5895

Browse files
committed
Try next host after a "cannot connect now" failure.
If a server returns ERRCODE_CANNOT_CONNECT_NOW, try the next host,if multiple host names have been provided. This allows dealinggracefully with standby servers that might not be in hot standby modeyet.In the wake of the preceding commit, it might be plausible to retrymany more error cases than we do now, but I (tgl) am hesitant tomove too aggressively on that --- it's not clear it'd be desirablefor cases such as bad-password, for example. But this case seemssafe enough.Hubert Zhang, reviewed by Takayuki TsunakawaDiscussion:https://postgr.es/m/BN6PR05MB3492948E4FD76C156E747E8BC9160@BN6PR05MB3492.namprd05.prod.outlook.com
1 parent52a1022 commitc1d5895

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

‎src/interfaces/libpq/fe-connect.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3315,6 +3315,20 @@ PQconnectPoll(PGconn *conn)
33153315
/* OK, we read the message; mark data consumed */
33163316
conn->inStart=conn->inCursor;
33173317

3318+
/*
3319+
* If error is "cannot connect now", try the next host if
3320+
* any (but we don't want to consider additional addresses
3321+
* for this host, nor is there much point in changing SSL
3322+
* or GSS mode). This is helpful when dealing with
3323+
* standby servers that might not be in hot-standby state.
3324+
*/
3325+
if (strcmp(conn->last_sqlstate,
3326+
ERRCODE_CANNOT_CONNECT_NOW)==0)
3327+
{
3328+
conn->try_next_host= true;
3329+
gotokeep_going;
3330+
}
3331+
33183332
/* Check to see if we should mention pgpassfile */
33193333
pgpassfileWarning(conn);
33203334

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp