Re: sublink [exists (select xxx group by grouping sets ())] causes an assertion error
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: 赵庭海(庭章) <zhaotinghai.zth@alibaba-inc.com>
Cc: "pgsql-hackers" <pgsql-hackers@lists.postgresql.org>,
Jeff Davis <pgsql@j-davis.com>, Heikki Linnakangas <hlinnaka@iki.fi>
Date: 2024-03-22T16:28:40Z
Lists: pgsql-hackers
"=?UTF-8?B?6LW15bqt5rW3KOW6reeroCk=?=" <zhaotinghai.zth@alibaba-inc.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
Commits
-
Clarify comment for LogicalTapeSetBlocks().
- abcea19abf3b 13.15 landed
- 24d1b9989134 14.12 landed
- b74e4a08b983 15.7 landed
- 022068ea2c60 16.3 landed
- bc5fcaa289a9 17.0 landed
-
Remove incorrect Assert introduced in c8aeaf3ab.
- bf038eb219bb 13.15 landed
- a1a51dc4fab7 14.12 landed
-
Change LogicalTapeSetBlocks() to use nBlocksWritten.
- c8aeaf3ab31e 14.0 cited