mirror of
https://github.com/postgres/postgres.git
synced 2025-09-02 04:21:28 +03:00
Expose some information about backend subxact status.
A new function pg_stat_get_backend_subxact() can be used to get information about the number of subtransactions in the cache of a particular backend and whether that cache has overflowed. This can be useful for tracking down performance problems that can result from overflowed snapshots. Dilip Kumar, reviewed by Zhihong Yu, Nikolay Samokhvalov, Justin Pryzby, Nathan Bossart, Ashutosh Sharma, Julien Rouhaud. Additional design comments from Andres Freund, Tom Lane, Bruce Momjian, and David G. Johnston. Discussion: http://postgr.es/m/CAFiTN-ut0uwkRJDQJeDPXpVyTWD46m3gt3JDToE02hTfONEN=Q@mail.gmail.com
This commit is contained in:
@@ -404,17 +404,20 @@ BackendIdGetProc(int backendID)
|
||||
|
||||
/*
|
||||
* BackendIdGetTransactionIds
|
||||
* Get the xid and xmin of the backend. The result may be out of date
|
||||
* arbitrarily quickly, so the caller must be careful about how this
|
||||
* information is used.
|
||||
* Get the xid, xmin, nsubxid and overflow status of the backend. The
|
||||
* result may be out of date arbitrarily quickly, so the caller must be
|
||||
* careful about how this information is used.
|
||||
*/
|
||||
void
|
||||
BackendIdGetTransactionIds(int backendID, TransactionId *xid, TransactionId *xmin)
|
||||
BackendIdGetTransactionIds(int backendID, TransactionId *xid,
|
||||
TransactionId *xmin, int *nsubxid, bool *overflowed)
|
||||
{
|
||||
SISeg *segP = shmInvalBuffer;
|
||||
|
||||
*xid = InvalidTransactionId;
|
||||
*xmin = InvalidTransactionId;
|
||||
*nsubxid = 0;
|
||||
*overflowed = false;
|
||||
|
||||
/* Need to lock out additions/removals of backends */
|
||||
LWLockAcquire(SInvalWriteLock, LW_SHARED);
|
||||
@@ -428,6 +431,8 @@ BackendIdGetTransactionIds(int backendID, TransactionId *xid, TransactionId *xmi
|
||||
{
|
||||
*xid = proc->xid;
|
||||
*xmin = proc->xmin;
|
||||
*nsubxid = proc->subxidStatus.count;
|
||||
*overflowed = proc->subxidStatus.overflowed;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user