mirror of
https://github.com/postgres/postgres.git
synced 2025-11-29 23:43:17 +03:00
Improve snapshot manager by keeping explicit track of snapshots.
There are two ways to track a snapshot: there's the "registered" list, which is used for arbitrary long-lived snapshots; and there's the "active stack", which is used for the snapshot that is considered "active" at any time. This also allows users of snapshots to stop worrying about snapshot memory allocation and freeing, and about using PG_TRY blocks around ActiveSnapshot assignment. This is all done automatically now. As a consequence, this allows us to reset MyProc->xmin when there are no more snapshots registered in the current backend, reducing the impact that long-running transactions have on VACUUM.
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
* Author: Jan Wieck, Afilias USA INC.
|
||||
* 64-bit txids: Marko Kreen, Skype Technologies
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/backend/utils/adt/txid.c,v 1.6 2008/03/26 18:48:59 alvherre Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/utils/adt/txid.c,v 1.7 2008/05/12 20:02:02 alvherre Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -362,9 +362,9 @@ txid_current_snapshot(PG_FUNCTION_ARGS)
|
||||
TxidEpoch state;
|
||||
Snapshot cur;
|
||||
|
||||
cur = ActiveSnapshot;
|
||||
cur = GetActiveSnapshot();
|
||||
if (cur == NULL)
|
||||
elog(ERROR, "txid_current_snapshot: ActiveSnapshot == NULL");
|
||||
elog(ERROR, "no active snapshot set");
|
||||
|
||||
load_xid_epoch(&state);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user