Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1ZSGCv-0003OH-K6 for pgsql-hackers@arkaria.postgresql.org; Thu, 20 Aug 2015 03:08:01 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1ZSGCv-00063v-1R for pgsql-hackers@arkaria.postgresql.org; Thu, 20 Aug 2015 03:08:01 +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_SHA384:256) (Exim 4.84) (envelope-from ) id 1ZSGBc-0004bv-AN for pgsql-hackers@postgresql.org; Thu, 20 Aug 2015 03:06:40 +0000 Received: from mail-wi0-x22f.google.com ([2a00:1450:400c:c05::22f]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84) (envelope-from ) id 1ZSGBW-000082-8H for pgsql-hackers@postgresql.org; Thu, 20 Aug 2015 03:06:39 +0000 Received: by wibhh20 with SMTP id hh20so24028810wib.0 for ; Wed, 19 Aug 2015 20:06:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=h7cDwSAVP/ykXcYKFsq0FwDplecRG4/5OwL+AJo3CsM=; b=EfpexPStC7aD6NgqOIOh0xKlUGTOsw38WxcArISzFLU+QGKe5zPwdUdPsmLb3yAhPg eooVfd+Wa3WS5V5+qn6qm3QFVgFn9rZcq0yQ7gtal31aFE/26Dp3yais9OwmnURYgcOi d/yGyk32okfT/jcsPYTNFR64X0aoVwtBN9H1W+kszs9xEJhsQ5kxMICPWRi1qU4v20BW 5FlWMegSRGeoSL48mjymn6XGPyJXemsQsKM0SCN7iumvG2GUEdGG2/x/spFzR76NDeVS /71W3rymf0e6Lzos7GIFlObQW0Xegaqeja3Bd5K7jBVnYZCpx91vQBlmm/feYxv4GtXr pDUQ== MIME-Version: 1.0 X-Received: by 10.180.108.210 with SMTP id hm18mr18219644wib.45.1440039991122; Wed, 19 Aug 2015 20:06:31 -0700 (PDT) Received: by 10.28.54.199 with HTTP; Wed, 19 Aug 2015 20:06:31 -0700 (PDT) In-Reply-To: <20150819075304.GF31302@wagner.pp.ru> References: <20150818041850.GA5092@wagner.pp.ru> <20150819070522.GB31302@wagner.pp.ru> <20150819075304.GF31302@wagner.pp.ru> Date: Thu, 20 Aug 2015 08:36:31 +0530 Message-ID: Subject: Re: Proposal: Implement failover on libpq connect level. From: Amit Kapila To: Victor Wagner Cc: pgsql-hackers Content-Type: multipart/alternative; boundary=e89a8f3bb065221f3b051db570ae X-Pg-Spam-Score: -2.4 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org --e89a8f3bb065221f3b051db570ae Content-Type: text/plain; charset=UTF-8 On Wed, Aug 19, 2015 at 1:23 PM, Victor Wagner wrote: > > On 2015.08.19 at 12:55:15 +0530, Amit Kapila wrote: > > > > I think that failover procedure should begin before first connection is > > > ever established. > > > > > > > As far as I understand, failover gets initiated once the master server goes > > down or is not accessible due to some reason, so for such cases if you > > have the connection to both the servers then it might not work. > > Master server might go down when client is not started yet. > And when client starts up, it has to find out which server to connect > now. > Always try with the first server specified in connection string and if that is not available try with second and so on. I think for the case of failover, the design shouldn't be much complicated and it is a standard thing provided by most of the client-side drivers in other databases. Considering what currently PostgreSQL offers in terms of high-availability functionality, for load-balancing, we need to be careful of many more things like redirecting read-queries to standby's, write statements should be executed via connection to master. With Regards, Amit Kapila. EnterpriseDB: http://www.enterprisedb.com --e89a8f3bb065221f3b051db570ae Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
On Wed, Aug 19, 2015 at 1:23 PM, Victor Wagner <vitus@wagner.pp.ru> wrote:
>> On 2015.08.19 at 12:55:15 +0530, Amit Kapila wrote:
>
> &= gt; > I think that failover procedure should begin before first connecti= on is
> > > ever established.
> > >
> >> > As far as I understand, failover gets initiated once the master = server goes
> > down or is not accessible due to some reason, so f= or such cases if you
> > have the connection to both the servers t= hen it might not work.
>
> Master server might go down when cli= ent is not started yet.
> And when client starts up, it has to find o= ut which server to connect
> now.
>

Always try with the first server specified in connection string and if t= hat
is not available try with second and so on.=C2=A0 = I think for the case of failover,
the design shouldn&#= 39;t be much complicated and it is a standard thing provided
by most of the client-side drivers in other databases.=C2=A0 Conside= ring what
currently PostgreSQL offers in terms of high= -availability functionality, for
load-balancing,=C2=A0= we need to be careful of many more things like redirecting
read-queries to=C2=A0standby's, write statements should be execut= ed via connection
to master. =C2=A0


With Regards,
Amit Kap= ila.
EnterpriseDB:=C2=A0http://www.enterprisedb.com
--e89a8f3bb065221f3b051db570ae--