Skip to content

Commit 6247aff

Browse files
committed
Integrate postgres_fdw with pg_tsdtm
1 parent aca7998 commit 6247aff

File tree

25 files changed

+1290
-134
lines changed

25 files changed

+1290
-134
lines changed

contrib/bdr/tests/reinit-mm.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
n_nodes=3
2-
export PATH=/home/knizhnik/postgrespro/cluster_install/bin/:$PATH
2+
export PATH=~/postgrespro/cluster_install/bin/:$PATH
33
ulimit -c unlimited
44
pkill -9 postgres
55
pkill -9 dtmd
@@ -10,7 +10,7 @@ sep=""
1010
for ((i=1;i<=n_nodes;i++))
1111
do
1212
port=$((5431+i))
13-
conn_str="$conn_str${sep}replication=database dbname=postgres host=127.0.0.1 user=knizhnik port=$port sslmode=disable"
13+
conn_str="$conn_str${sep}replication=database dbname=postgres host=127.0.0.1 port=$port sslmode=disable"
1414
sep=","
1515
initdb node$i
1616
done
@@ -35,7 +35,7 @@ echo Initialize database schema
3535
for ((i=1;i<=n_nodes;i++))
3636
do
3737
port=$((5431+i))
38-
psql -p $port postgres -U knizhnik -f init.sql
38+
psql -p $port postgres -f init.sql
3939
done
4040

4141
echo Done

contrib/bdr/tests/run.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
./dtmbench \
2-
-c "dbname=postgres host=localhost user=knizhnik port=5432 sslmode=disable" \
3-
-c "dbname=postgres host=localhost user=knizhnik port=5433 sslmode=disable" \
4-
-c "dbname=postgres host=localhost user=knizhnik port=5434 sslmode=disable" \
2+
-c "dbname=postgres host=localhost port=5432 sslmode=disable" \
3+
-c "dbname=postgres host=localhost port=5433 sslmode=disable" \
4+
-c "dbname=postgres host=localhost port=5434 sslmode=disable" \
55
-n 1000 -a 1000 -w 10 -r 1 $*

contrib/multimaster/multimaster.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ static TransactionId DtmGetGlobalTransactionId(void);
9797

9898
static bool DtmDetectGlobalDeadLock(PGPROC* proc);
9999
static void DtmSerializeLock(PROCLOCK* lock, void* arg);
100+
static char const* DtmGetName(void);
100101

101102
static bool TransactionIdIsInSnapshot(TransactionId xid, Snapshot snapshot);
102103
static bool TransactionIdIsInDoubt(TransactionId xid);
@@ -126,7 +127,8 @@ static TransactionManager DtmTM = {
126127
PgTransactionIdIsInProgress,
127128
DtmGetGlobalTransactionId,
128129
PgXidInMVCCSnapshot,
129-
DtmDetectGlobalDeadLock
130+
DtmDetectGlobalDeadLock,
131+
GtmGetName
130132
};
131133

132134
bool MMDoReplication;
@@ -163,6 +165,11 @@ static BackgroundWorker DtmWorker = {
163165
};
164166

165167

168+
static char const* DtmGetName(void)
169+
{
170+
return "multimaster";
171+
}
172+
166173
static void DumpSnapshot(Snapshot s, char *name)
167174
{
168175
#ifdef DUMP_SNAPSHOT

contrib/multimaster/tests/reinit-mm.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
n_nodes=3
2-
export PATH=/home/knizhnik/postgres_cluster/dist/bin/:$PATH
2+
export PATH=~/postgres_cluster/dist/bin/:$PATH
33
ulimit -c unlimited
44
pkill -9 postgres
55
pkill -9 dtmd
@@ -10,7 +10,7 @@ sep=""
1010
for ((i=1;i<=n_nodes;i++))
1111
do
1212
port=$((5431+i))
13-
conn_str="$conn_str${sep}dbname=postgres host=127.0.0.1 user=knizhnik port=$port sslmode=disable"
13+
conn_str="$conn_str${sep}dbname=postgres host=127.0.0.1 port=$port sslmode=disable"
1414
sep=","
1515
initdb node$i
1616
done
@@ -32,6 +32,6 @@ done
3232

3333
sleep 5
3434
echo Initialize database schema
35-
psql postgres -U knizhnik -f init.sql
35+
psql postgres -f init.sql
3636

3737
echo Done

contrib/multimaster/tests/run.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
./dtmbench \
2-
-c "dbname=postgres host=localhost user=knizhnik port=5432 sslmode=disable" \
3-
-c "dbname=postgres host=localhost user=knizhnik port=5433 sslmode=disable" \
4-
-c "dbname=postgres host=localhost user=knizhnik port=5434 sslmode=disable" \
2+
-c "dbname=postgres host=localhost port=5432 sslmode=disable" \
3+
-c "dbname=postgres host=localhost port=5433 sslmode=disable" \
4+
-c "dbname=postgres host=localhost port=5434 sslmode=disable" \
55
-n 1000 -a 1000 -w 10 -r 1 $*

contrib/pg_dtm/pg_dtm.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ static TransactionId DtmGetGlobalTransactionId(void);
8383

8484
static bool DtmDetectGlobalDeadLock(PGPROC* proc);
8585
static void DtmSerializeLock(PROCLOCK* lock, void* arg);
86+
static char const* DtmGetName(void);
8687

8788
static bool TransactionIdIsInSnapshot(TransactionId xid, Snapshot snapshot);
8889
static bool TransactionIdIsInDoubt(TransactionId xid);
@@ -116,7 +117,8 @@ static TransactionManager DtmTM = {
116117
PgTransactionIdIsInProgress,
117118
DtmGetGlobalTransactionId,
118119
PgXidInMVCCSnapshot,
119-
DtmDetectGlobalDeadLock
120+
DtmDetectGlobalDeadLock,
121+
GtmGetName
120122
};
121123

122124
static char *DtmServers;
@@ -135,6 +137,12 @@ static BackgroundWorker DtmWorker = {
135137
//#define XTM_INFO(fmt, ...) fprintf(stderr, fmt, ## __VA_ARGS__)
136138
#define XTM_INFO(fmt, ...)
137139

140+
static char const* DtmGetName(void)
141+
{
142+
return "pg_dtm";
143+
}
144+
145+
138146
static void DumpSnapshot(Snapshot s, char *name)
139147
{
140148
int i;

contrib/pg_multimaster/tests/reinit-mm.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
n_nodes=3
2-
export PATH=/home/knizhnik/postgres_cluster/dist/bin/:$PATH
2+
export PATH=~/postgres_cluster/dist/bin/:$PATH
33
ulimit -c unlimited
44
pkill -9 postgres
55
pkill -9 dtmd
@@ -10,7 +10,7 @@ sep=""
1010
for ((i=1;i<=n_nodes;i++))
1111
do
1212
port=$((5431+i))
13-
conn_str="$conn_str${sep}dbname=postgres host=127.0.0.1 user=knizhnik port=$port sslmode=disable"
13+
conn_str="$conn_str${sep}dbname=postgres host=127.0.0.1 port=$port sslmode=disable"
1414
sep=","
1515
initdb node$i
1616
done
@@ -32,6 +32,6 @@ done
3232

3333
sleep 5
3434
echo Initialize database schema
35-
psql postgres -U knizhnik -f init.sql
35+
psql postgres -f init.sql
3636

3737
echo Done

contrib/pg_multimaster/tests/run.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
./dtmbench \
2-
-c "dbname=postgres host=localhost user=knizhnik port=5432 sslmode=disable" \
3-
-c "dbname=postgres host=localhost user=knizhnik port=5433 sslmode=disable" \
4-
-c "dbname=postgres host=localhost user=knizhnik port=5434 sslmode=disable" \
2+
-c "dbname=postgres host=localhost port=5432 sslmode=disable" \
3+
-c "dbname=postgres host=localhost port=5433 sslmode=disable" \
4+
-c "dbname=postgres host=localhost port=5434 sslmode=disable" \
55
-n 1000 -a 1000 -w 10 -r 1 $*

contrib/pg_shard/bench/dtmbench.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ void initializeDatabase()
158158
exec(txn, "CREATE EXTENSION pg_shard");
159159
exec(txn, "create table t(u int primary key, v int)");
160160
exec(txn, "SELECT master_create_distributed_table(table_name := 't', partition_column := 'u')");
161-
exec(txn, "SELECT master_create_worker_shards(table_name := 't', shard_count := 16, replication_factor := 1)");
161+
exec(txn, "SELECT master_create_worker_shards(table_name := 't', shard_count := 100, replication_factor := 1)");
162162
for (int i = 0; i < cfg.nAccounts; i++) {
163163
exec(txn, "insert into t values (%d,0)", i);
164164
}

contrib/pg_shard/bench/reinit-pg_shard.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
n_shards=3
2-
export PATH=/home/knizhnik/postgres_cluster/dist/bin/:$PATH
2+
export PATH=~/postgres_cluster/dist/bin/:$PATH
33
ulimit -c unlimited
44
pkill -9 postgres
55
sleep 2
@@ -33,7 +33,7 @@ sleep 5
3333
for ((i=1;i<=n_shards;i++))
3434
do
3535
port=$((5432+i))
36-
psql -p $port postgres -U knizhnik -c "create extension pg_dtm"
36+
psql -p $port postgres -c "create extension pg_dtm"
3737
done
3838

3939
echo Done

contrib/pg_shard/bench/run.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
./dtmbench \
2-
-c "dbname=postgres host=localhost user=knizhnik port=5432 sslmode=disable" \
2+
-c "dbname=postgres host=localhost port=5432 sslmode=disable" \
33
-n 1000 -a 10000 -w 10 -r 1 $*

contrib/pg_shard/src/pg_shard.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,10 @@ static csn_t currentGlobalTransactionId = 0;
184184
static int currentLocalTransactionId = 0;
185185
static bool commitCallbackSet = false;
186186

187+
/*
187188
#define TRACE(fmt, ...) fprintf(stderr, fmt, ## __VA_ARGS__)
189+
*/
190+
#define TRACE(fmt, ...)
188191

189192
/*
190193
* _PG_init is called when the module is loaded. In this function we save the

contrib/pg_tsdtm/pg_dtm.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,9 @@ static TransactionId DtmAdjustOldestXid(TransactionId xid);
9191
static bool DtmDetectGlobalDeadLock(PGPROC* proc);
9292
static cid_t DtmGetCsn(TransactionId xid);
9393
static void DtmAddSubtransactions(DtmTransStatus* ts, TransactionId* subxids, int nSubxids);
94+
static char const* DtmGetName(void);
9495

95-
static TransactionManager DtmTM = { PgTransactionIdGetStatus, PgTransactionIdSetTreeStatus, DtmGetSnapshot, PgGetNewTransactionId, DtmGetOldestXmin, PgTransactionIdIsInProgress, PgGetGlobalTransactionId, DtmXidInMVCCSnapshot, DtmDetectGlobalDeadLock };
96+
static TransactionManager DtmTM = { PgTransactionIdGetStatus, PgTransactionIdSetTreeStatus, DtmGetSnapshot, PgGetNewTransactionId, DtmGetOldestXmin, PgTransactionIdIsInProgress, PgGetGlobalTransactionId, DtmXidInMVCCSnapshot, DtmDetectGlobalDeadLock, DtmGetName };
9697

9798
void _PG_init(void);
9899
void _PG_fini(void);
@@ -419,6 +420,11 @@ static int dtm_gtid_match_fn(const void *key1, const void *key2, Size keysize)
419420
return strcmp((GlobalTransactionId)key1, (GlobalTransactionId)key2);
420421
}
421422

423+
static char const* DtmGetName(void)
424+
{
425+
return "pg_tsdtm";
426+
}
427+
422428
static void DtmTransactionListAppend(DtmTransStatus* ts)
423429
{
424430
ts->next = NULL;

contrib/pg_tsdtm/tests/perf/run.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
go run *.go \
2-
-C "dbname=postgres user=knizhnik port=5432 sslmode=disable" \
3-
-C "dbname=postgres user=knizhnik port=5433 sslmode=disable" \
4-
-C "dbname=postgres user=knizhnik port=5434 sslmode=disable" \
2+
-C "dbname=postgres port=5432 sslmode=disable" \
3+
-C "dbname=postgres port=5433 sslmode=disable" \
4+
-C "dbname=postgres port=5434 sslmode=disable" \
55
-g -n 1000 -a 1000 -w 10 -r 1 $*

contrib/pg_tsdtm/tests/run.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
./dtmbench \
2-
-c "dbname=postgres host=localhost user=knizhnik port=5432 sslmode=disable" \
3-
-c "dbname=postgres host=localhost user=knizhnik port=5433 sslmode=disable" \
4-
-c "dbname=postgres host=localhost user=knizhnik port=5434 sslmode=disable" \
2+
-c "dbname=postgres host=localhost port=5432 sslmode=disable" \
3+
-c "dbname=postgres host=localhost port=5433 sslmode=disable" \
4+
-c "dbname=postgres host=localhost port=5434 sslmode=disable" \
55
-n 1000 -a 10000 -d 10000 -w 10 -r 1 $*
66

0 commit comments

Comments
 (0)