From: Tom Lane <tgl@sss.pgh.pa.us>
To: Andres Freund <andres@anarazel.de>
Cc: yi huang <yi.codeplayer@gmail.com>
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: PostgreSQL12 crash bug report
Date: Sat, 24 Aug 2019 12:13:22 -0400
Message-ID: <29185.1566663202@sss.pgh.pa.us> (raw)
In-Reply-To: <20190801043658.4hqm7k3iarmq3q7i@alap3.anarazel.de>
References: <CAHU7rYZo_C4ULsAx_LAj8az9zqgrD8WDd4hTegDTMM1LMqrBsg@mail.gmail.com>
<20811.1564344681@sss.pgh.pa.us>
<28807.1564614449@sss.pgh.pa.us>
<20190801004000.3xis75ulpun4ha3p@alap3.anarazel.de>
<5285.1564627060@sss.pgh.pa.us>
<20190801043658.4hqm7k3iarmq3q7i@alap3.anarazel.de>
Andres Freund <andres@anarazel.de> writes:
> On 2019-07-31 22:37:40 -0400, Tom Lane wrote:
>> Andres Freund <andres@anarazel.de> writes:
>>> Previously we simply didn't need to know the type during EPQ setup,
>>> because we only stored a HeapTuple anyway. And we'd know the appropriate
>>> tupledesc at the places that access the tuple.
>> Right. So we gotta refactor that somehow.
> One way to avoid doing so would be to just not deal with slots in the
> case of ROW_MARK_COPY. The reason why EPQ was made to use to use slots
> instead of HeapTuples is that not doing so would require expensive
> conversions for AMs that don't use HeapTuple. But for COPY rowmarks
> that's not an issue, because the source already is a HeapTuple (in the
> form of a Datum).
> That's imo not a particularly pretty approach, but might be the most
> viable approach for v12. Attached is a quick WIP implementation, which
> indeed fixes the crash reported here, and passes all our
> tests. Obviously it'd need some polish if we went for that.
I agree that that's mighty ugly. But it does have the advantage of being
not very invasive, so at this late date maybe it's what we should do
for v12.
>>> One bigger change - but possibly one worth it - would be to basically
>>> move the work done in EvalPlanQualFetchRowMarks() to be done on-demand,
>>> at least for ROW_MARK_COPY.
>> Hm. Too tired to think that through right now.
> I briefly tried to implement that. The problem is that, as things are
> currently set up, we don't have access to the corresponding epqstate
> from within executor nodes. That prevents us from accessing
> EPQState->{origslot, arowMarks}, which we need to actually be able to
> fetch the rows to return.
> We could solve that by referencing the EPQState from its EState (but not
> from the "main" estate). I've wondered before whether that'd be better
> than having various es_epq* fields in EState. I don't think it'd make
> the modularity any worse, given that we're already referencing EPQstate
> fields from with EState. If we moved es_epqTupleSlot into EPQState and
> allocated it from within EvalPlanQualInit(), instead of
> EvalPlanQualBegin(), we'd address your complaint that we now call that
> earlier too.
> Doesn't sound that hard. Seems like a big change for v12 though.
I feel that this seems like a promising solution for the longer term.
I agree that keeping a pointer to the whole EPQState in EState is no
worse than having pointers to some of its fields there.
Perhaps the next step is to draft a patch for this and see just how
big it is compared to the minimal fix. I'd rather not have v12 be
different from later branches in this area if the change doesn't
seem entirely unreasonable for late beta.
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, andres@anarazel.de, yi.codeplayer@gmail.com
Subject: Re: PostgreSQL12 crash bug report
In-Reply-To: <29185.1566663202@sss.pgh.pa.us>
References: <CAHU7rYZo_C4ULsAx_LAj8az9zqgrD8WDd4hTegDTMM1LMqrBsg@mail.gmail.com> <20811.1564344681@sss.pgh.pa.us> <28807.1564614449@sss.pgh.pa.us> <20190801004000.3xis75ulpun4ha3p@alap3.anarazel.de> <5285.1564627060@sss.pgh.pa.us> <20190801043658.4hqm7k3iarmq3q7i@alap3.anarazel.de> <29185.1566663202@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