Skip to content

Commit 0a03a1b

Browse files
committed
Remove TransactionIsInProgress from DTM API
1 parent 6f3d573 commit 0a03a1b

File tree

8 files changed

+7
-41
lines changed

8 files changed

+7
-41
lines changed

contrib/pg_xtm/dtmd/include/util.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ char *join_path(const char *dir, const char *file);
1616
bool inrange(xid_t min, xid_t x, xid_t max);
1717
int falloc(int fd, off64_t size);
1818

19-
#ifdef NDEBUG
19+
#ifndef DEBUG
2020
#define shout(...)
2121
#else
2222
#define shout(...) \

contrib/pg_xtm/libdtm.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,8 @@ DTMConn DtmConnect(char *host, int port) {
9797
continue;
9898
}
9999

100-
#ifdef NODELAY
101100
int one = 1;
102101
setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, &one, sizeof(one));
103-
#endif
104102

105103
if (connect(sock, a->ai_addr, a->ai_addrlen) == -1) {
106104
perror("failed to connect to an address");

contrib/pg_xtm/pg_dtm--1.0.sql

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,3 @@
44
CREATE FUNCTION dtm_begin_transaction(nodes integer[], xids integer[]) RETURNS void
55
AS 'MODULE_PATHNAME','dtm_begin_transaction'
66
LANGUAGE C;
7-
8-
CREATE FUNCTION dtm_get_snapshot() RETURNS void
9-
AS 'MODULE_PATHNAME','dtm_get_snapshot'
10-
LANGUAGE C;

contrib/pg_xtm/pg_dtm.c

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ static void DtmCopySnapshot(Snapshot dst, Snapshot src);
4545
static XidStatus DtmGetTransactionStatus(TransactionId xid, XLogRecPtr *lsn);
4646
static void DtmSetTransactionStatus(TransactionId xid, int nsubxids, TransactionId *subxids, XidStatus status, XLogRecPtr lsn);
4747
static void DtmUpdateRecentXmin(void);
48-
static bool DtmTransactionIsInProgress(TransactionId xid);
4948
static bool TransactionIdIsInDtmSnapshot(Snapshot s, TransactionId xid);
5049
static bool TransactionIdIsInDoubt(Snapshot s, TransactionId xid);
5150

@@ -54,7 +53,7 @@ static DTMConn DtmConn;
5453
static SnapshotData DtmSnapshot = { HeapTupleSatisfiesMVCC };
5554
static bool DtmHasSnapshot = false;
5655
static bool DtmGlobalTransaction = false;
57-
static TransactionManager DtmTM = { DtmGetTransactionStatus, DtmSetTransactionStatus, DtmGetSnapshot, DtmTransactionIsInProgress };
56+
static TransactionManager DtmTM = { DtmGetTransactionStatus, DtmSetTransactionStatus, DtmGetSnapshot };
5857
static DTMConn DtmConn;
5958

6059
#define XTM_TRACE(fmt, ...)
@@ -206,12 +205,6 @@ static Snapshot DtmGetSnapshot(Snapshot snapshot)
206205
}
207206

208207

209-
static bool DtmTransactionIsInProgress(TransactionId xid)
210-
{
211-
XTM_TRACE("XTM: DtmTransactionIsInProgress \n");
212-
return TransactionIdIsRunning(xid);// || (DtmHasSnapshot && TransactionIdIsInDtmSnapshot(&DtmSnapshot, xid));
213-
}
214-
215208
static XidStatus DtmGetTransactionStatus(TransactionId xid, XLogRecPtr *lsn)
216209
{
217210
XidStatus status = CLOGTransactionIdGetStatus(xid, lsn);
@@ -288,7 +281,6 @@ _PG_fini(void)
288281
PG_MODULE_MAGIC;
289282

290283
PG_FUNCTION_INFO_V1(dtm_begin_transaction);
291-
PG_FUNCTION_INFO_V1(dtm_get_snapshot);
292284

293285
Datum
294286
dtm_begin_transaction(PG_FUNCTION_ARGS)
@@ -308,16 +300,3 @@ dtm_begin_transaction(PG_FUNCTION_ARGS)
308300
}
309301
PG_RETURN_VOID();
310302
}
311-
312-
Datum
313-
dtm_get_snapshot(PG_FUNCTION_ARGS)
314-
{
315-
DtmEnsureConnection();
316-
DtmGlobalGetSnapshot(DtmConn, DtmNodeId, GetCurrentTransactionId(), &DtmSnapshot);
317-
318-
XTM_TRACE("XTM: dtm_get_snapshot \n");
319-
DtmHasSnapshot = true;
320-
DtmGlobalTransaction = true;
321-
PG_RETURN_VOID();
322-
}
323-

contrib/pg_xtm/tests/transfers.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package main
33
import (
44
"fmt"
55
"sync"
6-
"math/rand"
6+
// "math/rand"
77
"github.com/jackc/pgx"
88
)
99

@@ -107,8 +107,8 @@ func transfer(id int, wg *sync.WaitGroup) {
107107
for i := 0; i < N_ITERATIONS; i++ {
108108
//amount := 2*rand.Intn(2) - 1
109109
amount := 1
110-
account1 := rand.Intn(N_ACCOUNTS)
111-
account2 := rand.Intn(N_ACCOUNTS)
110+
account1 := id//rand.Intn(N_ACCOUNTS)
111+
account2 := id//rand.Intn(N_ACCOUNTS)
112112

113113
// strt transaction
114114
exec(conn1, "begin")

src/backend/access/transam/clog.c

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

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

5050
/*

src/backend/storage/ipc/procarray.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -962,12 +962,6 @@ ProcArrayApplyXidAssignment(TransactionId topxid,
962962
LWLockRelease(ProcArrayLock);
963963
}
964964

965-
bool
966-
TransactionIdIsInProgress(TransactionId xid)
967-
{
968-
return TM->IsInProgress(xid);
969-
}
970-
971965
/*
972966
* TransactionIdIsInProgress -- is given transaction running in some backend
973967
*
@@ -995,7 +989,7 @@ TransactionIdIsInProgress(TransactionId xid)
995989
* PGXACT again anyway; see GetNewTransactionId).
996990
*/
997991
bool
998-
TransactionIdIsRunning(TransactionId xid)
992+
TransactionIdIsInProgress(TransactionId xid)
999993
{
1000994
static TransactionId *xids = NULL;
1001995
int nxids = 0;

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;

0 commit comments

Comments
 (0)