Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit fb435f4

Browse files
committed
Observe array length in HaveVirtualXIDsDelayingChkpt().
Since commit f21bb9c, this function ignores the caller-provided length and loops until it finds a terminator, which GetVirtualXIDsDelayingChkpt() never adds. Restore the previous loop control logic. In passing, revert the addition of an unused variable by the same commit, presumably a debugging relic.
1 parent ff53890 commit fb435f4

File tree

2 files changed

+14
-19
lines changed

2 files changed

+14
-19
lines changed

src/backend/access/transam/xlog.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6984,12 +6984,9 @@ CreateCheckPoint(int flags)
69846984
vxids = GetVirtualXIDsDelayingChkpt(&nvxids);
69856985
if (nvxids > 0)
69866986
{
6987-
uint32 nwaits = 0;
6988-
69896987
do
69906988
{
69916989
pg_usleep(10000L); /* wait for 10 msec */
6992-
nwaits++;
69936990
} while (HaveVirtualXIDsDelayingChkpt(vxids, nvxids));
69946991
}
69956992
pfree(vxids);

src/backend/storage/ipc/procarray.c

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1849,32 +1849,30 @@ HaveVirtualXIDsDelayingChkpt(VirtualTransactionId *vxids, int nvxids)
18491849

18501850
LWLockAcquire(ProcArrayLock, LW_SHARED);
18511851

1852-
while (VirtualTransactionIdIsValid(*vxids))
1852+
for (index = 0; index < arrayP->numProcs; index++)
18531853
{
1854-
for (index = 0; index < arrayP->numProcs; index++)
1854+
int pgprocno = arrayP->pgprocnos[index];
1855+
volatile PGPROC *proc = &allProcs[pgprocno];
1856+
volatile PGXACT *pgxact = &allPgXact[pgprocno];
1857+
VirtualTransactionId vxid;
1858+
1859+
GET_VXID_FROM_PGPROC(vxid, *proc);
1860+
1861+
if (pgxact->delayChkpt && VirtualTransactionIdIsValid(vxid))
18551862
{
1856-
int pgprocno = arrayP->pgprocnos[index];
1857-
volatile PGPROC *proc = &allProcs[pgprocno];
1858-
volatile PGXACT *pgxact = &allPgXact[pgprocno];
1859-
VirtualTransactionId vxid;
1863+
int i;
18601864

1861-
GET_VXID_FROM_PGPROC(vxid, *proc);
1862-
if (VirtualTransactionIdIsValid(vxid))
1865+
for (i = 0; i < nvxids; i++)
18631866
{
1864-
if (VirtualTransactionIdEquals(vxid, *vxids) &&
1865-
pgxact->delayChkpt)
1867+
if (VirtualTransactionIdEquals(vxid, vxids[i]))
18661868
{
18671869
result = true;
18681870
break;
18691871
}
18701872
}
1873+
if (result)
1874+
break;
18711875
}
1872-
1873-
if (result)
1874-
break;
1875-
1876-
/* The virtual transaction is gone now, wait for the next one */
1877-
vxids++;
18781876
}
18791877

18801878
LWLockRelease(ProcArrayLock);

0 commit comments

Comments
 (0)