diff options
| author | Kevin Grittner | 2016-04-29 21:46:08 +0000 |
|---|---|---|
| committer | Kevin Grittner | 2016-04-29 21:46:08 +0000 |
| commit | 7c3e8039f450eb99b3a73272d0a1661195747d1b (patch) | |
| tree | 584cbac86a2eddbcf78d5c2617cc6179d44d3290 /src/include | |
| parent | d34e7b2812467279b95060a4db8d9f4fc4be0e40 (diff) | |
Add a few entries to the tail of time mapping, to see old values.
Without a few entries beyond old_snapshot_threshold, the lookup
would often fail, resulting in the more aggressive pruning or
vacuum being skipped often enough to matter. This was very clearly
shown by a python test script posted by Ants Aasma, and was likely
a factor in an earlier but somewhat less clear-cut test case posted
by Jeff Janes.
This patch makes no change to the logic, per se -- it just makes
the array of mapping entries big enough to make lookup misses based
on timing much less likely. An occasional miss is still possible
if a thread stalls for more than 10 minutes, but that does not
create any problem with correctness of behavior. Besides, if
things are so busy that a thread is stalling for more than 10
minutes, it is probably OK to skip the more aggressive cleanup at
that particular point in time.
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/utils/snapmgr.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/include/utils/snapmgr.h b/src/include/utils/snapmgr.h index 6a80f0ba550..42706966f10 100644 --- a/src/include/utils/snapmgr.h +++ b/src/include/utils/snapmgr.h @@ -19,6 +19,19 @@ #include "utils/snapshot.h" +/* + * The structure used to map times to TransactionId values for the "snapshot + * too old" feature must have a few entries at the tail to hold old values; + * otherwise the lookup will often fail and the expected early pruning or + * vacuum will not usually occur. It is best if this padding is for a number + * of minutes greater than a thread would normally be stalled, but it's OK if + * early vacuum opportunities are occasionally missed, so there's no need to + * use an extreme value or get too fancy. 10 minutes seems plenty. + */ +#define OLD_SNAPSHOT_PADDING_ENTRIES 10 +#define OLD_SNAPSHOT_TIME_MAP_ENTRIES (old_snapshot_threshold + OLD_SNAPSHOT_PADDING_ENTRIES) + + /* GUC variables */ extern PGDLLIMPORT int old_snapshot_threshold; |
