Skip to content

Commit 9f63dea

Browse files
committed
A version without locks (still with inconsistency).
1 parent c501386 commit 9f63dea

File tree

4 files changed

+1
-39
lines changed

4 files changed

+1
-39
lines changed

contrib/pg_xtm/pg_dtm--1.0.sql

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,3 @@ LANGUAGE C;
88
CREATE FUNCTION dtm_get_snapshot() RETURNS void
99
AS 'MODULE_PATHNAME','dtm_get_snapshot'
1010
LANGUAGE C;
11-
12-
CREATE FUNCTION dtm_lock() RETURNS void
13-
AS 'MODULE_PATHNAME','dtm_lock'
14-
LANGUAGE C;
15-
16-
CREATE FUNCTION dtm_unlock() RETURNS void
17-
AS 'MODULE_PATHNAME','dtm_unlock'
18-
LANGUAGE C;

contrib/pg_xtm/pg_dtm.c

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,6 @@ PG_MODULE_MAGIC;
233233

234234
PG_FUNCTION_INFO_V1(dtm_begin_transaction);
235235
PG_FUNCTION_INFO_V1(dtm_get_snapshot);
236-
PG_FUNCTION_INFO_V1(dtm_lock);
237-
PG_FUNCTION_INFO_V1(dtm_unlock);
238236

239237
Datum
240238
dtm_begin_transaction(PG_FUNCTION_ARGS)
@@ -254,9 +252,7 @@ Datum
254252
dtm_get_snapshot(PG_FUNCTION_ARGS)
255253
{
256254
DtmEnsureConnection();
257-
LWLockAcquire(DtmLock, LW_EXCLUSIVE);
258255
DtmGlobalGetSnapshot(DtmConn, DtmNodeId, GetCurrentTransactionId(), &DtmSnapshot);
259-
LWLockRelease(DtmLock);
260256

261257
// VacuumProcArray(&DtmSnapshot);
262258

@@ -267,16 +263,3 @@ dtm_get_snapshot(PG_FUNCTION_ARGS)
267263
PG_RETURN_VOID();
268264
}
269265

270-
Datum
271-
dtm_lock(PG_FUNCTION_ARGS)
272-
{
273-
LWLockAcquire(DtmLock, LW_EXCLUSIVE);
274-
PG_RETURN_VOID();
275-
}
276-
277-
Datum
278-
dtm_unlock(PG_FUNCTION_ARGS)
279-
{
280-
LWLockRelease(DtmLock);
281-
PG_RETURN_VOID();
282-
}

contrib/pg_xtm/tests/transfers.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@ func prepare_db() {
6565
exec(conn2, "create table t(u int primary key, v int)")
6666

6767
// strt transaction
68-
exec(conn1, "select dtm_lock()")
69-
exec(conn2, "select dtm_lock()")
7068
exec(conn1, "begin")
7169
exec(conn2, "begin")
7270

@@ -76,8 +74,6 @@ func prepare_db() {
7674

7775
// register global transaction in DTMD
7876
exec(conn1, "select dtm_begin_transaction($1, $2)", nodes, xids)
79-
exec(conn1, "select dtm_unlock()")
80-
exec(conn2, "select dtm_unlock()")
8177

8278
// first global statement
8379
exec(conn1, "select dtm_get_snapshot()")
@@ -117,8 +113,6 @@ func transfer(id int, wg *sync.WaitGroup) {
117113
account2 := rand.Intn(N_ACCOUNTS)
118114

119115
// strt transaction
120-
exec(conn1, "select dtm_lock()")
121-
exec(conn2, "select dtm_lock()")
122116
exec(conn1, "begin")
123117
exec(conn2, "begin")
124118

@@ -128,8 +122,6 @@ func transfer(id int, wg *sync.WaitGroup) {
128122

129123
// register global transaction in DTMD
130124
exec(conn1, "select dtm_begin_transaction($1, $2)", nodes, xids)
131-
exec(conn1, "select dtm_unlock()")
132-
exec(conn2, "select dtm_unlock()")
133125

134126
// first global statement
135127
exec(conn1, "select dtm_get_snapshot()")
@@ -160,8 +152,6 @@ func total() int32 {
160152
defer conn2.Close()
161153

162154
for {
163-
exec(conn1, "select dtm_lock()")
164-
exec(conn2, "select dtm_lock()")
165155
exec(conn1, "begin")
166156
exec(conn2, "begin")
167157

@@ -171,8 +161,6 @@ func total() int32 {
171161

172162
// register global transaction in DTMD
173163
exec(conn1, "select dtm_begin_transaction($1, $2)", nodes, xids)
174-
exec(conn1, "select dtm_unlock()")
175-
exec(conn2, "select dtm_unlock()")
176164

177165
exec(conn1, "select dtm_get_snapshot()")
178166
exec(conn2, "select dtm_get_snapshot()")

src/include/storage/lwlock.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,8 @@ extern PGDLLIMPORT LWLockPadded *MainLWLockArray;
139139
#define CommitTsControlLock (&MainLWLockArray[38].lock)
140140
#define CommitTsLock (&MainLWLockArray[39].lock)
141141
#define ReplicationOriginLock (&MainLWLockArray[40].lock)
142-
#define DtmLock (&MainLWLockArray[41].lock)
143142

144-
#define NUM_INDIVIDUAL_LWLOCKS 42
143+
#define NUM_INDIVIDUAL_LWLOCKS 41
145144

146145
/*
147146
* It's a bit odd to declare NUM_BUFFER_PARTITIONS and NUM_LOCK_PARTITIONS

0 commit comments

Comments
 (0)