pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Aleksander Alekseev <a.alekseev@postgrespro.ru>
To: Victor Wagner <vitus@wagner.pp.ru>
Cc: pgsql-hackers@postgresql.org
Subject: Re: Patch: Implement failover on libpq connect level.
Date: Wed, 7 Sep 2016 17:32:11 +0300
Message-ID: <20160907143211.GC20001@e733> (raw)
In-Reply-To: <20160907165634.5f8e9675@fafnir.local.vm>
References: <56E9E978.5090103@pgmasters.net>
	<CAD__OugniD9nz6weXCvnEELKX2iTK3xCmVWttVjLH0k5rn_NOA@mail.gmail.com>
	<CAD__Ouh53ttKfZ-439R9OGDOx=1xbBHS34SKOgTLqu73=gcp7Q@mail.gmail.com>
	<20160831111330.53a018ed@fafnir.local.vm>
	<CAD__OuimXSFUNCXXfcXXGEceuH8ik+Hr9qSYU0BidZw4gSxdig@mail.gmail.com>
	<CAD__Oui-3m6W83HyQNQLczrGRDQr4R67jv76DGwf1tT764zQ5A@mail.gmail.com>
	<CAD__OuhfOL-TQz-BBrFMj_tu8DqTc+ccxbwLkj+tUHAzvH14Pw@mail.gmail.com>
	<20160905072215.4efd7b8a@wagner.wagner.home>
	<20160905110311.GA11351@e733>
	<20160907165634.5f8e9675@fafnir.local.vm>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>

> > 8) get_next_element procedure implementation is way too smart (read
> > "complicated"). You could probably just store current list length and
> > generate a random number between 0 and length-1.
> 
> No, algorithm here is more complicated. It must ensure that there would
> not be second attempt to connect to host, for which unsuccessful
> connection attempt was done. So, there is list rearrangement.
> 
> Algorithm for pick random list element by single pass is quite trivial.

Great! In this case I would be _trivial_ for you to write a comment that
describes how this procedure works, what makes you think that it gives a
good distribution in all possible cases (e.g. if there is more than
0x10000 elements in a list - why not), etc. Right? :)

-- 
Best regards,
Aleksander Alekseev


-- 
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: <20160907143211.GC20001@e733>
Permalink:  ../20160907143211.GC20001@e733/
Also on:    postgresql.org/message-id/20160907143211.GC20001@e733

 · 

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: a.alekseev@postgrespro.ru, vitus@wagner.pp.ru, pgsql-hackers@postgresql.org
  Subject: Re: Patch: Implement failover on libpq connect level.
  In-Reply-To: <20160907143211.GC20001@e733>
  References: <56E9E978.5090103@pgmasters.net> <CAD__OugniD9nz6weXCvnEELKX2iTK3xCmVWttVjLH0k5rn_NOA@mail.gmail.com> <CAD__Ouh53ttKfZ-439R9OGDOx=1xbBHS34SKOgTLqu73=gcp7Q@mail.gmail.com> <20160831111330.53a018ed@fafnir.local.vm> <CAD__OuimXSFUNCXXfcXXGEceuH8ik+Hr9qSYU0BidZw4gSxdig@mail.gmail.com> <CAD__Oui-3m6W83HyQNQLczrGRDQr4R67jv76DGwf1tT764zQ5A@mail.gmail.com> <CAD__OuhfOL-TQz-BBrFMj_tu8DqTc+ccxbwLkj+tUHAzvH14Pw@mail.gmail.com> <20160905072215.4efd7b8a@wagner.wagner.home> <20160905110311.GA11351@e733> <20160907165634.5f8e9675@fafnir.local.vm> <20160907143211.GC20001@e733>

* 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