Skip to content

Commit 1101476

Browse files
committed
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.
1 parent 0c2914d commit 1101476

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/backend/storage/ipc/procarray.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
*
2424
*
2525
* IDENTIFICATION
26-
* $PostgreSQL: pgsql/src/backend/storage/ipc/procarray.c,v 1.44 2008/05/12 20:02:00 alvherre Exp $
26+
* $PostgreSQL: pgsql/src/backend/storage/ipc/procarray.c,v 1.45 2008/07/11 02:10:13 alvherre Exp $
2727
*
2828
*-------------------------------------------------------------------------
2929
*/
@@ -666,6 +666,9 @@ GetOldestXmin(bool allDbs, bool ignoreVacuum)
666666
* RecentGlobalXmin: the global xmin (oldest TransactionXmin across all
667667
* running transactions, except those running LAZY VACUUM). This is
668668
* the same computation done by GetOldestXmin(true, true).
669+
*
670+
* Note: this function should probably not be called with an argument that's
671+
* not statically allocated (see xip allocation below).
669672
*/
670673
Snapshot
671674
GetSnapshotData(Snapshot snapshot)

src/backend/utils/time/snapmgr.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@
33
* PostgreSQL snapshot manager
44
*
55
* We keep track of snapshots in two ways: the "registered snapshots" list,
6-
* and the "active snapshot" stack. All snapshots in any of them is supposed
7-
* to be in persistent memory. When a snapshot is no longer in any of these
8-
* lists (tracked by separate refcounts of each snapshot), its memory can be
9-
* freed.
6+
* and the "active snapshot" stack. All snapshots in either of them live in
7+
* persistent memory. When a snapshot is no longer in any of these lists
8+
* (tracked by separate refcounts on each snapshot), its memory can be freed.
109
*
1110
* These arrangements let us reset MyProc->xmin when there are no snapshots
1211
* referenced by this transaction. (One possible improvement would be to be
@@ -23,7 +22,7 @@
2322
* Portions Copyright (c) 1994, Regents of the University of California
2423
*
2524
* IDENTIFICATION
26-
* $PostgreSQL: pgsql/src/backend/utils/time/snapmgr.c,v 1.3 2008/07/11 00:00:29 neilc Exp $
25+
* $PostgreSQL: pgsql/src/backend/utils/time/snapmgr.c,v 1.4 2008/07/11 02:10:14 alvherre Exp $
2726
*
2827
*-------------------------------------------------------------------------
2928
*/
@@ -261,6 +260,7 @@ FreeSnapshot(Snapshot snapshot)
261260
{
262261
Assert(snapshot->regd_count == 0);
263262
Assert(snapshot->active_count == 0);
263+
Assert(snapshot->copied);
264264

265265
pfree(snapshot);
266266
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy