Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eMfTy-0002ZB-ID for pgsql-bugs@arkaria.postgresql.org; Wed, 06 Dec 2017 19:35:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eMfTy-0002VS-03 for pgsql-bugs@arkaria.postgresql.org; Wed, 06 Dec 2017 19:35:49 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eMfTx-0002VI-Nn for pgsql-bugs@lists.postgresql.org; Wed, 06 Dec 2017 19:35:49 +0000 Received: from out3-smtp.messagingengine.com ([66.111.4.27]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1eMfTv-0006I1-Gp for pgsql-bugs@postgresql.org; Wed, 06 Dec 2017 19:35:48 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 9781520937; Wed, 6 Dec 2017 14:35:46 -0500 (EST) Received: from frontend1 ([10.202.2.160]) by compute5.internal (MEProxy); Wed, 06 Dec 2017 14:35:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; bh=2It2JhUv/ve/7pXEywsk2hPb8vyxF fAdTR4nHTYJkb0=; b=p1NySWVRaMuTuvh/NbzmYyFisdmkIyVeasld0BK0/xUR4 X/5zJK4ziInDn7OEdUugF8s99VDitbQqQ4CA0PdkJxzrZw77ANgd/VsfI0b8F6Sa pXio2VUF81CPZidIQWSCPHqaPH9MaPBk/KTa02YUwDy+F/EAoj8E6lhp6TIto9GX kIshHmHC+BYE2mhXFq49KalFSDq5UZSxm7X5Ddw604yHIoQa63pi0tz1urbqPYpI JK+z6SOs5ErSHAIaVfz/zemKZxT6krj0Lud0VMuIKIO4Fv1IhXDf35/Uo9QIXQXV KdBXpUVCGlT+3pJYmgJLqM8FKmadDT4GZd5X6J43Q== X-ME-Sender: Received: from intern.anarazel.de (unknown [136.24.76.189]) by mail.messagingengine.com (Postfix) with ESMTPA id 336E27E26F; Wed, 6 Dec 2017 14:35:46 -0500 (EST) Date: Wed, 6 Dec 2017 11:35:45 -0800 From: Andres Freund To: Tomas Vondra Cc: "Todd A. Cook" , Tom Lane , Thomas Munro , PostgreSQL Bugs Subject: Re: BUG #14932: SELECT DISTINCT val FROM table gets stuck in an infinite loop Message-ID: <20171206193545.3imvbfwjgrmuho3s@alap3.anarazel.de> References: <20171127185700.1470.20362@wrigleys.postgresql.org> <7a22f496-92b5-d199-984e-183965918304@blackducksoftware.com> <20171127221041.mezzysc4zcfsqkyc@alap3.anarazel.de> <17357.1511841783@sss.pgh.pa.us> <9cd29b81-7ba1-91a2-f491-9014f4ac87e6@blackducksoftware.com> <2a76784c-06cb-46ec-35be-9895d144b839@2ndquadrant.com> <263b03b1-3e1c-49ca-165a-8ac6751419c4@2ndquadrant.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <263b03b1-3e1c-49ca-165a-8ac6751419c4@2ndquadrant.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2017-12-06 20:32:24 +0100, Tomas Vondra wrote: > On 12/05/2017 11:01 PM, Tomas Vondra wrote: > > > > Based on the initial discussion, the problem here is twofold. > > > > Firstly, the code assumes that if it gets certain number of bucket > > collisions (essentially, the initial bucket and certain number of > > neighboring buckets already being full), making the table larger is > > guaranteed to reduce the number of collisions. > > > > Which is obviously untrue for duplicate hash values, but it may also > > happen for distinct hash values that form a chain (think a sequence of > > hash values 1,2,3,4,5,6,7,...,K - that is never gonna get fixed). > I've managed to construct (by sheer brute force) an example that breaks > simplehash in this way. It triggers the growth by having a sequence of > distinct but consecutive hash values, e.g. 1, 2, 3, 4, ..., 1000, and > then trying to insert a value with duplicate hash (say, 4). I fail to be excited by this. That's possible for any sort of hashtable in some way. You might hit issues due to resizing or due to lookup performance, but you'll hit problem. That's a fairly fundamental issue of pure hashtables. Greetings, Andres Freund