How to send queries to master and failover to slave ?

From: Benoit Salotti <benoit(dot)salotti(at)gmail(dot)com>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: How to send queries to master and failover to slave ?
Date: 2016-06-28 09:41:26
Message-ID: CAH9tKGn1QpazJjt6jxGfXO-tDMTYbrBUzxz4cZaESZt==6x_BQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Hi all,

I have a setup with 1 master and 1 slave (hot standy to serve read queries
if necessary).
I would like the JDBC driver to talk preferrably to the master (to be sure
to get the freshest data). If the master is not available I would like to
send the queries to the slave.

The documentation mentions the following values for the parameter
targetServerType: any, master, slave, preferSlave.
I'm surprised there is no preferMaster option which would allow me to
implement easily my requirement.

Anyone already encountered the same need ?

Regards,

Benoit

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Mikko Tiihonen 2016-06-28 10:09:37 Re: How to send queries to master and failover to slave ?
Previous Message Vladimir Sitnikov 2016-06-26 18:50:04 Re: PostgreSQL query timeout do not stop JDBC client attempt to read data from the server