Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bHqP8-0002m2-IE for pgsql-jdbc@arkaria.postgresql.org; Tue, 28 Jun 2016 10:38:06 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bHqP7-0007Uo-DU for pgsql-jdbc@arkaria.postgresql.org; Tue, 28 Jun 2016 10:38:05 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bHqP6-0007Ud-QD for pgsql-jdbc@postgresql.org; Tue, 28 Jun 2016 10:38:04 +0000 Received: from hogranch.com ([75.101.82.47]) by makus.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bHqP4-0000M2-7W for pgsql-jdbc@postgresql.org; Tue, 28 Jun 2016 10:38:03 +0000 Received: from [192.168.0.2] (porker [192.168.0.2]) by hogranch.com (8.11.6/8.11.6) with ESMTP id u5SAbuv21929 for ; Tue, 28 Jun 2016 03:37:56 -0700 Subject: Re: How to send queries to master and failover to slave ? To: pgsql-jdbc@postgresql.org References: From: John R Pierce Message-ID: <4ae74d8b-2a0e-68fc-93ce-ccbf2abd1744@hogranch.com> Date: Tue, 28 Jun 2016 03:37:51 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.1.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-HawgScanner-Information: Please contact the ISP for more information X-HawgScanner: Found to be clean X-Pg-Spam-Score: -3.2 (---) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-jdbc Precedence: bulk Sender: pgsql-jdbc-owner@postgresql.org On 6/28/2016 2:41 AM, Benoit Salotti wrote: > > 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. > normally, if the master is not available, that means its failed, and your HA cluster management will promote the slave to be the new master, fencing off the old master until it can be manually reset and restored as the new slave. -- john r pierce, recycling bits in santa cruz -- Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-jdbc