pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Fix bug #16784 in Disk-based Hash Aggregation.
5+ messages / 3 participants
[nested] [flat]

* pgsql: Fix bug #16784 in Disk-based Hash Aggregation.
@ 2020-12-27 01:53  Jeff Davis <jdavis@postgresql.org>
  0 siblings, 1 reply; 5+ messages in thread

From: Jeff Davis @ 2020-12-27 01:53 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix bug #16784 in Disk-based Hash Aggregation.

Before processing tuples, agg_refill_hash_table() was setting all
pergroup pointers to NULL to signal to advance_aggregates() that it
should not attempt to advance groups that had spilled.

The problem was that it also set the pergroups for sorted grouping
sets to NULL, which caused rescanning to fail.

Instead, change agg_refill_hash_table() to only set the pergroups for
hashed grouping sets to NULL; and when compiling the expression, pass
doSort=false.

Reported-by: Alexander Lakhin
Discussion: https://postgr.es/m/16784-7ff169bf2c3d1588%40postgresql.org
Backpatch-through: 13

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/05c0258966b502fae1bd63dcbe74d52f5c6f6948

Modified Files
--------------
src/backend/executor/nodeAgg.c             |  24 +++-
src/test/regress/expected/groupingsets.out | 207 +++++++++++++++++++++++++++++
src/test/regress/sql/groupingsets.sql      |  21 +++
3 files changed, 245 insertions(+), 7 deletions(-)



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* pgsql: Fix bug #16784 in Disk-based Hash Aggregation.
@ 2020-12-27 01:53  Jeff Davis <jdavis@postgresql.org>
  0 siblings, 0 replies; 5+ messages in thread

From: Jeff Davis @ 2020-12-27 01:53 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix bug #16784 in Disk-based Hash Aggregation.

Before processing tuples, agg_refill_hash_table() was setting all
pergroup pointers to NULL to signal to advance_aggregates() that it
should not attempt to advance groups that had spilled.

The problem was that it also set the pergroups for sorted grouping
sets to NULL, which caused rescanning to fail.

Instead, change agg_refill_hash_table() to only set the pergroups for
hashed grouping sets to NULL; and when compiling the expression, pass
doSort=false.

Reported-by: Alexander Lakhin
Discussion: https://postgr.es/m/16784-7ff169bf2c3d1588%40postgresql.org
Backpatch-through: 13

Branch
------
REL_13_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/7b8692eaf113a56933c77cf4c3993716ab37e763

Modified Files
--------------
src/backend/executor/nodeAgg.c             |  24 +++-
src/test/regress/expected/groupingsets.out | 207 +++++++++++++++++++++++++++++
src/test/regress/sql/groupingsets.sql      |  21 +++
3 files changed, 245 insertions(+), 7 deletions(-)



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: pgsql: Fix bug #16784 in Disk-based Hash Aggregation.
@ 2020-12-27 07:09  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Jeff Davis <jdavis@postgresql.org>
  0 siblings, 1 reply; 5+ messages in thread

From: Tom Lane @ 2020-12-27 07:09 UTC (permalink / raw)
  To: Jeff Davis <jdavis@postgresql.org>; +Cc: pgsql-committers@lists.postgresql.org

Jeff Davis <jdavis@postgresql.org> writes:
> Fix bug #16784 in Disk-based Hash Aggregation.

Buildfarm thinks this new test case is not completely stable.

It appears that only 32-bit machines are failing, and it's
not totally consistent even for them.  Dunno what to make of it.

			regards, tom lane





^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: pgsql: Fix bug #16784 in Disk-based Hash Aggregation.
@ 2020-12-27 17:59  Jeff Davis <pgsql@j-davis.com>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 5+ messages in thread

From: Jeff Davis @ 2020-12-27 17:59 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; Jeff Davis <jdavis@postgresql.org>; +Cc: pgsql-committers@lists.postgresql.org

On Sun, 2020-12-27 at 02:09 -0500, Tom Lane wrote:
> Jeff Davis <jdavis@postgresql.org> writes:
> > Fix bug #16784 in Disk-based Hash Aggregation.
> 
> Buildfarm thinks this new test case is not completely stable.
> 
> It appears that only 32-bit machines are failing, and it's
> not totally consistent even for them.  Dunno what to make of it.

I think I just need to disable sort. Because there is a () group, we
don't need a Sort in the plan to exercise the bug.

Committed to master. I'll backport if the tests stabilize. I'm on
vacation now and will return on the 5th, so hopefully we're in a
reasonable state until then. If not, I can just revert my fix and deal
with it when I get back.

Regards,
	Jeff Davis







^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: pgsql: Fix bug #16784 in Disk-based Hash Aggregation.
@ 2020-12-27 20:20  Jeff Davis <pgsql@j-davis.com>
  parent: Jeff Davis <pgsql@j-davis.com>
  0 siblings, 0 replies; 5+ messages in thread

From: Jeff Davis @ 2020-12-27 20:20 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; Jeff Davis <jdavis@postgresql.org>; +Cc: pgsql-committers@lists.postgresql.org

On Sun, 2020-12-27 at 09:59 -0800, Jeff Davis wrote:
> I think I just need to disable sort. Because there is a () group, we
> don't need a Sort in the plan to exercise the bug.

That still didn't stabilize the test, so I removed the EXPLAIN part of
the test and left the execution test in place.

The planning for grouping sets still uses work_mem in the knapsack
algorithm, so something about the other platforms is not considering
the plan with all hashes (except the () grouping set). I think we can
tune the test to be stable, but it doesn't seem critical so I think
we're fine just doing the execution-time test.

Regards,
	Jeff Davis







^ permalink  raw  reply  [nested|flat] 5+ messages in thread


end of thread, other threads:[~2020-12-27 20:20 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-12-27 01:53 pgsql: Fix bug #16784 in Disk-based Hash Aggregation. Jeff Davis <jdavis@postgresql.org>
2020-12-27 07:09 ` Tom Lane <tgl@sss.pgh.pa.us>
2020-12-27 17:59   ` Jeff Davis <pgsql@j-davis.com>
2020-12-27 20:20     ` Jeff Davis <pgsql@j-davis.com>
2020-12-27 01:53 pgsql: Fix bug #16784 in Disk-based Hash Aggregation. Jeff Davis <jdavis@postgresql.org>

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