pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andres Freund <andres@anarazel.de>
To: Kevin Grittner <kgrittn@gmail.com>
Cc: Robert Haas <robertmhaas@gmail.com>
Cc: Alvaro Herrera <alvherre@2ndquadrant.com>
Cc: Ants Aasma <ants.aasma@eesti.ee>
Cc: Amit Kapila <amit.kapila16@gmail.com>
Cc: Noah Misch <noah@leadboat.com>
Cc: Kevin Grittner <kgrittn@postgresql.org>
Cc: pgsql-hackers@postgresql.org <pgsql-hackers@postgresql.org>
Cc: pgsql-committers@postgresql.org <pgsql-committers@postgresql.org>
Subject: Re: Re: [COMMITTERS] pgsql: Avoid extra locks in GetSnapshotData if old_snapshot_threshold <
Date: Thu, 16 Jun 2016 11:40:39 -0700
Message-ID: <20160616184039.cevbwbtge6miafjs@alap3.anarazel.de> (raw)
In-Reply-To: <CACjxUsORAC-=gHFYct70D33Vua5-7Zu5KgFPN-Giz4xdnnC4bg@mail.gmail.com>
References: <20160615223440.omhksf4senwtfc6q@alap3.anarazel.de>
	<CACjxUsNN+Y5WyASrMS+=vL-Bk3QX-vHuYpM2jpS0K2iUp_qkig@mail.gmail.com>
	<20160616015730.rtozaq5mmlhci6xy@alap3.anarazel.de>
	<CACjxUsN6iCBrrNw7H5BJ7amJRx4AiUzjnpW=35FSuyZ1+Pgq1A@mail.gmail.com>
	<20160616153745.upxilwj3spbi43dj@alap3.anarazel.de>
	<CA+TgmobTQ=71y-c5P9VjWxOREVYWvkKd2ajQ5-J5HRkebdZ8DQ@mail.gmail.com>
	<20160616161426.bapgkbh762ktzyhk@alap3.anarazel.de>
	<CA+TgmoZBcUoYR4VmhLoeqdt8t1b80eOacbub4WHu1duqSy8ErA@mail.gmail.com>
	<20160616165440.pla4q3gbozyciuyo@alap3.anarazel.de>
	<CACjxUsORAC-=gHFYct70D33Vua5-7Zu5KgFPN-Giz4xdnnC4bg@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>

Hi,

On 2016-06-16 13:19:13 -0500, Kevin Grittner wrote:
> On Thu, Jun 16, 2016 at 11:54 AM, Andres Freund <andres@anarazel.de> wrote:
> > On 2016-06-16 12:43:34 -0400, Robert Haas 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.
> 
> I thought that we should never be using visibility information from
> the toast table; that the visibility information in the heap should
> control.

We use visibility information for vacuuming, toast vacuum puts toast
chunk tuples through HeapTupleSatisfiesVacuum(), just like for normal
tuples.  Otherwise we'd have to collect dead toast tuples during the
normal vacuum, and then do explicit vacuums for those. That'd end up
being pretty expensive.


> If that's the case, how would we prune toast rows without
> pruning the heap?

I'm not sure what you mean? We prune toast tuples by checking xmin/xmax,
and then comparing with OldestXmin. Without STO that's safe, because we
know nobody could lookup up those toast tuples.


> You pointed out that the *reverse* case has an
> option bit -- if that is ever set there could be toasted values
> which would not have a row.

We vacuum toast tables without the main table, by simply calling
vacuum() on the toast relation.  So you can get the case that only the
normal relation is vacuumed *or* that only the toast relation is vacuumed.


> Do they still have a line pointer in the heap, like "dead" index
> entries?

You can have non-pruned toast tuples, where any evidence of the
referencing main-heap tuple is gone.


> How are they cleaned up in current production versions?

There's simply no interlock except OldestXmin preveting referenced toast
tuples to be vacuumed, as long as any alive snapshot can read them.


Greetings,

Andres Freund


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers



view thread (195+ messages)  latest in thread

Message-ID: <20160616184039.cevbwbtge6miafjs@alap3.anarazel.de>
Permalink:  ../20160616184039.cevbwbtge6miafjs@alap3.anarazel.de/
Also on:    postgresql.org/message-id/20160616184039.cevbwbtge6miafjs@alap3.anarazel.de

 · 

reply

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-committers@postgresql.org
  Cc: andres@anarazel.de, kgrittn@gmail.com, robertmhaas@gmail.com, alvherre@2ndquadrant.com, ants.aasma@eesti.ee, amit.kapila16@gmail.com, noah@leadboat.com, kgrittn@postgresql.org, pgsql-hackers@postgresql.org
  Subject: Re: [COMMITTERS] pgsql: Avoid extra locks in GetSnapshotData if old_snapshot_threshold <
  In-Reply-To: <20160616184039.cevbwbtge6miafjs@alap3.anarazel.de>
  References: <20160615223440.omhksf4senwtfc6q@alap3.anarazel.de> <CACjxUsNN+Y5WyASrMS+=vL-Bk3QX-vHuYpM2jpS0K2iUp_qkig@mail.gmail.com> <20160616015730.rtozaq5mmlhci6xy@alap3.anarazel.de> <CACjxUsN6iCBrrNw7H5BJ7amJRx4AiUzjnpW=35FSuyZ1+Pgq1A@mail.gmail.com> <20160616153745.upxilwj3spbi43dj@alap3.anarazel.de> <CA+TgmobTQ=71y-c5P9VjWxOREVYWvkKd2ajQ5-J5HRkebdZ8DQ@mail.gmail.com> <20160616161426.bapgkbh762ktzyhk@alap3.anarazel.de> <CA+TgmoZBcUoYR4VmhLoeqdt8t1b80eOacbub4WHu1duqSy8ErA@mail.gmail.com> <20160616165440.pla4q3gbozyciuyo@alap3.anarazel.de> <CACjxUsORAC-=gHFYct70D33Vua5-7Zu5KgFPN-Giz4xdnnC4bg@mail.gmail.com> <20160616184039.cevbwbtge6miafjs@alap3.anarazel.de>

* 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