RE: How to send queries to master and failover to slave ?

From: Švorc Martin <svorc(at)sefira(dot)cz>
To: Dave Cramer <pg(at)fastcrypt(dot)com>
Cc: "pgsql-jdbc(at)postgresql(dot)org" <pgsql-jdbc(at)postgresql(dot)org>
Subject: RE: How to send queries to master and failover to slave ?
Date: 2019-03-01 10:16:39
Message-ID: VI1PR05MB5295BA974B84191217A6A613BC760@VI1PR05MB5295.eurprd05.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Okay thanks, I have opened a pull request for the feature: #1430

Martin

From: Dave Cramer [mailto:pg(at)fastcrypt(dot)com]
Sent: Thursday, February 28, 2019 1:24 PM
To: Švorc Martin
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: How to send queries to master and failover to slave ?

If you have a use case for it then I think it's a good idea

Dave Cramer

davec(at)postgresintl(dot)com<mailto:davec(at)postgresintl(dot)com>
www.postgresintl.com<http://www.postgresintl.com>

On Thu, 28 Feb 2019 at 07:01, Švorc Martin <svorc(at)sefira(dot)cz<mailto:svorc(at)sefira(dot)cz>> wrote:
Hello,

We have the very same scenario as Benoit describes – if the master instance fails, we would like the driver to communicate with the secondary instance for read-only operations before the failover process is commenced. The second use-case is when the master instance is deliberately shut down for maintenance reasons and we do not want to fail over to the secondary instance, but instead allow it to process user queries throughout the maintenance.

For this, we intend to implement "preferMaster" targetServerType in the JDBC driver paramater. Would you consider it a good idea to integrate this feature into the official JDBC driver?

Cheers

Martin

From: pgsql-jdbc-owner(at)postgresql(dot)org<mailto:pgsql-jdbc-owner(at)postgresql(dot)org> [mailto:pgsql-jdbc-owner(at)postgresql(dot)org<mailto:pgsql-jdbc-owner(at)postgresql(dot)org>] On Behalf Of Benoit Salotti
Sent: Tuesday, June 28, 2016 11:41 AM
To: pgsql-jdbc(at)postgresql(dot)org<mailto:pgsql-jdbc(at)postgresql(dot)org>
Subject: How to send queries to master and failover to slave ?

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

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Atul Deopujari 2019-03-04 13:09:11 High memory retention by QueryExecutorImpl.pgStream.encoding.decoderArray
Previous Message Dave Cramer 2019-02-28 12:23:50 Re: How to send queries to master and failover to slave ?