pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Victor Wagner <vitus@wagner.pp.ru>
To: pgsql-hackers@postgresql.org
Subject: Re: Patch: Implement failover on libpq connect level.
Date: Thu, 21 Jan 2016 12:49:09 +0300
Message-ID: <20160121124909.7fa66dab@fafnir.local.vm> (raw)
In-Reply-To: <CAA-aLv4ddFHXA0BHZz-dLXJJNVfhj8JURDm77izZCO8UaM1oVg@mail.gmail.com>
References: <20150818041850.GA5092@wagner.pp.ru>
	<20151014104151.GA6744@wagner.pp.ru>
	<562E8C55.9030409@gmx.net>
	<20151028111839.6e73c68a@fafnir>
	<56327381.5040108@gmx.net>
	<CA+TgmoY8J2Jp1fM4EmtU6=3hHLpHc9+qyOJW3OgCNRN6QTgyDg@mail.gmail.com>
	<56379A44.9080609@gmx.net>
	<20151105151235.GA21434@wagner.pp.ru>
	<CA+TgmoYKvGsZGJB-cKU=xhHnq=b6XOM=qbseVC72HwH2+p5+TA@mail.gmail.com>
	<CAMsr+YGXTK3+i5zL3AkkR5BRP+Tw+f4+Ph=Z2_g7KD-nbb+cYg@mail.gmail.com>
	<20151106153807.GA6104@alvherre.pgsql>
	<CA+TgmoYYUeojjos=7ZT6Emkmri1f4n753tx9v7jEU-y28_8zOw@mail.gmail.com>
	<CAMsr+YHr740oGcVQcuyvLt1bwBPLQtpm5U-O+tTEFifBgHWdzw@mail.gmail.com>
	<20151109124404.1af6ba0c@fafnir>
	<5665EB79.9070805@enterprisedb.com>
	<20151210075419.6c9b7ca4@wagnner.wagner.home>
	<56780A3D.2090609@sigaev.ru>
	<20151221175013.644535cd@fafnir.local.vm>
	<CAA-aLv4ddFHXA0BHZz-dLXJJNVfhj8JURDm77izZCO8UaM1oVg@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>

On Tue, 19 Jan 2016 14:34:54 +0000
Thom Brown <thom@linux.com> wrote:

> The segfault issue I originally reported now appears to be resolved.
> 
> But now I have another one:
> 
> psql
> 'postgresql://thom@127.0.0.1:5530,127.0.0.1:5531,127.0.0.1:5532,127.0.0.1:5533/postgres?hostorder=random&readonly=1&failover_timeout=5'
> -c 'show port'
> 
> Segmentation fault

This segfault appears to be a simple programming error. 
which comes out only when  we need to retry address list (which happens
when no node is available at the time of first scan)

There is code which prevents random hostorder to connect same node
twice a row

        while (current != NULL)
        {
            if (current == conn->addr_cur)
            {
                current = current->ai_next;
            }
            count++;
            if ((rand()&0xffff) < 0x10000 / count)
            {
                choice = current;
            }
            current = current->ai_next;
        }


There should be continue;  after first current = current->ai_next;
 
> This is where no nodes are available.  If I remove hostorder=random,
> or replace it with hostorder=sequential, it doesn't segfault.
> However, it then tries to connect to PGHOST on PGPORT repeatedly, even
> if I bring up one of the nodes it should be looking for.  Not only
> this, but it seems to do it forever if failover_timeout is greater
> than 0.

But this turns out to be more complicated matter, so I'm not ready to
provide next version of patch yet.







-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers



view thread (165+ messages)  latest in thread

Message-ID: <20160121124909.7fa66dab@fafnir.local.vm>
Permalink:  ../20160121124909.7fa66dab@fafnir.local.vm/
Also on:    postgresql.org/message-id/20160121124909.7fa66dab@fafnir.local.vm

 · 

reply

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: vitus@wagner.pp.ru, pgsql-hackers@postgresql.org
  Subject: Re: Patch: Implement failover on libpq connect level.
  In-Reply-To: <20160121124909.7fa66dab@fafnir.local.vm>
  References: <20150818041850.GA5092@wagner.pp.ru> <20151014104151.GA6744@wagner.pp.ru> <562E8C55.9030409@gmx.net> <20151028111839.6e73c68a@fafnir> <56327381.5040108@gmx.net> <CA+TgmoY8J2Jp1fM4EmtU6=3hHLpHc9+qyOJW3OgCNRN6QTgyDg@mail.gmail.com> <56379A44.9080609@gmx.net> <20151105151235.GA21434@wagner.pp.ru> <CA+TgmoYKvGsZGJB-cKU=xhHnq=b6XOM=qbseVC72HwH2+p5+TA@mail.gmail.com> <CAMsr+YGXTK3+i5zL3AkkR5BRP+Tw+f4+Ph=Z2_g7KD-nbb+cYg@mail.gmail.com> <20151106153807.GA6104@alvherre.pgsql> <CA+TgmoYYUeojjos=7ZT6Emkmri1f4n753tx9v7jEU-y28_8zOw@mail.gmail.com> <CAMsr+YHr740oGcVQcuyvLt1bwBPLQtpm5U-O+tTEFifBgHWdzw@mail.gmail.com> <20151109124404.1af6ba0c@fafnir> <5665EB79.9070805@enterprisedb.com> <20151210075419.6c9b7ca4@wagnner.wagner.home> <56780A3D.2090609@sigaev.ru> <20151221175013.644535cd@fafnir.local.vm> <CAA-aLv4ddFHXA0BHZz-dLXJJNVfhj8JURDm77izZCO8UaM1oVg@mail.gmail.com> <20160121124909.7fa66dab@fafnir.local.vm>

* 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