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

From: Benoit Salotti <benoit(dot)salotti(at)gmail(dot)com>
To: Mikko Tiihonen <mikko(dot)tiihonen(at)nitor(dot)fi>, pgsql-jdbc(at)postgresql(dot)org
Subject: Re: How to send queries to master and failover to slave ?
Date: 2016-06-28 13:48:35
Message-ID: CAH9tKG=wydcZhzX4qXrj1HVWd7E79dy88VOamEy9jJYC2bUH7A@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Hi Mikko,

I agree, everything works as expected but as long as the failover is not
done (about 1 minute with our settings, we are using repmgr) we are unable
to serve queries... I'd like the system to serve at least the reads in the
meantime :)

If the preferMaster feature can be done "easily" at the driver level I take
it.

Benoit

2016-06-28 12:09 GMT+02:00 Mikko Tiihonen <mikko(dot)tiihonen(at)nitor(dot)fi>:

> Assuming that the old slave will become new master if master ever goes
> down then the option "master" would do what you want. Right?
>
> But if you do take the master down for maintenance without failing over to
> slave then yes. A small code change could be done to add support for
> preferMaster.
>
>
> -Mikko
>
> ------------------------------
> *From:* pgsql-jdbc-owner(at)postgresql(dot)org <pgsql-jdbc-owner(at)postgresql(dot)org>
> on behalf of Benoit Salotti <benoit(dot)salotti(at)gmail(dot)com>
> *Sent:* 28 June 2016 12:41
> *To:* pgsql-jdbc(at)postgresql(dot)org
> *Subject:* [JDBC] 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 Benoit Salotti 2016-06-28 14:01:06 Re: How to send queries to master and failover to slave ?
Previous Message John R Pierce 2016-06-28 10:37:51 Re: How to send queries to master and failover to slave ?