From: Tom Lane <tgl@sss.pgh.pa.us>
To: 赵庭海(庭章) <zhaotinghai.zth@alibaba-inc.com>
Cc: pgsql-hackers <pgsql-hackers@lists.postgresql.org>
Cc: Jeff Davis <pgsql@j-davis.com>
Cc: Heikki Linnakangas <hlinnaka@iki.fi>
Subject: Re: sublink [exists (select xxx group by grouping sets ())] causes an assertion error
Date: Fri, 22 Mar 2024 12:28:40 -0400
Message-ID: <932664.1711124920@sss.pgh.pa.us> (raw)
In-Reply-To: <cfd84cb8-12fe-433a-a4bb-f460a4515f9c.zhaotinghai.zth@alibaba-inc.com>
References: <cfd84cb8-12fe-433a-a4bb-f460a4515f9c.zhaotinghai.zth@alibaba-inc.com>
"=?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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: tgl@sss.pgh.pa.us, zhaotinghai.zth@alibaba-inc.com, pgsql-hackers@lists.postgresql.org, pgsql@j-davis.com, hlinnaka@iki.fi
Subject: Re: sublink [exists (select xxx group by grouping sets ())] causes an assertion error
In-Reply-To: <932664.1711124920@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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