Add the "snapshot too old" feature

Kevin Grittner <kgrittn@postgresql.org>

Commit: 848ef42bb8c7909c9d7baa38178d4a209906e7c1
Author: Kevin Grittner <kgrittn@postgresql.org>
Date: 2016-04-08T19:36:30Z
Releases: 9.6.0
Add the "snapshot too old" feature

This feature is controlled by a new old_snapshot_threshold GUC.  A
value of -1 disables the feature, and that is the default.  The
value of 0 is just intended for testing.  Above that it is the
number of minutes a snapshot can reach before pruning and vacuum
are allowed to remove dead tuples which the snapshot would
otherwise protect.  The xmin associated with a transaction ID does
still protect dead tuples.  A connection which is using an "old"
snapshot does not get an error unless it accesses a page modified
recently enough that it might not be able to produce accurate
results.

This is similar to the Oracle feature, and we use the same SQLSTATE
and error message for compatibility.

Files

PathChange+/−
contrib/bloom/blscan.c modified +2 −1
doc/src/sgml/config.sgml modified +50 −0
src/backend/access/brin/brin.c modified +11 −8
src/backend/access/brin/brin_revmap.c modified +7 −4
src/backend/access/gin/ginbtree.c modified +5 −4
src/backend/access/gin/gindatapage.c modified +4 −3
src/backend/access/gin/ginget.c modified +12 −10
src/backend/access/gin/gininsert.c modified +1 −1
src/backend/access/gist/gistget.c modified +1 −1
src/backend/access/hash/hash.c modified +2 −1
src/backend/access/hash/hashsearch.c modified +6 −4
src/backend/access/heap/heapam.c modified +20 −11
src/backend/access/heap/pruneheap.c modified +10 −1
src/backend/access/nbtree/nbtinsert.c modified +4 −3
src/backend/access/nbtree/nbtpage.c modified +1 −1
src/backend/access/nbtree/nbtsearch.c modified +31 −20
src/backend/access/spgist/spgscan.c modified +1 −1
src/backend/commands/vacuum.c modified +2 −1
src/backend/commands/vacuumlazy.c modified +2 −1
src/backend/storage/buffer/bufmgr.c modified +40 −0
src/backend/storage/ipc/ipci.c modified +3 −0
src/backend/storage/ipc/procarray.c modified +9 −0
src/backend/storage/lmgr/lwlocknames.txt modified +1 −0
src/backend/utils/errcodes.txt modified +4 −0
src/backend/utils/misc/guc.c modified +11 −0
src/backend/utils/misc/postgresql.conf.sample modified +2 −0
src/backend/utils/time/snapmgr.c modified +404 −0
src/include/access/brin_revmap.h modified +3 −2
src/include/access/gin_private.h modified +2 −2
src/include/access/nbtree.h modified +4 −3
src/include/storage/bufmgr.h modified +17 −2
src/include/utils/rel.h modified +1 −0
src/include/utils/snapmgr.h modified +13 −0
src/include/utils/snapshot.h modified +4 −0
src/test/modules/Makefile modified +1 −0
src/test/modules/snapshot_too_old/expected/sto_using_cursor.out added +73 −0
src/test/modules/snapshot_too_old/expected/sto_using_select.out added +55 −0
src/test/modules/snapshot_too_old/Makefile added +47 −0
src/test/modules/snapshot_too_old/specs/sto_using_cursor.spec added +37 −0
src/test/modules/snapshot_too_old/specs/sto_using_select.spec added +36 −0
src/test/modules/snapshot_too_old/sto.conf added +3 −0

Documentation touched