Skip to content

Commit c28682f

Browse files
committed
Undo replacement of TransactionIdIsInProgress
1 parent 7a3c1f2 commit c28682f

File tree

8 files changed

+34
-49
lines changed

8 files changed

+34
-49
lines changed

contrib/pg_xtm/libdtm.c

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -161,29 +161,29 @@ bool DtmGlobalStartTransaction(DTMConn dtm, GlobalTransactionId *gtid) {
161161
return ok;
162162
}
163163

164-
// void DtmInitSnapshot(Snapshot snapshot)
165-
// {
166-
// if (snapshot->xip == NULL)
167-
// {
168-
// /*
169-
// * First call for this snapshot. Snapshot is same size whether or not
170-
// * we are in recovery, see later comments.
171-
// */
172-
// snapshot->xip = (TransactionId *)
173-
// malloc(GetMaxSnapshotXidCount() * sizeof(TransactionId));
174-
// if (snapshot->xip == NULL)
175-
// ereport(ERROR,
176-
// (errcode(ERRCODE_OUT_OF_MEMORY),
177-
// errmsg("out of memory")));
178-
// Assert(snapshot->subxip == NULL);
179-
// snapshot->subxip = (TransactionId *)
180-
// malloc(GetMaxSnapshotSubxidCount() * sizeof(TransactionId));
181-
// if (snapshot->subxip == NULL)
182-
// ereport(ERROR,
183-
// (errcode(ERRCODE_OUT_OF_MEMORY),
184-
// errmsg("out of memory")));
185-
// }
186-
// }
164+
void DtmInitSnapshot(Snapshot snapshot)
165+
{
166+
if (snapshot->xip == NULL)
167+
{
168+
/*
169+
* First call for this snapshot. Snapshot is same size whether or not
170+
* we are in recovery, see later comments.
171+
*/
172+
snapshot->xip = (TransactionId *)
173+
malloc(GetMaxSnapshotXidCount() * sizeof(TransactionId));
174+
if (snapshot->xip == NULL)
175+
ereport(ERROR,
176+
(errcode(ERRCODE_OUT_OF_MEMORY),
177+
errmsg("out of memory")));
178+
Assert(snapshot->subxip == NULL);
179+
snapshot->subxip = (TransactionId *)
180+
malloc(GetMaxSnapshotSubxidCount() * sizeof(TransactionId));
181+
if (snapshot->subxip == NULL)
182+
ereport(ERROR,
183+
(errcode(ERRCODE_OUT_OF_MEMORY),
184+
errmsg("out of memory")));
185+
}
186+
}
187187

188188
// Asks DTM for a fresh snapshot. Returns 'true' on success, or 'false'
189189
// otherwise.
@@ -213,7 +213,7 @@ bool DtmGlobalGetSnapshot(DTMConn dtm, NodeId nodeid, TransactionId xid, Snapsho
213213
s->xcnt = number;
214214
Assert(s->xcnt == number); // the number should definitely fit into xcnt field size
215215

216-
// DtmInitSnapshot(s);
216+
DtmInitSnapshot(s);
217217
for (i = 0; i < s->xcnt; i++) {
218218
if (!dtm_read_hex16(dtm, &number)) return false;
219219
s->xip[i] = number;

contrib/pg_xtm/libdtm.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ DTMConn DtmConnect(char *host, int port);
2020
// bad things will happen.
2121
void DtmDisconnect(DTMConn dtm);
2222

23-
// void DtmInitSnapshot(Snapshot snapshot);
23+
void DtmInitSnapshot(Snapshot snapshot);
2424

2525
typedef struct {
2626
TransactionId* xids;

contrib/pg_xtm/pg_dtm.c

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,12 @@ static Snapshot DtmGetSnapshot(Snapshot snapshot);
4040
static void DtmCopySnapshot(Snapshot dst, Snapshot src);
4141
static XidStatus DtmGetTransactionStatus(TransactionId xid, XLogRecPtr *lsn);
4242
static void DtmSetTransactionStatus(TransactionId xid, int nsubxids, TransactionId *subxids, XidStatus status, XLogRecPtr lsn);
43-
static bool DtmTransactionIsRunning(TransactionId xid);
4443
static NodeId DtmNodeId;
4544

4645
static DTMConn DtmConn;
4746
static SnapshotData DtmSnapshot = {HeapTupleSatisfiesMVCC};
4847
static bool DtmHasSnapshot = false;
49-
static TransactionManager DtmTM = { DtmGetTransactionStatus, DtmSetTransactionStatus, DtmGetSnapshot, DtmTransactionIsRunning };
48+
static TransactionManager DtmTM = { DtmGetTransactionStatus, DtmSetTransactionStatus, DtmGetSnapshot };
5049
static DTMConn DtmConn;
5150

5251
static void DtmEnsureConnection(void)
@@ -72,20 +71,12 @@ static void DtmCopySnapshot(Snapshot dst, Snapshot src)
7271
static Snapshot DtmGetSnapshot(Snapshot snapshot)
7372
{
7473
if (DtmHasSnapshot) {
75-
CopyDtmSnapshot(snapshot, &DtmSnapshot);
74+
DtmCopySnapshot(snapshot, &DtmSnapshot);
7675
return snapshot;
7776
}
7877
return GetLocalSnapshotData(snapshot);
7978
}
8079

81-
static bool DtmTransactionIsRunning(TransactionId xid)
82-
{
83-
XLogRecPtr lsn;
84-
return DtmHasSnapshot
85-
? DtmGetTransactionStatus(xid, &lsn) == TRANSACTION_STATUS_IN_PROGRESS
86-
: TransactionIdIsRunning(xid);
87-
}
88-
8980
static XidStatus DtmGetTransactionStatus(TransactionId xid, XLogRecPtr *lsn)
9081
{
9182
XidStatus status = CLOGTransactionIdGetStatus(xid, lsn);

src/backend/access/transam/clog.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
#include "miscadmin.h"
4444
#include "pg_trace.h"
4545

46-
TransactionManager DefaultTM = { CLOGTransactionIdGetStatus, CLOGTransactionIdSetTreeStatus, GetLocalSnapshotData, TransactionIdIsRunning };
46+
TransactionManager DefaultTM = { CLOGTransactionIdGetStatus, CLOGTransactionIdSetTreeStatus, GetLocalSnapshotData };
4747
TransactionManager* TM = &DefaultTM;
4848

4949
/*

src/backend/storage/ipc/procarray.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -946,12 +946,6 @@ ProcArrayApplyXidAssignment(TransactionId topxid,
946946
LWLockRelease(ProcArrayLock);
947947
}
948948

949-
bool
950-
TransactionIdIsInProgress(TransactionId xid)
951-
{
952-
return TM->IsInProgress(xid);
953-
}
954-
955949
/*
956950
* TransactionIdIsInProgress -- is given transaction running in some backend
957951
*
@@ -979,7 +973,7 @@ TransactionIdIsInProgress(TransactionId xid)
979973
* PGXACT again anyway; see GetNewTransactionId).
980974
*/
981975
bool
982-
TransactionIdIsRunning(TransactionId xid)
976+
TransactionIdIsInProgress(TransactionId xid)
983977
{
984978
static TransactionId *xids = NULL;
985979
int nxids = 0;

src/backend/utils/time/tqual.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,7 @@ HeapTupleSatisfiesUpdate(HeapTuple htup, CommandId curcid,
738738
* token is also returned in snapshot->speculativeToken.
739739
*/
740740
bool
741-
HeapTupleSatisfiesDirty(HeapTuple htup, Snapshot snapshot,
741+
HeapTupleSatisfiesDirtyVerbose(HeapTuple htup, Snapshot snapshot,
742742
Buffer buffer)
743743
{
744744
HeapTupleHeader tuple = htup->t_data;
@@ -905,9 +905,11 @@ HeapTupleSatisfiesDirty(HeapTuple htup, Snapshot snapshot,
905905

906906
if (TransactionIdIsInProgress(HeapTupleHeaderGetRawXmax(tuple)))
907907
{
908-
if (!HEAP_XMAX_IS_LOCKED_ONLY(tuple->t_infomask))
908+
if (!HEAP_XMAX_IS_LOCKED_ONLY(tuple->t_infomask)) {
909909
snapshot->xmax = HeapTupleHeaderGetRawXmax(tuple);
910-
return true;
910+
return true;
911+
}
912+
return true;
911913
}
912914

913915
if (!TransactionIdDidCommit(HeapTupleHeaderGetRawXmax(tuple)))

src/include/access/xtm.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ typedef struct
1919
XidStatus (*GetTransactionStatus)(TransactionId xid, XLogRecPtr *lsn);
2020
void (*SetTransactionStatus)(TransactionId xid, int nsubxids, TransactionId *subxids, XidStatus status, XLogRecPtr lsn);
2121
Snapshot (*GetSnapshot)(Snapshot snapshot);
22-
bool (*IsInProgress)(TransactionId xid);
2322
} TransactionManager;
2423

2524
extern TransactionManager* TM;

src/include/storage/procarray.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ extern bool ProcArrayInstallRestoredXmin(TransactionId xmin, PGPROC *proc);
5353
extern RunningTransactions GetRunningTransactionData(void);
5454

5555
extern bool TransactionIdIsInProgress(TransactionId xid);
56-
extern bool TransactionIdIsRunning(TransactionId xid);
5756
extern bool TransactionIdIsActive(TransactionId xid);
5857
extern TransactionId GetOldestXmin(Relation rel, bool ignoreVacuum);
5958
extern TransactionId GetOldestActiveTransactionId(void);

0 commit comments

Comments
 (0)