Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gNiM3-0006Rr-KZ for pgsql-hackers@arkaria.postgresql.org; Fri, 16 Nov 2018 17:56:31 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gNiM0-0004OT-0A for pgsql-hackers@arkaria.postgresql.org; Fri, 16 Nov 2018 17:56:28 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gNiLz-0004OL-P6 for pgsql-hackers@lists.postgresql.org; Fri, 16 Nov 2018 17:56:27 +0000 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) by magus.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gNiLx-0006Lh-J4 for pgsql-hackers@postgresql.org; Fri, 16 Nov 2018 17:56:27 +0000 Received: from smtp1.mailbox.org (smtp1.mailbox.org [80.241.60.240]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by mx1.mailbox.org (Postfix) with ESMTPS id 3D84849369; Fri, 16 Nov 2018 18:56:20 +0100 (CET) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp1.mailbox.org ([80.241.60.240]) by spamfilter02.heinlein-hosting.de (spamfilter02.heinlein-hosting.de [80.241.56.116]) (amavisd-new, port 10030) with ESMTP id zqiY1lL_iPzO; Fri, 16 Nov 2018 18:56:19 +0100 (CET) Message-ID: <84d7a264fb5ad46873f6e40e10c3ee92983c55ca.camel@cybertec.at> Subject: Re: Libpq support to connect to standby server as priority From: Laurenz Albe To: Tom Lane Cc: Haribabu Kommi , Robert Haas , Jing Wang , Pg Hackers , "Tsunakawa, Takayuki" Date: Fri, 16 Nov 2018 18:56:11 +0100 In-Reply-To: <28777.1542386147@sss.pgh.pa.us> References: <1530710078.2411.29.camel@cybertec.at> <67be09458f276c0c95a4b2a2a383dca9775d19cd.camel@cybertec.at> <26890.1542047012@sss.pgh.pa.us> <096a642cff0dd68b8157a5f8838e1762d0050d18.camel@cybertec.at> <28777.1542386147@sss.pgh.pa.us> Organization: Cybertec Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Tom Lane wrote: > > As it is now, the patch doesn't keep two connections open. It remembers > > the index of the host of the first successful writable connection, but > > closes the connection, and opens another one to that host if no read-only > > host can be found. > > Oh! The reason I assumed it wasn't doing that is that such a behavior > seems completely insane. If the point is to keep down the load on your > master server, then connecting only to immediately disconnect is not > a friendly way to do that --- even without counting the fact that you > might later come back and connect again. That's why I had argued initially to keep the session open, but you seem to dislike that idea as well. > If that's the best we can do, we should forget the whole feature and > just recommend putting slave servers first in your hosts list when > you want prefer-slave. If you know which is which, certainly. But in a setup with automated failover you cannot be certain which is which. That's what the proposed feature targets. Yours, Laurenz Albe