Re: BUG #14932: SELECT DISTINCT val FROM table gets stuck in an infinite loop

Andres Freund <andres@anarazel.de>

From: Andres Freund <andres@anarazel.de>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Tomas Vondra <tomas.vondra@2ndquadrant.com>, "Todd A. Cook" <tcook@blackducksoftware.com>, pgsql-bugs@postgresql.org
Date: 2018-01-26T23:47:41Z
Lists: pgsql-bugs
On 2018-01-26 18:22:26 -0500, Tom Lane wrote:
> In any case, we still need a fix for the behavior that the hash table size
> is blown out by lots of collisions, because that can happen no matter what
> the hash function is.  Andres seems to have dropped the ball on doing
> something about that.

Didn't have spare brain cycles :(, and the next backbranch release
wasn't yet close reducing immediate urgency a bit.  As written nearby I
think we should make execGrouping.c users of hashtables use a more
random IV, and apply something similar to the growth limit patch from
Tomas.

Greetings,

Andres Freund


Commits

  1. Improve bit perturbation in TupleHashTableHash.

  2. Prevent growth of simplehash tables when they're "too empty".

  3. Add stack-overflow guards in set-operation planning.