From: Mikko Tiihonen <Mikko.Tiihonen@nitorcreations.com>
To: pgsql-jdbc@postgresql.org <pgsql-jdbc@postgresql.org>
Subject: Pull request for better handling of master/slave and load balancing when connecting to multiple hosts
Date: Sat, 1 Nov 2014 00:34:19 +0000
Message-ID: <1414802059544.34620@nitorcreations.com> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-jdbc>
https://github.com/pgjdbc/pgjdbc/pull/209
It is a rewrite of the original request from 2011 by chenhj@cn.fujitsu.com.
If multiple hosts are specified in the jdbc connection url then:
* Adds optional querying of node writability and possibility to restrict connections to writable or read-only nodes.
* Adds optional load balancing of connections.
* Uses a JVM global cache of known node states.
By default the functionality stays the same compared to previous versions.
To run the unit tests one needs to configure a replication slave and configure slaveServer and slavePort properties in addition to the normal server and port.
I have a few questions about how to best detect the master/slave node:
1. Is the method show transaction_read_only = off still the best way on more modern postgresql to detect if we are connection to the master or slave?
2. Are there some other settings/functions that should be invoked to get better information about nodes to choose. Like how far behind the replica is from the master. We might not want to use slaves if they are too much behind.
-Mikko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: Mikko.Tiihonen@nitorcreations.com
Subject: Re: Pull request for better handling of master/slave and load balancing when connecting to multiple hosts
In-Reply-To: <1414802059544.34620@nitorcreations.com>
References: <1414802059544.34620@nitorcreations.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox