mirror of
https://github.com/postgres/postgres.git
synced 2025-11-25 12:03:53 +03:00
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.
This commit is contained in:
@@ -180,11 +180,26 @@ extern PGDLLIMPORT int32 *LocalRefCount;
|
||||
/*
|
||||
* BufferGetPage
|
||||
* Returns the page associated with a buffer.
|
||||
*
|
||||
* agetest will normally be a literal, so use a macro at the outer level to
|
||||
* give the compiler a chance to optimize away the runtime code to check it.
|
||||
*
|
||||
* TestForOldSnapshot(), if it doesn't throw an error, will return the page
|
||||
* argument it is passed, so the same result will go back to this macro's
|
||||
* caller for either agetest value; it is a matter of whether to call the
|
||||
* function to perform the test. For call sites where the check is not needed
|
||||
* (which is the vast majority of them), the snapshot and relation parameters
|
||||
* can, and generally should, be NULL.
|
||||
*/
|
||||
#define BufferGetPage(buffer, snapshot, relation, agetest) \
|
||||
( \
|
||||
AssertMacro((agetest) == BGP_NO_SNAPSHOT_TEST), \
|
||||
((Page)BufferGetBlock(buffer)) \
|
||||
( \
|
||||
AssertMacro((agetest) == BGP_NO_SNAPSHOT_TEST || (agetest) == BGP_TEST_FOR_OLD_SNAPSHOT), \
|
||||
((agetest) == BGP_NO_SNAPSHOT_TEST) \
|
||||
) ? \
|
||||
((Page)BufferGetBlock(buffer)) \
|
||||
: \
|
||||
(TestForOldSnapshot(snapshot, relation, (Page)BufferGetBlock(buffer))) \
|
||||
)
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user