Pull request for better handling of master/slave and load balancing when connecting to multiple hosts

From: Mikko Tiihonen <Mikko(dot)Tiihonen(at)nitorcreations(dot)com>
To: "pgsql-jdbc(at)postgresql(dot)org" <pgsql-jdbc(at)postgresql(dot)org>
Subject: Pull request for better handling of master/slave and load balancing when connecting to multiple hosts
Date: 2014-11-01 00:34:19
Message-ID: 1414802059544.34620@nitorcreations.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

https://github.com/pgjdbc/pgjdbc/pull/209

It is a rewrite of the original request from 2011 by chenhj(at)cn(dot)fujitsu(dot)com(dot)

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

Browse pgsql-jdbc by date

  From Date Subject
Next Message Mikko Tiihonen 2014-11-01 14:04:05 Pipelining executions to postgresql server
Previous Message Kevin Grittner 2014-10-31 16:13:59 Re: Hung thread