Re: BUG #16846: "retrieved too many tuples in a bounded sort"

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: contact@yorhel.nl
Cc: pgsql-bugs@lists.postgresql.org, Tomas Vondra <tomas.vondra@enterprisedb.com>
Date: 2021-01-31T16:16:08Z
Lists: pgsql-bugs
PG Bug reporting form <noreply@postgresql.org> writes:
> I have a query that fails as follows:

> SELECT id FROM releases WHERE minage = 18 AND released <= 20210131 AND id
> IN(SELECT id FROM releases_lang WHERE lang = 'ja') ORDER BY released DESC,
> id LIMIT 50; 
> ERROR:  XX000: retrieved too many tuples in a bounded sort
> LOCATION:  tuplesort_gettuple_common, tuplesort.c:2103

> Sadly I've not been able to create a minimum working example, but I have
> been able to reproduce this on our public database dumps. I've made an
> excerpt of the database with only the two referenced tables:
> https://s.vndb.org/u/vndb-releases-test-20210131.sql.gz (~5.5MB compressed).

I confirm this is reproducible on HEAD with the referenced test data.
(Load it into a utf8-encoding database, ANALYZE, and boom.)

I presume that the incremental-sort patch is at fault, though I've
not tried to run it to ground since I have no idea how that works.

			regards, tom lane



Commits

  1. Simplify loop logic in nodeIncrementalSort.c.

  2. Fix YA incremental sort bug.