Skip to content

Commit 31dc8b4

Browse files
committed
Merge branch 'xtm' of gitlab.postgrespro.ru:pgpro-dev/postgrespro into xtm
2 parents 0193ed1 + 99a60ea commit 31dc8b4

File tree

8 files changed

+15
-28
lines changed

8 files changed

+15
-28
lines changed

contrib/pg_xtm/libdtm.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,11 @@ bool DtmGlobalStartTransaction(DTMConn dtm, GlobalTransactionId *gtid) {
167167
return ok;
168168
}
169169

170-
void DtmInitSnapshot(Snapshot snapshot, int nactive) {
170+
void DtmInitSnapshot(Snapshot snapshot)
171+
{
171172
#ifdef TEST
172173
if (snapshot->xip == NULL) {
173-
snapshot->xip = malloc(nactive * sizeof(TransactionId));
174+
snapshot->xip = malloc(snapshot->xcnt * sizeof(TransactionId));
174175
// FIXME: is this enough for tests?
175176
}
176177
#else
@@ -224,7 +225,8 @@ bool DtmGlobalGetSnapshot(DTMConn dtm, NodeId nodeid, TransactionId xid, Snapsho
224225
s->xcnt = number;
225226
Assert(s->xcnt == number); // the number should definitely fit into xcnt field size
226227

227-
DtmInitSnapshot(s, s->xcnt);
228+
DtmInitSnapshot(s);
229+
228230
for (i = 0; i < s->xcnt; i++) {
229231
if (!dtm_read_hex16(dtm, &number)) return false;
230232
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, int nactive);
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)