On 2016-06-16 13:44:34 -0400, Robert Haas wrote: > On Thu, Jun 16, 2016 at 12:54 PM, Andres Freund <and...@anarazel.de> wrote: > >> The root of my confusion is: if we prune a tuple, we'll bump the page > >> LSN, so any session that is still referencing that tuple will error > >> out as soon as it touches the page on which that tuple used to exist. > > > > Right. On the main table. But we don't peform that check on the toast > > table/pages. So if we prune toast tuples, which are still referenced by > > (unvacuumed) main relation, we can get into trouble. > > OK, if it's true that we don't perform that check on the TOAST table, > then I agree there's a potential problem there. I don't immediately > know where in the code to look to check that.
static inline void TestForOldSnapshot(Snapshot snapshot, Relation relation, Page page) { Assert(relation != NULL); if (old_snapshot_threshold >= 0 && (snapshot) != NULL && (snapshot)->satisfies == HeapTupleSatisfiesMVCC && !XLogRecPtrIsInvalid((snapshot)->lsn) && PageGetLSN(page) > (snapshot)->lsn) TestForOldSnapshot_impl(snapshot, relation); } The relevant part is the HeapTupleSatisfiesMVCC check, we're using SatisfiesToast for toast lookups. FWIW, I just tried to reproduce this with old_snapshot_threshold = 0 - but ran into the problem that I couldn't get it to vacuum anything away (neither main nor toast rel). That appears to be if (old_snapshot_threshold == 0) { if (TransactionIdPrecedes(latest_xmin, MyPgXact->xmin) && TransactionIdFollows(latest_xmin, xlimit)) xlimit = latest_xmin; because latest_xmin always is equal to MyPgXact->xmin, which is actually kinda unsurprising? Regards, Andres -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers