diff options
author | Alvaro Herrera <alvherre@alvh.no-ip.org> | 2008-05-12 20:02:02 +0000 |
---|---|---|
committer | Alvaro Herrera <alvherre@alvh.no-ip.org> | 2008-05-12 20:02:02 +0000 |
commit | 5da9da71c44f27ba48fdad08ef263bf70e43e689 (patch) | |
tree | d8afb52acd9386a59c1862a265d4f8e6d2fdbaba /src/backend/storage/large_object/inv_api.c | |
parent | aa82790fcab98b8d3d4eca2e2f6f7bfce57870bc (diff) | |
download | postgresql-5da9da71c44f27ba48fdad08ef263bf70e43e689.tar.gz postgresql-5da9da71c44f27ba48fdad08ef263bf70e43e689.zip |
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.
Diffstat (limited to 'src/backend/storage/large_object/inv_api.c')
-rw-r--r-- | src/backend/storage/large_object/inv_api.c | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/src/backend/storage/large_object/inv_api.c b/src/backend/storage/large_object/inv_api.c index 00fbfd89ed6..85695fb01c1 100644 --- a/src/backend/storage/large_object/inv_api.c +++ b/src/backend/storage/large_object/inv_api.c @@ -24,7 +24,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/storage/large_object/inv_api.c,v 1.132 2008/04/12 23:14:21 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/storage/large_object/inv_api.c,v 1.133 2008/05/12 20:02:00 alvherre Exp $ * *------------------------------------------------------------------------- */ @@ -246,12 +246,8 @@ inv_open(Oid lobjId, int flags, MemoryContext mcxt) } else if (flags & INV_READ) { - /* be sure to copy snap into mcxt */ - MemoryContext oldContext = MemoryContextSwitchTo(mcxt); - - retval->snapshot = CopySnapshot(ActiveSnapshot); + retval->snapshot = RegisterSnapshot(GetActiveSnapshot()); retval->flags = IFS_RDLOCK; - MemoryContextSwitchTo(oldContext); } else elog(ERROR, "invalid flags: %d", flags); @@ -274,7 +270,7 @@ inv_close(LargeObjectDesc *obj_desc) { Assert(PointerIsValid(obj_desc)); if (obj_desc->snapshot != SnapshotNow) - FreeSnapshot(obj_desc->snapshot); + UnregisterSnapshot(obj_desc->snapshot); pfree(obj_desc); } |