pg.ddx.io pgsql-committers@postgresql.org mailing list archive
help / color / mirror / Atom feedpgsql: Prevent "snapshot too old" from trying to return pruned TOAST tu
6+ messages / 3 participants
[nested] [flat]
* pgsql: Prevent "snapshot too old" from trying to return pruned TOAST tu
@ 2016-08-03 20:52 Robert Haas <rhaas@postgresql.org>
2016-08-04 23:23 ` Re: pgsql: Prevent "snapshot too old" from trying to return pruned TOAST tu Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 6+ messages in thread
From: Robert Haas @ 2016-08-03 20:52 UTC (permalink / raw)
To: pgsql-committers
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(-)
--
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: pgsql: Prevent "snapshot too old" from trying to return pruned TOAST tu
2016-08-03 20:52 pgsql: Prevent "snapshot too old" from trying to return pruned TOAST tu Robert Haas <rhaas@postgresql.org>
@ 2016-08-04 23:23 ` Tom Lane <tgl@sss.pgh.pa.us>
2016-08-05 02:58 ` Re: pgsql: Prevent "snapshot too old" from trying to return pruned TOAST tu Robert Haas <robertmhaas@gmail.com>
0 siblings, 1 reply; 6+ messages in thread
From: Tom Lane @ 2016-08-04 23:23 UTC (permalink / raw)
To: Robert Haas <rhaas@postgresql.org>; +Cc: pgsql-committers
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
--
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: pgsql: Prevent "snapshot too old" from trying to return pruned TOAST tu
2016-08-03 20:52 pgsql: Prevent "snapshot too old" from trying to return pruned TOAST tu Robert Haas <rhaas@postgresql.org>
2016-08-04 23:23 ` Re: pgsql: Prevent "snapshot too old" from trying to return pruned TOAST tu Tom Lane <tgl@sss.pgh.pa.us>
@ 2016-08-05 02:58 ` Robert Haas <robertmhaas@gmail.com>
2016-08-05 03:59 ` Re: [COMMITTERS] pgsql: Prevent "snapshot too old" from trying to return pruned TOAST tu Robert Haas <robertmhaas@gmail.com>
0 siblings, 1 reply; 6+ messages in thread
From: Robert Haas @ 2016-08-05 02:58 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-committers
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
--
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: [COMMITTERS] pgsql: Prevent "snapshot too old" from trying to return pruned TOAST tu
2016-08-03 20:52 pgsql: Prevent "snapshot too old" from trying to return pruned TOAST tu Robert Haas <rhaas@postgresql.org>
2016-08-04 23:23 ` Re: pgsql: Prevent "snapshot too old" from trying to return pruned TOAST tu Tom Lane <tgl@sss.pgh.pa.us>
2016-08-05 02:58 ` Re: pgsql: Prevent "snapshot too old" from trying to return pruned TOAST tu Robert Haas <robertmhaas@gmail.com>
@ 2016-08-05 03:59 ` Robert Haas <robertmhaas@gmail.com>
2016-08-05 15:05 ` Re: Re: [COMMITTERS] pgsql: Prevent "snapshot too old" from trying to return pruned TOAST tu Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 6+ messages in thread
From: Robert Haas @ 2016-08-05 03:59 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-hackers@postgresql.org <pgsql-hackers@postgresql.org>
On Thu, Aug 4, 2016 at 10:58 PM, Robert Haas <robertmhaas@gmail.com> wrote:
> 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?
That was poorly phrased. I'll try again: I can't see any reason for
using a macro here except that it allows frontend code to compile this
without breaking. But that doesn't seem like a very good way of
solving that problem. There's surely no way for a casual reader of
the code to realize that macros can be used here and inline functions
cannot, especially because this works apparently works fine on most
machines, including mine.
Here's a patch. Is this what you want?
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
Attachments:
init-toast-snapshot-macro-v1.patch (text/x-patch, 1.3K) download
diff --git a/src/backend/access/heap/tuptoaster.c b/src/backend/access/heap/tuptoaster.c
index 55b6b41..31b0132 100644
--- a/src/backend/access/heap/tuptoaster.c
+++ b/src/backend/access/heap/tuptoaster.c
@@ -2316,5 +2316,5 @@ init_toast_snapshot(Snapshot toast_snapshot)
if (snapshot == NULL)
elog(ERROR, "no known snapshots");
- InitToastSnapshot(toast_snapshot, snapshot->lsn, snapshot->whenTaken);
+ InitToastSnapshot(*toast_snapshot, snapshot->lsn, snapshot->whenTaken);
}
diff --git a/src/include/utils/tqual.h b/src/include/utils/tqual.h
index 8041e7b..fc7328c 100644
--- a/src/include/utils/tqual.h
+++ b/src/include/utils/tqual.h
@@ -104,12 +104,9 @@ extern bool ResolveCminCmaxDuringDecoding(struct HTAB *tuplecid_data,
* Similarly, some initialization is required for SnapshotToast. We need
* to set lsn and whenTaken correctly to support snapshot_too_old.
*/
-static inline void
-InitToastSnapshot(Snapshot snapshot, XLogRecPtr lsn, int64 whenTaken)
-{
- snapshot->satisfies = HeapTupleSatisfiesToast;
- snapshot->lsn = lsn;
- snapshot->whenTaken = whenTaken;
-}
+#define InitToastSnapshot(snapshotdata, l, w) \
+ ((snapshotdata).satisfies = HeapTupleSatisfiesDirty, \
+ (snapshotdata).lsn = (l), \
+ (snapshotdata).whenTaken = (w))
#endif /* TQUAL_H */
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Re: [COMMITTERS] pgsql: Prevent "snapshot too old" from trying to return pruned TOAST tu
2016-08-03 20:52 pgsql: Prevent "snapshot too old" from trying to return pruned TOAST tu Robert Haas <rhaas@postgresql.org>
2016-08-04 23:23 ` Re: pgsql: Prevent "snapshot too old" from trying to return pruned TOAST tu Tom Lane <tgl@sss.pgh.pa.us>
2016-08-05 02:58 ` Re: pgsql: Prevent "snapshot too old" from trying to return pruned TOAST tu Robert Haas <robertmhaas@gmail.com>
2016-08-05 03:59 ` Re: [COMMITTERS] pgsql: Prevent "snapshot too old" from trying to return pruned TOAST tu Robert Haas <robertmhaas@gmail.com>
@ 2016-08-05 15:05 ` Tom Lane <tgl@sss.pgh.pa.us>
2016-08-05 16:04 ` Re: Re: [COMMITTERS] pgsql: Prevent "snapshot too old" from trying to return pruned TOAST tu Robert Haas <robertmhaas@gmail.com>
0 siblings, 1 reply; 6+ messages in thread
From: Tom Lane @ 2016-08-05 15:05 UTC (permalink / raw)
To: Robert Haas <robertmhaas@gmail.com>; +Cc: pgsql-hackers@postgresql.org <pgsql-hackers@postgresql.org>
Robert Haas <robertmhaas@gmail.com> writes:
> On Thu, Aug 4, 2016 at 10:58 PM, Robert Haas <robertmhaas@gmail.com> wrote:
>> What is the reason? We refuse to separate frontend and backend
>> headers in any sort of principled way?
> That was poorly phrased. I'll try again: I can't see any reason for
> using a macro here except that it allows frontend code to compile this
> without breaking.
Well, the alternative would be to put "#ifndef FRONTEND" around the
static-inline function. That's not very pretty either, and it's
inconsistent with the existing precedent (ie, InitDirtySnapshot).
Also, it presumes that a non-backend includer actually has defined
FRONTEND; that seems to be the case for pg_xlogdump but I do not
think we do that everywhere.
> Here's a patch. Is this what you want?
OK by me.
regards, tom lane
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Re: [COMMITTERS] pgsql: Prevent "snapshot too old" from trying to return pruned TOAST tu
2016-08-03 20:52 pgsql: Prevent "snapshot too old" from trying to return pruned TOAST tu Robert Haas <rhaas@postgresql.org>
2016-08-04 23:23 ` Re: pgsql: Prevent "snapshot too old" from trying to return pruned TOAST tu Tom Lane <tgl@sss.pgh.pa.us>
2016-08-05 02:58 ` Re: pgsql: Prevent "snapshot too old" from trying to return pruned TOAST tu Robert Haas <robertmhaas@gmail.com>
2016-08-05 03:59 ` Re: [COMMITTERS] pgsql: Prevent "snapshot too old" from trying to return pruned TOAST tu Robert Haas <robertmhaas@gmail.com>
2016-08-05 15:05 ` Re: Re: [COMMITTERS] pgsql: Prevent "snapshot too old" from trying to return pruned TOAST tu Tom Lane <tgl@sss.pgh.pa.us>
@ 2016-08-05 16:04 ` Robert Haas <robertmhaas@gmail.com>
0 siblings, 0 replies; 6+ messages in thread
From: Robert Haas @ 2016-08-05 16:04 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-hackers@postgresql.org <pgsql-hackers@postgresql.org>
On Fri, Aug 5, 2016 at 11:05 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Robert Haas <robertmhaas@gmail.com> writes:
>> On Thu, Aug 4, 2016 at 10:58 PM, Robert Haas <robertmhaas@gmail.com> wrote:
>>> What is the reason? We refuse to separate frontend and backend
>>> headers in any sort of principled way?
>
>> That was poorly phrased. I'll try again: I can't see any reason for
>> using a macro here except that it allows frontend code to compile this
>> without breaking.
>
> Well, the alternative would be to put "#ifndef FRONTEND" around the
> static-inline function. That's not very pretty either, and it's
> inconsistent with the existing precedent (ie, InitDirtySnapshot).
> Also, it presumes that a non-backend includer actually has defined
> FRONTEND; that seems to be the case for pg_xlogdump but I do not
> think we do that everywhere.
That may not be pretty, but it'd be a lot more transparent. If I see
#ifndef FRONTEND, I think, oh, that's protecting some stuff that
shouldn't be included in front-end compiles. If I see a macro, I not
necessarily think of the fact that this may be a way of preventing
that code from being compiled in front-end compiles.
>> Here's a patch. Is this what you want?
>
> OK by me.
OK, committed.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2016-08-05 16:04 UTC | newest]
Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2016-08-03 20:52 pgsql: Prevent "snapshot too old" from trying to return pruned TOAST tu Robert Haas <rhaas@postgresql.org>
2016-08-04 23:23 ` Tom Lane <tgl@sss.pgh.pa.us>
2016-08-05 02:58 ` Robert Haas <robertmhaas@gmail.com>
2016-08-05 03:59 ` Robert Haas <robertmhaas@gmail.com>
2016-08-05 15:05 ` Tom Lane <tgl@sss.pgh.pa.us>
2016-08-05 16:04 ` Robert Haas <robertmhaas@gmail.com>
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