mirror of
https://github.com/postgres/postgres.git
synced 2025-04-24 10:47:04 +03:00
Volatile-qualify the ProcArray PGPROC pointer in a bunch of routines
that examine fields that could change under them. This is just to make really sure that when we are fetching a value 'only once', that's what actually happens. Possibly this is a bug that should be back-patched, but in the absence of solid evidence that it's needed, I won't bother.
This commit is contained in:
parent
4bf2dfb9a2
commit
0ecb4ea773
@ -23,7 +23,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/storage/ipc/procarray.c,v 1.29 2007/09/05 18:10:47 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/storage/ipc/procarray.c,v 1.30 2007/09/05 21:11:19 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -233,7 +233,7 @@ TransactionIdIsInProgress(TransactionId xid)
|
|||||||
|
|
||||||
for (i = 0; i < arrayP->numProcs; i++)
|
for (i = 0; i < arrayP->numProcs; i++)
|
||||||
{
|
{
|
||||||
PGPROC *proc = arrayP->procs[i];
|
volatile PGPROC *proc = arrayP->procs[i];
|
||||||
|
|
||||||
/* Fetch xid just once - see GetNewTransactionId */
|
/* Fetch xid just once - see GetNewTransactionId */
|
||||||
TransactionId pxid = proc->xid;
|
TransactionId pxid = proc->xid;
|
||||||
@ -361,7 +361,7 @@ TransactionIdIsActive(TransactionId xid)
|
|||||||
|
|
||||||
for (i = 0; i < arrayP->numProcs; i++)
|
for (i = 0; i < arrayP->numProcs; i++)
|
||||||
{
|
{
|
||||||
PGPROC *proc = arrayP->procs[i];
|
volatile PGPROC *proc = arrayP->procs[i];
|
||||||
|
|
||||||
/* Fetch xid just once - see GetNewTransactionId */
|
/* Fetch xid just once - see GetNewTransactionId */
|
||||||
TransactionId pxid = proc->xid;
|
TransactionId pxid = proc->xid;
|
||||||
@ -434,7 +434,7 @@ GetOldestXmin(bool allDbs, bool ignoreVacuum)
|
|||||||
|
|
||||||
for (index = 0; index < arrayP->numProcs; index++)
|
for (index = 0; index < arrayP->numProcs; index++)
|
||||||
{
|
{
|
||||||
PGPROC *proc = arrayP->procs[index];
|
volatile PGPROC *proc = arrayP->procs[index];
|
||||||
|
|
||||||
if (ignoreVacuum && proc->inVacuum)
|
if (ignoreVacuum && proc->inVacuum)
|
||||||
continue;
|
continue;
|
||||||
@ -613,7 +613,7 @@ GetSnapshotData(Snapshot snapshot, bool serializable)
|
|||||||
*/
|
*/
|
||||||
for (index = 0; index < arrayP->numProcs; index++)
|
for (index = 0; index < arrayP->numProcs; index++)
|
||||||
{
|
{
|
||||||
PGPROC *proc = arrayP->procs[index];
|
volatile PGPROC *proc = arrayP->procs[index];
|
||||||
TransactionId xid;
|
TransactionId xid;
|
||||||
|
|
||||||
/* Ignore procs running LAZY VACUUM */
|
/* Ignore procs running LAZY VACUUM */
|
||||||
@ -672,7 +672,7 @@ GetSnapshotData(Snapshot snapshot, bool serializable)
|
|||||||
if (nxids > 0)
|
if (nxids > 0)
|
||||||
{
|
{
|
||||||
memcpy(snapshot->subxip + subcount,
|
memcpy(snapshot->subxip + subcount,
|
||||||
proc->subxids.xids,
|
(void *) proc->subxids.xids,
|
||||||
nxids * sizeof(TransactionId));
|
nxids * sizeof(TransactionId));
|
||||||
subcount += nxids;
|
subcount += nxids;
|
||||||
}
|
}
|
||||||
@ -739,7 +739,7 @@ GetTransactionsInCommit(TransactionId **xids_p)
|
|||||||
|
|
||||||
for (index = 0; index < arrayP->numProcs; index++)
|
for (index = 0; index < arrayP->numProcs; index++)
|
||||||
{
|
{
|
||||||
PGPROC *proc = arrayP->procs[index];
|
volatile PGPROC *proc = arrayP->procs[index];
|
||||||
/* Fetch xid just once - see GetNewTransactionId */
|
/* Fetch xid just once - see GetNewTransactionId */
|
||||||
TransactionId pxid = proc->xid;
|
TransactionId pxid = proc->xid;
|
||||||
|
|
||||||
@ -773,7 +773,7 @@ HaveTransactionsInCommit(TransactionId *xids, int nxids)
|
|||||||
|
|
||||||
for (index = 0; index < arrayP->numProcs; index++)
|
for (index = 0; index < arrayP->numProcs; index++)
|
||||||
{
|
{
|
||||||
PGPROC *proc = arrayP->procs[index];
|
volatile PGPROC *proc = arrayP->procs[index];
|
||||||
/* Fetch xid just once - see GetNewTransactionId */
|
/* Fetch xid just once - see GetNewTransactionId */
|
||||||
TransactionId pxid = proc->xid;
|
TransactionId pxid = proc->xid;
|
||||||
|
|
||||||
@ -861,7 +861,7 @@ BackendXidGetPid(TransactionId xid)
|
|||||||
|
|
||||||
for (index = 0; index < arrayP->numProcs; index++)
|
for (index = 0; index < arrayP->numProcs; index++)
|
||||||
{
|
{
|
||||||
PGPROC *proc = arrayP->procs[index];
|
volatile PGPROC *proc = arrayP->procs[index];
|
||||||
|
|
||||||
if (proc->xid == xid)
|
if (proc->xid == xid)
|
||||||
{
|
{
|
||||||
@ -909,7 +909,7 @@ GetCurrentVirtualXIDs(TransactionId limitXmin)
|
|||||||
|
|
||||||
for (index = 0; index < arrayP->numProcs; index++)
|
for (index = 0; index < arrayP->numProcs; index++)
|
||||||
{
|
{
|
||||||
PGPROC *proc = arrayP->procs[index];
|
volatile PGPROC *proc = arrayP->procs[index];
|
||||||
/* Fetch xmin just once - might change on us? */
|
/* Fetch xmin just once - might change on us? */
|
||||||
TransactionId pxmin = proc->xmin;
|
TransactionId pxmin = proc->xmin;
|
||||||
|
|
||||||
@ -963,7 +963,7 @@ CountActiveBackends(void)
|
|||||||
*/
|
*/
|
||||||
for (index = 0; index < arrayP->numProcs; index++)
|
for (index = 0; index < arrayP->numProcs; index++)
|
||||||
{
|
{
|
||||||
PGPROC *proc = arrayP->procs[index];
|
volatile PGPROC *proc = arrayP->procs[index];
|
||||||
|
|
||||||
if (proc == MyProc)
|
if (proc == MyProc)
|
||||||
continue; /* do not count myself */
|
continue; /* do not count myself */
|
||||||
@ -993,7 +993,7 @@ CountDBBackends(Oid databaseid)
|
|||||||
|
|
||||||
for (index = 0; index < arrayP->numProcs; index++)
|
for (index = 0; index < arrayP->numProcs; index++)
|
||||||
{
|
{
|
||||||
PGPROC *proc = arrayP->procs[index];
|
volatile PGPROC *proc = arrayP->procs[index];
|
||||||
|
|
||||||
if (proc->pid == 0)
|
if (proc->pid == 0)
|
||||||
continue; /* do not count prepared xacts */
|
continue; /* do not count prepared xacts */
|
||||||
@ -1020,7 +1020,7 @@ CountUserBackends(Oid roleid)
|
|||||||
|
|
||||||
for (index = 0; index < arrayP->numProcs; index++)
|
for (index = 0; index < arrayP->numProcs; index++)
|
||||||
{
|
{
|
||||||
PGPROC *proc = arrayP->procs[index];
|
volatile PGPROC *proc = arrayP->procs[index];
|
||||||
|
|
||||||
if (proc->pid == 0)
|
if (proc->pid == 0)
|
||||||
continue; /* do not count prepared xacts */
|
continue; /* do not count prepared xacts */
|
||||||
@ -1072,7 +1072,7 @@ CheckOtherDBBackends(Oid databaseId)
|
|||||||
|
|
||||||
for (index = 0; index < arrayP->numProcs; index++)
|
for (index = 0; index < arrayP->numProcs; index++)
|
||||||
{
|
{
|
||||||
PGPROC *proc = arrayP->procs[index];
|
volatile PGPROC *proc = arrayP->procs[index];
|
||||||
|
|
||||||
if (proc->databaseId != databaseId)
|
if (proc->databaseId != databaseId)
|
||||||
continue;
|
continue;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user