Re: [sqlsmith] Crash in GetOldestSnapshot() - Mailing list pgsql-hackers

From Andrew Gierth
Subject Re: [sqlsmith] Crash in GetOldestSnapshot()
Date
Msg-id 87zioqcbbv.fsf@news-spur.riddles.org.uk
Whole thread Raw
In response to Re: [sqlsmith] Crash in GetOldestSnapshot()  (Amit Kapila <amit.kapila16@gmail.com>)
Responses Re: [sqlsmith] Crash in GetOldestSnapshot()  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: [sqlsmith] Crash in GetOldestSnapshot()  (Robert Haas <robertmhaas@gmail.com>)
List pgsql-hackers
>>>>> "Amit" == Amit Kapila <amit.kapila16@gmail.com> writes:
Amit> Sure, that is the reason of crash, but even if we do that it willAmit> lead to an error "no known snapshots".
Here,what is going on isAmit> that we initialized toast snapshot when there is no activeAmit> snapshot in the backend,
soGetOldestSnapshot() won't return anyAmit> snapshot.
 

Hmm.

So this happens because RETURNING queries run to completion immediately
and populate a tuplestore with the results, and the portal then fetches
from the tuplestore to send to the destination. The assumption is that
the tuplestore output can be processed without needing a snapshot, which
obviously is not true now if it contains toasted data.

In a similar case in the past involving holdable cursors, the solution
was to detoast _before_ storing in the tuplestore (see
PersistHoldablePortal). I guess the question now is, under what
circumstances is it now allowable to detoast a datum with no active
snapshot? (Wouldn't it be necessary in such a case to know what the
oldest snapshot ever used in the transaction was?)
Amit> I think for such situations, we need to initialize the lsn andAmit> whenTaken of ToastSnapshot as we do in
GetSnapshotData()[1].
 

Would that not give a too-recent LSN, resulting in possibly failing to
fetch the toast rows?

-- 
Andrew (irc:RhodiumToad)



pgsql-hackers by date:

Previous
From: Amit Kapila
Date:
Subject: Re: [sqlsmith] Crash in GetOldestSnapshot()
Next
From: Amit Kapila
Date:
Subject: Re: Parallel tuplesort (for parallel B-Tree index creation)