Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bhdwV-00056x-Ut for pgsql-hackers@arkaria.postgresql.org; Wed, 07 Sep 2016 14:35:12 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bhdwV-00010X-HM for pgsql-hackers@arkaria.postgresql.org; Wed, 07 Sep 2016 14:35:11 +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_2) (envelope-from ) id 1bhdv6-0006oU-Ee for pgsql-hackers@postgresql.org; Wed, 07 Sep 2016 14:33:44 +0000 Received: from newmail.postgrespro.ru ([93.174.131.138] helo=mail.postgrespro.ru) by magus.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bhdv3-00028t-FG for pgsql-hackers@postgresql.org; Wed, 07 Sep 2016 14:33:43 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.postgrespro.ru (Postfix) with ESMTP id BD3CF21C28EE; Wed, 7 Sep 2016 17:33:39 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at postgrespro.ru Received: from mail.postgrespro.ru ([127.0.0.1]) by localhost (mail.postgrespro.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 6oorS54Mea3M; Wed, 7 Sep 2016 17:33:39 +0300 (MSK) Received: from localhost (unknown [192.168.27.1]) by mail.postgrespro.ru (Postfix) with ESMTPSA id 73F0E21C28E6; Wed, 7 Sep 2016 17:33:39 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1473258819; bh=ekNG2p/+yvG6H8seYjDy2iwr6u6EYonZIOD8LpDE5iU=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=YjJrMQLz+gPy8pAPplJkQ8f4N/37gLGYhwOOVNSCrHjPms96TM1a9TYmerFnMOJum oEt6o21eQ2YBPIlg3NkZqEs5a3ZyvyEKzRcvWSWh9rqP0k3bPHFHq6+Pfp06K+6rMs 6HiXetdGglhGsnDqNcsO7bqDer036gVFr65gdkWo= Date: Wed, 7 Sep 2016 17:32:11 +0300 From: Aleksander Alekseev To: Victor Wagner Cc: pgsql-hackers@postgresql.org Subject: Re: Patch: Implement failover on libpq connect level. Message-ID: <20160907143211.GC20001@e733> References: <56E9E978.5090103@pgmasters.net> <20160831111330.53a018ed@fafnir.local.vm> <20160905072215.4efd7b8a@wagner.wagner.home> <20160905110311.GA11351@e733> <20160907165634.5f8e9675@fafnir.local.vm> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160907165634.5f8e9675@fafnir.local.vm> User-Agent: Mutt/1.6.1 (2016-04-27) X-Pg-Spam-Score: -3.1 (---) 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 > > 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