Commit 11014765 authored by Alvaro Herrera's avatar Alvaro Herrera

Make sure we only try to free snapshots that have been passed through

CopySnapshot, per Neil Conway.  Also add a comment about the assumption in
GetSnapshotData that the argument is statically allocated.

Also, fix some more typos in comments in snapmgr.c.
parent 0c2914d4
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/storage/ipc/procarray.c,v 1.44 2008/05/12 20:02:00 alvherre Exp $ * $PostgreSQL: pgsql/src/backend/storage/ipc/procarray.c,v 1.45 2008/07/11 02:10:13 alvherre Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -666,6 +666,9 @@ GetOldestXmin(bool allDbs, bool ignoreVacuum) ...@@ -666,6 +666,9 @@ GetOldestXmin(bool allDbs, bool ignoreVacuum)
* RecentGlobalXmin: the global xmin (oldest TransactionXmin across all * RecentGlobalXmin: the global xmin (oldest TransactionXmin across all
* running transactions, except those running LAZY VACUUM). This is * running transactions, except those running LAZY VACUUM). This is
* the same computation done by GetOldestXmin(true, true). * the same computation done by GetOldestXmin(true, true).
*
* Note: this function should probably not be called with an argument that's
* not statically allocated (see xip allocation below).
*/ */
Snapshot Snapshot
GetSnapshotData(Snapshot snapshot) GetSnapshotData(Snapshot snapshot)
......
...@@ -3,10 +3,9 @@ ...@@ -3,10 +3,9 @@
* PostgreSQL snapshot manager * PostgreSQL snapshot manager
* *
* We keep track of snapshots in two ways: the "registered snapshots" list, * We keep track of snapshots in two ways: the "registered snapshots" list,
* and the "active snapshot" stack. All snapshots in any of them is supposed * and the "active snapshot" stack. All snapshots in either of them live in
* to be in persistent memory. When a snapshot is no longer in any of these * persistent memory. When a snapshot is no longer in any of these lists
* lists (tracked by separate refcounts of each snapshot), its memory can be * (tracked by separate refcounts on each snapshot), its memory can be freed.
* freed.
* *
* These arrangements let us reset MyProc->xmin when there are no snapshots * These arrangements let us reset MyProc->xmin when there are no snapshots
* referenced by this transaction. (One possible improvement would be to be * referenced by this transaction. (One possible improvement would be to be
...@@ -23,7 +22,7 @@ ...@@ -23,7 +22,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/time/snapmgr.c,v 1.3 2008/07/11 00:00:29 neilc Exp $ * $PostgreSQL: pgsql/src/backend/utils/time/snapmgr.c,v 1.4 2008/07/11 02:10:14 alvherre Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -261,6 +260,7 @@ FreeSnapshot(Snapshot snapshot) ...@@ -261,6 +260,7 @@ FreeSnapshot(Snapshot snapshot)
{ {
Assert(snapshot->regd_count == 0); Assert(snapshot->regd_count == 0);
Assert(snapshot->active_count == 0); Assert(snapshot->active_count == 0);
Assert(snapshot->copied);
pfree(snapshot); pfree(snapshot);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment