Thread: pgsql: Prevent "snapshot too old" from trying to return pruned TOAST tu

pgsql: Prevent "snapshot too old" from trying to return pruned TOAST tu

From
Robert Haas
Date:
Prevent "snapshot too old" from trying to return pruned TOAST tuples.

Previously, we tested for MVCC snapshots to see whether they were too
old, but not TOAST snapshots, which can lead to complaints about missing
TOAST chunks if those chunks are subject to early pruning.  Ideally,
the threshold lsn and timestamp for a TOAST snapshot would be that of
the corresponding MVCC snapshot, but since we have no way of deciding
which MVCC snapshot was used to fetch the TOAST pointer, use the oldest
active or registered snapshot instead.

Reported by Andres Freund, who also sketched out what the fix should
look like.  Patch by me, reviewed by Amit Kapila.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/3e2f3c2e423b3ae906668c186bac79522b8e3e29

Modified Files
--------------
src/backend/access/heap/tuptoaster.c | 37 +++++++++++++++++++++++++++++++----
src/backend/utils/time/snapmgr.c     | 38 ++++++++++++++++++++++++++++++++++++
src/backend/utils/time/tqual.c       |  1 -
src/include/storage/bufmgr.h         |  3 ++-
src/include/utils/snapmgr.h          |  1 +
src/include/utils/tqual.h            | 32 ++++++++++++++++++++----------
6 files changed, 96 insertions(+), 16 deletions(-)


Robert Haas <rhaas@postgresql.org> writes:
> Prevent "snapshot too old" from trying to return pruned TOAST tuples.

Looks like this patch broke the build on castoroides.  Recommend
changing InitToastSnapshot into a macro.  (There's a reason why
InitDirtySnapshot is a macro.)

            regards, tom lane


Re: pgsql: Prevent "snapshot too old" from trying to return pruned TOAST tu

From
Robert Haas
Date:
On Thu, Aug 4, 2016 at 7:23 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Robert Haas <rhaas@postgresql.org> writes:
>> Prevent "snapshot too old" from trying to return pruned TOAST tuples.
>
> Looks like this patch broke the build on castoroides.  Recommend
> changing InitToastSnapshot into a macro.  (There's a reason why
> InitDirtySnapshot is a macro.)

What is the reason?  We refuse to separate frontend and backend
headers in any sort of principled way?

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company