Libpq support to connect to standby server as priority
Hi Hackers,
This is a proposal that let libpq support 'prefer-read' option in
target_session_attrs in pg_conn. The 'prefer-read' means the libpq will try
to connect to a 'read-only' server firstly from the multiple server
addresses. If failed to connect to the 'read-only' server then it will try
to connect to the 'read-write' server.
By providing this feature the application can have the opportunity to
connect to the standby server firstly if failed then connect to master
server without caring the sequence of the server addresses provided to the
libpq.
The 'read-only' server means Standby Server
The 'read-write' server means Master Server support to 'read-write'
--
Regards,
Jing Wang
Fujitsu Australia
From: Jing Wang [mailto:jingwangian@gmail.com]
This is a proposal that let libpq support 'prefer-read' option in
target_session_attrs in pg_conn. The 'prefer-read' means the libpq will
try to connect to a 'read-only' server firstly from the multiple server
addresses. If failed to connect to the 'read-only' server then it will try
to connect to the 'read-write' server.
There's a pending patch I started. I'd be happy if you could continue this.
https://commitfest.postgresql.org/15/1148/
Regards
Takayuki Tsunakawa
Hi,
Enclosed please find the patch that the libpq support 'prefer-read'
feature.
If the *target_session_attrs* is set to 'prefer-read', the patch will
connect to server and send 'SHOW transaction_read_only' query to check the
server being 'read-only' or not. If server is 'read-write' then it will try
next server address. If all connections for 'read-only' get failed it will
try to connect to the master server.
--
Regards,
Jing Wang
Fujitsu Australia
Hi Takayuki,
Thanks your reminder.
I will have a look your patch and the review comments and update the patch
soon.
Please leave my current submitted patch now.
--
Regards,
Jing Wang
Fujitsu Australia
2018-01-04 17:40 GMT+11:00 Tsunakawa, Takayuki <
tsunakawa.takay@jp.fujitsu.com>:
From: Jing Wang [mailto:jingwangian@gmail.com]
This is a proposal that let libpq support 'prefer-read' option in
target_session_attrs in pg_conn. The 'prefer-read' means the libpq will
try to connect to a 'read-only' server firstly from the multiple server
addresses. If failed to connect to the 'read-only' server then it willtry
to connect to the 'read-write' server.
There's a pending patch I started. I'd be happy if you could continue
this.https://commitfest.postgresql.org/15/1148/
Regards
Takayuki Tsunakawa
--
Kind regards
Jing