Re: sublink [exists (select xxx group by grouping sets ())] causes an assertion error

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: 赵庭海(庭章) <zhaotinghai(dot)zth(at)alibaba-inc(dot)com>
Cc: "pgsql-hackers" <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Jeff Davis <pgsql(at)j-davis(dot)com>, Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
Subject: Re: sublink [exists (select xxx group by grouping sets ())] causes an assertion error
Date: 2024-03-22 16:28:40
Message-ID: 932664.1711124920@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

"=?UTF-8?B?6LW15bqt5rW3KOW6reeroCk=?=" <zhaotinghai(dot)zth(at)alibaba-inc(dot)com> writes:
> I recently notice these sql can lead to a assertion error in pg14 and older version. Here is an example:
> postgres=> CREATE TABLE t1 (a int);
> postgres=> INSERT INTO t1 VALUES (1);
> postgres=> SELECT EXISTS ( SELECT * FROM t1 GROUP BY GROUPING SETS ((a), generate_series (1, 262144)) ) AS result;
> server closed the connection unexpectedly

In current v14 this produces:
TRAP: FailedAssertion("!lt->writing || lt->buffer == NULL", File: "logtape.c", Line: 1279, PID: 928622)

Thanks for the report. I did some bisecting and found that the crash
appears at Jeff's commit c8aeaf3ab (which introduced this assertion)
and disappears at Heikki's c4649cce3 (which removed it). So I would
say that the problem is "this assertion is wrong", and we should fix
the problem by fixing the assertion, not by hacking around in distant
calling code. On the whole, since this code has been dead for
several versions, I'd be inclined to just remove the assertion.
I think it's quite risky because of the possibility that we reach
this function during post-transaction-abort cleanup, when there's
no very good reason to assume that the tapeset's been closed down
cleanly. (To be clear, that's not what's happening in the given
test case ... but I fear that it could.)

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2024-03-22 16:32:40 Re: documentation structure
Previous Message Tom Lane 2024-03-22 15:51:00 Re: [PATCH] plpython function causes server panic