Re: Patch: Implement failover on libpq connect level. - Mailing list pgsql-hackers

From Victor Wagner
Subject Re: Patch: Implement failover on libpq connect level.
Date
Msg-id 20160121124909.7fa66dab@fafnir.local.vm
Whole thread Raw
In response to Re: Patch: Implement failover on libpq connect level.  (Thom Brown <thom@linux.com>)
List pgsql-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.








pgsql-hackers by date:

Previous
From: Kyotaro HORIGUCHI
Date:
Subject: Re: [PoC] Asynchronous execution again (which is not parallel)
Next
From: Etsuro Fujita
Date:
Subject: Re: Optimization for updating foreign tables in Postgres FDW