mirror of
https://github.com/postgres/postgres.git
synced 2025-06-30 21:42:05 +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:
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/tcop/fastpath.c,v 1.99 2008/03/26 18:48:59 alvherre Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/tcop/fastpath.c,v 1.100 2008/05/12 20:02:01 alvherre Exp $
|
||||
*
|
||||
* NOTES
|
||||
* This cruft is the server side of PQfn.
|
||||
@ -309,7 +309,7 @@ HandleFunctionRequest(StringInfo msgBuf)
|
||||
* Now that we know we are in a valid transaction, set snapshot in case
|
||||
* needed by function itself or one of the datatype I/O routines.
|
||||
*/
|
||||
ActiveSnapshot = CopySnapshot(GetTransactionSnapshot());
|
||||
PushActiveSnapshot(GetTransactionSnapshot());
|
||||
|
||||
/*
|
||||
* Begin parsing the buffer contents.
|
||||
@ -396,6 +396,9 @@ HandleFunctionRequest(StringInfo msgBuf)
|
||||
|
||||
SendFunctionResult(retval, fcinfo.isnull, fip->rettype, rformat);
|
||||
|
||||
/* We no longer need the snapshot */
|
||||
PopActiveSnapshot();
|
||||
|
||||
/*
|
||||
* Emit duration logging if appropriate.
|
||||
*/
|
||||
|
Reference in New Issue
Block a user