From 5da9da71c44f27ba48fdad08ef263bf70e43e689 Mon Sep 17 00:00:00 2001 From: Alvaro Herrera Date: Mon, 12 May 2008 20:02:02 +0000 Subject: 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. --- src/include/utils/snapmgr.h | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'src/include/utils/snapmgr.h') diff --git a/src/include/utils/snapmgr.h b/src/include/utils/snapmgr.h index c76c70feaac..8f3cc44c57b 100644 --- a/src/include/utils/snapmgr.h +++ b/src/include/utils/snapmgr.h @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/utils/snapmgr.h,v 1.1 2008/03/26 18:48:59 alvherre Exp $ + * $PostgreSQL: pgsql/src/include/utils/snapmgr.h,v 1.2 2008/05/12 20:02:02 alvherre Exp $ * *------------------------------------------------------------------------- */ @@ -16,9 +16,7 @@ #include "utils/snapshot.h" -extern PGDLLIMPORT Snapshot SerializableSnapshot; -extern PGDLLIMPORT Snapshot LatestSnapshot; -extern PGDLLIMPORT Snapshot ActiveSnapshot; +extern bool FirstSnapshotSet; extern TransactionId TransactionXmin; extern TransactionId RecentXmin; @@ -26,8 +24,19 @@ extern TransactionId RecentGlobalXmin; extern Snapshot GetTransactionSnapshot(void); extern Snapshot GetLatestSnapshot(void); -extern Snapshot CopySnapshot(Snapshot snapshot); -extern void FreeSnapshot(Snapshot snapshot); -extern void FreeXactSnapshot(void); +extern void SnapshotSetCommandId(CommandId curcid); + +extern void PushActiveSnapshot(Snapshot snapshot); +extern void PushUpdatedSnapshot(Snapshot snapshot); +extern void PopActiveSnapshot(void); +extern Snapshot GetActiveSnapshot(void); +extern bool ActiveSnapshotSet(void); + +extern Snapshot RegisterSnapshot(Snapshot snapshot); +extern void UnregisterSnapshot(Snapshot snapshot); + +extern void AtSubCommit_Snapshot(int level); +extern void AtSubAbort_Snapshot(int level); +extern void AtEOXact_Snapshot(bool isCommit); #endif /* SNAPMGR_H */ -- cgit v1.2.3