Skip to content

Commit f691f5b

Browse files
committed
Remove the "snapshot too old" feature.
Remove the old_snapshot_threshold setting and mechanism for producing the error "snapshot too old", originally added by commit 848ef42. Unfortunately it had a number of known problems in terms of correctness and performance, mostly reported by Andres in the course of his work on snapshot scalability. We agreed to remove it, after a long period without an active plan to fix it. This is certainly a desirable feature, and someone might propose a new or improved implementation in the future. Reported-by: Andres Freund <andres@anarazel.de> Discussion: https://postgr.es/m/CACG%3DezYV%2BEvO135fLRdVn-ZusfVsTY6cH1OZqWtezuEYH6ciQA%40mail.gmail.com Discussion: https://postgr.es/m/20200401064008.qob7bfnnbu4w5cw4%40alap3.anarazel.de Discussion: https://postgr.es/m/CA%2BTgmoY%3Daqf0zjTD%2B3dUWYkgMiNDegDLFjo%2B6ze%3DWtpik%2B3XqA%40mail.gmail.com
1 parent aa0d350 commit f691f5b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+21
-1425
lines changed

contrib/Makefile

-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ SUBDIRS = \
2929
lo \
3030
ltree \
3131
oid2name \
32-
old_snapshot \
3332
pageinspect \
3433
passwordcheck \
3534
pg_buffercache \

contrib/bloom/blscan.c

-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ blgetbitmap(IndexScanDesc scan, TIDBitmap *tbm)
132132

133133
LockBuffer(buffer, BUFFER_LOCK_SHARE);
134134
page = BufferGetPage(buffer);
135-
TestForOldSnapshot(scan->xs_snapshot, scan->indexRelation, page);
136135

137136
if (!PageIsNew(page) && !BloomPageIsDeleted(page))
138137
{

contrib/meson.build

-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ subdir('lo')
3737
subdir('ltree')
3838
subdir('ltree_plpython')
3939
subdir('oid2name')
40-
subdir('old_snapshot')
4140
subdir('pageinspect')
4241
subdir('passwordcheck')
4342
subdir('pg_buffercache')

contrib/old_snapshot/Makefile

-21
This file was deleted.

contrib/old_snapshot/meson.build

-23
This file was deleted.

contrib/old_snapshot/old_snapshot--1.0.sql

-14
This file was deleted.

contrib/old_snapshot/old_snapshot.control

-5
This file was deleted.

contrib/old_snapshot/time_mapping.c

-142
This file was deleted.

doc/src/sgml/config.sgml

-69
Original file line numberDiff line numberDiff line change
@@ -2709,65 +2709,6 @@ include_dir 'conf.d'
27092709
</para>
27102710
</listitem>
27112711
</varlistentry>
2712-
2713-
<varlistentry id="guc-old-snapshot-threshold" xreflabel="old_snapshot_threshold">
2714-
<term><varname>old_snapshot_threshold</varname> (<type>integer</type>)
2715-
<indexterm>
2716-
<primary><varname>old_snapshot_threshold</varname> configuration parameter</primary>
2717-
</indexterm>
2718-
</term>
2719-
<listitem>
2720-
<para>
2721-
Sets the minimum amount of time that a query snapshot can be used
2722-
without risk of a <quote>snapshot too old</quote> error occurring
2723-
when using the snapshot. Data that has been dead for longer than
2724-
this threshold is allowed to be vacuumed away. This can help
2725-
prevent bloat in the face of snapshots which remain in use for a
2726-
long time. To prevent incorrect results due to cleanup of data which
2727-
would otherwise be visible to the snapshot, an error is generated
2728-
when the snapshot is older than this threshold and the snapshot is
2729-
used to read a page which has been modified since the snapshot was
2730-
built.
2731-
</para>
2732-
2733-
<para>
2734-
If this value is specified without units, it is taken as minutes.
2735-
A value of <literal>-1</literal> (the default) disables this feature,
2736-
effectively setting the snapshot age limit to infinity.
2737-
This parameter can only be set at server start.
2738-
</para>
2739-
2740-
<para>
2741-
Useful values for production work probably range from a small number
2742-
of hours to a few days. Small values (such as <literal>0</literal> or
2743-
<literal>1min</literal>) are only allowed because they may sometimes be
2744-
useful for testing. While a setting as high as <literal>60d</literal> is
2745-
allowed, please note that in many workloads extreme bloat or
2746-
transaction ID wraparound may occur in much shorter time frames.
2747-
</para>
2748-
2749-
<para>
2750-
When this feature is enabled, freed space at the end of a relation
2751-
cannot be released to the operating system, since that could remove
2752-
information needed to detect the <quote>snapshot too old</quote>
2753-
condition. All space allocated to a relation remains associated with
2754-
that relation for reuse only within that relation unless explicitly
2755-
freed (for example, with <command>VACUUM FULL</command>).
2756-
</para>
2757-
2758-
<para>
2759-
This setting does not attempt to guarantee that an error will be
2760-
generated under any particular circumstances. In fact, if the
2761-
correct results can be generated from (for example) a cursor which
2762-
has materialized a result set, no error will be generated even if the
2763-
underlying rows in the referenced table have been vacuumed away.
2764-
Some tables cannot safely be vacuumed early, and so will not be
2765-
affected by this setting, such as system catalogs. For such tables
2766-
this setting will neither reduce bloat nor create a possibility
2767-
of a <quote>snapshot too old</quote> error on scanning.
2768-
</para>
2769-
</listitem>
2770-
</varlistentry>
27712712
</variablelist>
27722713
</sect2>
27732714
</sect1>
@@ -4783,16 +4724,6 @@ ANY <replaceable class="parameter">num_sync</replaceable> ( <replaceable class="
47834724
until it eventually reaches the primary. Standbys make no other use
47844725
of feedback they receive other than to pass upstream.
47854726
</para>
4786-
<para>
4787-
This setting does not override the behavior of
4788-
<varname>old_snapshot_threshold</varname> on the primary; a snapshot on the
4789-
standby which exceeds the primary's age threshold can become invalid,
4790-
resulting in cancellation of transactions on the standby. This is
4791-
because <varname>old_snapshot_threshold</varname> is intended to provide an
4792-
absolute limit on the time which dead rows can contribute to bloat,
4793-
which would otherwise be violated because of the configuration of a
4794-
standby.
4795-
</para>
47964727
</listitem>
47974728
</varlistentry>
47984729

doc/src/sgml/contrib.sgml

-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,6 @@ CREATE EXTENSION <replaceable>extension_name</replaceable>;
150150
&isn;
151151
&lo;
152152
&ltree;
153-
&oldsnapshot;
154153
&pageinspect;
155154
&passwordcheck;
156155
&pgbuffercache;

doc/src/sgml/filelist.sgml

-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@
138138
<!ENTITY lo SYSTEM "lo.sgml">
139139
<!ENTITY ltree SYSTEM "ltree.sgml">
140140
<!ENTITY oid2name SYSTEM "oid2name.sgml">
141-
<!ENTITY oldsnapshot SYSTEM "oldsnapshot.sgml">
142141
<!ENTITY pageinspect SYSTEM "pageinspect.sgml">
143142
<!ENTITY passwordcheck SYSTEM "passwordcheck.sgml">
144143
<!ENTITY pgbuffercache SYSTEM "pgbuffercache.sgml">

doc/src/sgml/oldsnapshot.sgml

-33
This file was deleted.

src/backend/access/brin/brin_revmap.c

-7
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ brinRevmapInitialize(Relation idxrel, BlockNumber *pagesPerRange,
7979
meta = ReadBuffer(idxrel, BRIN_METAPAGE_BLKNO);
8080
LockBuffer(meta, BUFFER_LOCK_SHARE);
8181
page = BufferGetPage(meta);
82-
TestForOldSnapshot(snapshot, idxrel, page);
8382
metadata = (BrinMetaPageData *) PageGetContents(page);
8483

8584
revmap = palloc(sizeof(BrinRevmap));
@@ -277,7 +276,6 @@ brinGetTupleForHeapBlock(BrinRevmap *revmap, BlockNumber heapBlk,
277276
}
278277
LockBuffer(*buf, mode);
279278
page = BufferGetPage(*buf);
280-
TestForOldSnapshot(snapshot, idxRel, page);
281279

282280
/* If we land on a revmap page, start over */
283281
if (BRIN_IS_REGULAR_PAGE(page))
@@ -372,11 +370,6 @@ brinRevmapDesummarizeRange(Relation idxrel, BlockNumber heapBlk)
372370
LockBuffer(regBuf, BUFFER_LOCK_EXCLUSIVE);
373371
regPg = BufferGetPage(regBuf);
374372

375-
/*
376-
* We're only removing data, not reading it, so there's no need to
377-
* TestForOldSnapshot here.
378-
*/
379-
380373
/* if this is no longer a regular page, tell caller to start over */
381374
if (!BRIN_IS_REGULAR_PAGE(regPg))
382375
{

0 commit comments

Comments
 (0)