Re: BUG #16784: Server crash in ExecReScanAgg()

From: Jeff Davis <pgsql(at)j-davis(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, exclusion(at)gmail(dot)com
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #16784: Server crash in ExecReScanAgg()
Date: 2020-12-27 01:50:53
Message-ID: d7e4ba887554732f83b8bfd9990ee6894d1d450a.camel@j-davis.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Thank you for the report, Alexander!

On Mon, 2020-12-21 at 14:26 -0500, Tom Lane wrote:
> /* there could be residual pergroup pointers; clear them */
> for (int setoff = 0;
> setoff < aggstate->maxsets + aggstate->num_hashes;
> setoff++)
> aggstate->all_pergroups[setoff] = NULL;
>
> I suspect this is clearing the wrong subset of the all_pergroups
> pointers, but the code is so underdocumented that I'm not very
> sure.

That's correct, but there was a (bad) reason it was done that way that
I had to fix first. A null pergroup was used as a signal not to advance
a group that has spilled, but that's only a good solution for the
hashed grouping sets, not the sorted grouping sets (which is what
caused this bug).

Instead, I solved it by simply not compiling the expressions for the
sorted grouping sets, so that agg_refill_hash_table() can leave those
pergroups alone.

Regards,
Jeff Davis

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Zhiyu ZY13 Xu 2020-12-27 11:18:57 could not fork new process and out of memory issues PG 11.5
Previous Message Tom Lane 2020-12-25 16:35:56 Re: BUG #16791: Compile error with new ICU 68.2 for 10.15