Skip to content

Commit 15a412f

Browse files
committed
Fill subxip array
1 parent 5af4303 commit 15a412f

File tree

4 files changed

+17
-13
lines changed

4 files changed

+17
-13
lines changed

contrib/pg_xtm/pg_dtm.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,11 @@ static void DtmCopySnapshot(Snapshot dst, Snapshot src)
6565
{
6666
DtmInitSnapshot(dst);
6767
memcpy(dst->xip, src->xip, src->xcnt*sizeof(TransactionId));
68+
memcpy(dst->subxip, src->xip, src->xcnt*sizeof(TransactionId));
6869
dst->xmax = src->xmax;
6970
dst->xmin = src->xmin;
7071
dst->xcnt = src->xcnt;
72+
dst->subxcnt = src->xcnt;
7173
dst->curcid = src->curcid;
7274
}
7375

src/backend/access/transam/twophase.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ AllocGXid(TransactionId xid)
659659
gxact->prepare_lsn = 0;
660660
gxact->owner = 0;
661661
gxact->locking_backend = MyBackendId;
662-
gxact->valid = false;
662+
gxact->valid = true;
663663
strcpy(gxact->gid, gid);
664664

665665
/* And insert it into the active array */
@@ -677,7 +677,7 @@ AllocGXid(TransactionId xid)
677677
return gxact->pgprocno;
678678
}
679679

680-
void
680+
bool
681681
RemoveGXid(TransactionId xid)
682682
{
683683
int i;
@@ -699,12 +699,13 @@ RemoveGXid(TransactionId xid)
699699
TwoPhaseState->prepXacts[i]->next = TwoPhaseState->freeGXacts;
700700
TwoPhaseState->freeGXacts = TwoPhaseState->prepXacts[i];
701701

702-
break;
702+
LWLockRelease(TwoPhaseStateLock);
703+
return true;
703704
}
704705
}
705706

706707
LWLockRelease(TwoPhaseStateLock);
707-
708+
return false;
708709
}
709710

710711
/*

src/backend/storage/ipc/procarray.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3869,7 +3869,7 @@ KnownAssignedXidsReset(void)
38693869

38703870
static bool TransactionIsStillInProgress(TransactionId xid, Snapshot snapshot)
38713871
{
3872-
return (bsearch(&xid, snapshot->xip, snapshot->xcnt, sizeof(TransactionId), xidComparator) != NULL) || (xid > snapshot->xmax);
3872+
return (xid > snapshot->xmax) || (bsearch(&xid, snapshot->xip, snapshot->xcnt, sizeof(TransactionId), xidComparator) != NULL);
38733873
}
38743874

38753875

@@ -3895,13 +3895,14 @@ void VacuumProcArray(Snapshot snapshot)
38953895
nInProgress += 1;
38963896
continue;
38973897
}
3898-
RemoveGXid(pxid);
3899-
nCompleted += 1;
3900-
memmove(&arrayP->pgprocnos[i], &arrayP->pgprocnos[i + 1],
3901-
(arrayP->numProcs - i - 1) * sizeof(int));
3902-
arrayP->pgprocnos[arrayP->numProcs - 1] = -1; /* for debugging */
3903-
arrayP->numProcs--;
3898+
if (RemoveGXid(pxid)) {
3899+
nCompleted += 1;
3900+
memmove(&arrayP->pgprocnos[i], &arrayP->pgprocnos[i + 1],
3901+
(arrayP->numProcs - i - 1) * sizeof(int));
3902+
arrayP->pgprocnos[arrayP->numProcs - 1] = -1; /* for debugging */
3903+
arrayP->numProcs--;
3904+
}
39043905
}
39053906
LWLockRelease(ProcArrayLock);
3906-
//elog(WARNING, "VacuumProcArray: %d in progress, %d completed, %d total\n", nInProgress, nCompleted, arrayP->numProcs);
3907+
elog(WARNING, "VacuumProcArray: %d in progress, %d completed, %d total\n", nInProgress, nCompleted, arrayP->numProcs);
39073908
}

src/include/access/twophase.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,6 @@ extern void FinishPreparedTransaction(const char *gid, bool isCommit);
5959
extern const char* GetLockedGlobalTransactionId(void);
6060

6161
extern int AllocGXid(TransactionId xid);
62-
extern void RemoveGXid(TransactionId xid);
62+
extern bool RemoveGXid(TransactionId xid);
6363

6464
#endif /* TWOPHASE_H */

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy