Re: ERROR: missing chunk number 0 for toast value

From: Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>
To: Andres Freund <andres(at)2ndquadrant(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Rushabh Lathia <rushabh(dot)lathia(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Rushabh Lathia <rushabh(dot)lathia(at)enterprisedb(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
Subject: Re: ERROR: missing chunk number 0 for toast value
Date: 2014-01-07 08:45:24
Message-ID: 52CBBEA4.7000107@vmware.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 01/06/2014 08:29 PM, Andres Freund wrote:
> On 2014-01-06 12:40:25 -0500, Robert Haas wrote:
>> On Mon, Jan 6, 2014 at 11:47 AM, Andres Freund <andres(at)2ndquadrant(dot)com> wrote:
>>> On 2014-01-06 11:08:41 -0500, Robert Haas wrote:
>>> Yea. But at least it would fail reliably instead of just under
>>> concurrency and other strange circumstances - and there'd be a safe way
>>> out. Currently there seem to be all sorts of odd behaviour possible.
>>>
>>> I simply don't have a better idea :(
>>
>> Is "forcibly detoast everything" a complete no-go? I realize there
>> are performance concerns with that approach, but I'm not sure how
>> realistic a worry it actually is.
>
> The scenario I am primarily worried about is turning a record assignment
> which previously took up to BLOCK_SIZE + slop amount of memory into
> something taking up to a gigabyte. That's a pretty damn hefty
> change.
> And there's no good way of preventing it short of using a variable for
> each actually desired column which imnsho isn't really a solution.

We could mitigate that somewhat by doing an optimization pass of the
PL/pgSQL code after compilation, and check which fields of a row
variable are never referenced, and skip the detoasting for those fields.
It would only work for named row variables, not anonymous record
variables, and you would still unnecessarily detoast fields that are
sometimes accessed but usually not. But it would avoid the detoasting in
the most egregious cases, e.g where you fetch a whole row into a
variable just to access one field.

Overall, I'm leaning towards biting the bullet and always detoasting
everything in master. Probably best to just leave the stable branches alone.

- Heikki

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2014-01-07 09:12:06 Re: In-core regression tests for replication, cascading, archiving, PITR, etc. Michael Paquier
Previous Message Michael Paquier 2014-01-07 08:37:52 Re: Fixing pg_basebackup with tablespaces found in $PGDATA