@@ -844,7 +844,7 @@ postgresql://localhost/mydb
844
844
postgresql://user@localhost
845
845
postgresql://user:secret@localhost
846
846
postgresql://other@localhost/otherdb?connect_timeout=10&application_name=myapp
847
- postgresql://host1:123,host2:456/somedb?target_session_attrs=any&application_name=myapp
847
+ postgresql://host1:123,host2:456/somedb?hostorder=random& target_session_attrs=any&application_name=myapp
848
848
</programlisting>
849
849
Components of the hierarchical part of the <acronym>URI</acronym> can also
850
850
be given as parameters. For example:
@@ -909,14 +909,15 @@ postgresql://%2Fvar%2Flib%2Fpostgresql/dbname
909
909
<title>Specifying Multiple Hosts</title>
910
910
911
911
<para>
912
- It is possible to specify multiple hosts to connect to, so that they are
913
- tried in the given order. In the Keyword/Value format, the <literal>host</>,
914
- <literal>hostaddr</>, and <literal>port</> options accept a comma-separated
915
- list of values. The same number of elements must be given in each option, such
916
- that e.g. the first <literal>hostaddr</> corresponds to the first host name,
917
- the second <literal>hostaddr</> corresponds to the second host name, and so
918
- forth. As an exception, if only one <literal>port</literal> is specified, it
919
- applies to all the hosts.
912
+ It is possible to specify multiple hosts to connect to. In the Keyword/Value
913
+ format, the <literal>host</>, <literal>hostaddr</>, and <literal>port</>
914
+ options accept a comma-separated list of values. The same number of
915
+ elements must be given in each option, such that e.g. the first
916
+ <literal>hostaddr</> corresponds to the first host name, the second
917
+ <literal>hostaddr</> corresponds to the second host name, and so
918
+ forth. As an exception, if only one <literal>port</literal> is specified,
919
+ it applies to all the hosts. The order in which hosts are tried may be
920
+ specified by <xref linkend="libpq-connect-hostorder"> parameter.
920
921
</para>
921
922
922
923
<para>
@@ -967,8 +968,7 @@ postgresql://%2Fvar%2Flib%2Fpostgresql/dbname
967
968
Unix-domain sockets, the default is to connect to <literal>localhost</>.
968
969
</para>
969
970
<para>
970
- A comma-separated list of host names is also accepted, in which case
971
- each host name in the list is tried in order. See
971
+ A comma-separated list of host names is also accepted. See
972
972
<xref linkend="libpq-multiple-hosts"> for details.
973
973
</para>
974
974
</listitem>
@@ -1038,6 +1038,30 @@ postgresql://%2Fvar%2Flib%2Fpostgresql/dbname
1038
1038
</listitem>
1039
1039
</varlistentry>
1040
1040
1041
+ <varlistentry id="libpq-connect-hostorder" xreflabel="hostorder">
1042
+ <term><literal>hostorder</literal></term>
1043
+ <listitem>
1044
+ <para>
1045
+ Specifies the order in which hosts from the list of hosts
1046
+ specified by the <xref linkend="libpq-connect-host"> parameter are
1047
+ tried.
1048
+ </para>
1049
+ <para>
1050
+ If the value of this argument is <literal>sequential</literal> (the
1051
+ default) connections to the hosts will be attempted in the order in
1052
+ which they are given.
1053
+ </para>
1054
+ <para>
1055
+ If the value is <literal>random</literal>, the host to connect to
1056
+ will be randomly picked from the list. It allows load balacing between
1057
+ several cluster nodes. However, PostgreSQL doesn't currently support
1058
+ multimaster clusters. So, without the use of third-party products,
1059
+ only read-only connections can take advantage from load-balancing.
1060
+ See <xref linkend="libpq-connect-target-session-attrs">
1061
+ </para>
1062
+ </listitem>
1063
+ </varlistentry>
1064
+
1041
1065
<varlistentry id="libpq-connect-port" xreflabel="port">
1042
1066
<term><literal>port</literal></term>
1043
1067
<listitem>
@@ -1114,6 +1138,29 @@ postgresql://%2Fvar%2Flib%2Fpostgresql/dbname
1114
1138
</listitem>
1115
1139
</varlistentry>
1116
1140
1141
+ <varlistentry id="libpq-connect-falover-timeout" xreflabel="failover_timeout">
1142
+ <term><literal>failover_timeout</literal></term>
1143
+ <listitem>
1144
+ <para>
1145
+ Maximum time to cyclically retry all the hosts in the connection string.
1146
+ (as decimal integer number of seconds). If not specified, then
1147
+ hosts are tried just once.
1148
+ </para>
1149
+ <para>
1150
+ If we have replicating cluster, and master node fails, it might
1151
+ take some time to promote one of the standby nodes to the new master.
1152
+ So clients which detect failure to connect to the master might
1153
+ abandon attempts to reestablish a connection before the new master
1154
+ becomes available.
1155
+ </para>
1156
+ <para>
1157
+ Setting this parameter to a value that takes into account the amount of
1158
+ time needed for failover to complete will ensure attempts to connect
1159
+ to hosts continue to be made until the new master becomes available.
1160
+ </para>
1161
+ </listitem>
1162
+ </varlistentry>
1163
+
1117
1164
<varlistentry id="libpq-connect-client-encoding" xreflabel="client_encoding">
1118
1165
<term><literal>client_encoding</literal></term>
1119
1166
<listitem>
@@ -1498,13 +1545,14 @@ postgresql://%2Fvar%2Flib%2Fpostgresql/dbname
1498
1545
1499
1546
<varlistentry id="libpq-connect-target-session-attrs" xreflabel="target_session_attrs">
1500
1547
<term><literal>target_session_attrs</literal></term>
1548
+ <term><literal>target_server_type (synonym)</literal></term>
1501
1549
<listitem>
1502
1550
<para>
1503
- If this parameter is set to <literal>read-write</literal>, only a
1504
- connection in which read-write transactions are accepted by default
1505
- is considered acceptable. The query
1506
- <literal>SHOW transaction_read_only</literal> will be sent upon any
1507
- successful connection; if it returns <literal>on</>, the connection
1551
+ If this parameter is set to <literal>read-write</literal> (or its
1552
+ equivalent <literal>master</literal>, only a connection in which
1553
+ read-write transactions are accepted by default is considered acceptable.
1554
+ The query <literal>SHOW transaction_read_only</literal> will be sent upon
1555
+ any successful connection; if it returns <literal>on</>, the connection
1508
1556
will be closed. If multiple hosts were specified in the connection
1509
1557
string, any remaining servers will be tried just as if the connection
1510
1558
attempt had failed. The default value of this parameter,
0 commit comments