Skip to content

Commit 82b8301

Browse files
committed
Make it possible to switch off DTM
1 parent 6fae8cd commit 82b8301

File tree

5 files changed

+45
-45
lines changed

5 files changed

+45
-45
lines changed

contrib/mmts/multimaster.c

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ int MtmKeepaliveTimeout;
182182
int MtmReconnectAttempts;
183183
int MtmNodeDisableDelay;
184184
bool MtmUseRaftable;
185+
bool MtmUseDtm;
185186
MtmConnectionInfo* MtmConnections;
186187

187188
static char* MtmConnStrs;
@@ -340,7 +341,7 @@ TransactionId MtmGetOldestXmin(Relation rel, bool ignoreVacuum)
340341
}
341342

342343
bool MtmXidInMVCCSnapshot(TransactionId xid, Snapshot snapshot)
343-
{
344+
{
344345
#if TRACE_SLEEP_TIME
345346
static timestamp_t firstReportTime;
346347
static timestamp_t prevReportTime;
@@ -350,6 +351,10 @@ bool MtmXidInMVCCSnapshot(TransactionId xid, Snapshot snapshot)
350351
timestamp_t delay = MIN_WAIT_TIMEOUT;
351352
Assert(xid != InvalidTransactionId);
352353

354+
if (!MtmUseDtm) {
355+
return PgXidInMVCCSnapshot(xid, snapshot);
356+
}
357+
353358
MtmLock(LW_SHARED);
354359

355360
#if TRACE_SLEEP_TIME
@@ -769,7 +774,7 @@ MtmPostPrepareTransaction(MtmCurrentTrans* x)
769774
tm->state = ts;
770775
ts->votingCompleted = true;
771776
if (Mtm->status != MTM_RECOVERY) {
772-
MtmSendNotificationMessage(ts, MSG_READY); /* send notification to coordinator */
777+
MtmSendNotificationMessage(ts, MtmUseDtm ? MSG_READY : MSG_PREPARED); /* send notification to coordinator */
773778
} else {
774779
ts->status = TRANSACTION_STATUS_UNKNOWN;
775780
}
@@ -1652,6 +1657,19 @@ _PG_init(void)
16521657
NULL
16531658
);
16541659

1660+
DefineCustomBoolVariable(
1661+
"multimaster.use_dtm",
1662+
"Use distributed transaction manager",
1663+
NULL,
1664+
&MtmUseDtm,
1665+
true,
1666+
PGC_BACKEND,
1667+
0,
1668+
NULL,
1669+
NULL,
1670+
NULL
1671+
);
1672+
16551673
DefineCustomIntVariable(
16561674
"multimaster.workers",
16571675
"Number of multimaster executor workers per node",

contrib/mmts/multimaster.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
#include "pglogical_output/hooks.h"
99

10-
#define DEBUG_LEVEL 1
10+
#define DEBUG_LEVEL 0
1111

1212
#if DEBUG_LEVEL == 0
1313
#define MTM_LOG1(fmt, ...) elog(LOG, fmt, ## __VA_ARGS__)
@@ -191,6 +191,7 @@ extern int MtmConnectTimeout;
191191
extern int MtmReconnectAttempts;
192192
extern int MtmKeepaliveTimeout;
193193
extern int MtmNodeDisableDelay;
194+
extern bool MtmUseDtm;
194195
extern HTAB* MtmXid2State;
195196

196197
extern MtmConnectionInfo* MtmConnections;

contrib/mmts/tests/deploy_layouts/cluster.yml

Lines changed: 9 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,5 @@
11
---
22

3-
- hosts: nodes[0]
4-
5-
roles:
6-
- role: postgres
7-
pg_port: 15432
8-
pg_repo: https://github.com/postgrespro/postgres_cluster.git
9-
pg_version_tag: master
10-
pg_destroy_and_init: true
11-
12-
tasks:
13-
- name: build sockhub
14-
shell: "make clean && make -j 4"
15-
args:
16-
chdir: "~/pg_cluster/src/contrib/arbiter/sockhub"
17-
18-
- name: build dtm
19-
shell: "make clean && make -j 4"
20-
args:
21-
chdir: "~/pg_cluster/src/contrib/arbiter"
22-
# when: dtm_sources.changed
23-
24-
- name: kill arbiter
25-
shell: kill -9 `cat ~/pg_cluster/dtm_data/arbiter.pid` || true
26-
27-
- name: ensure datadir for dtm exists
28-
shell: "rm -rf ~/pg_cluster/dtm_data && mkdir ~/pg_cluster/dtm_data"
29-
30-
- name: start dtm
31-
shell: >
32-
nohup ~/pg_cluster/src/contrib/arbiter/bin/arbiter
33-
-d ~/pg_cluster/dtm_data -r 0.0.0.0:5431 -i 0 -l ~/pg_cluster/dtm_data/log &
34-
35-
- name: wait until dtm is available
36-
wait_for: port=5431 delay=1
37-
38-
393
- hosts: nodes[1]:nodes[2]:nodes[3]
404
# accelerate: true
415

@@ -61,10 +25,10 @@
6125
set_fact:
6226
connections: "{{ connstrs.results | map(attribute='ansible_facts.connstr') | join(', ') }}"
6327

64-
- name: build sockhub
65-
shell: "make clean && make -j 4"
28+
- name: build raftable
29+
shell: "make clean && make -j {{makejobs}} install"
6630
args:
67-
chdir: "{{pg_src}}/contrib/arbiter/sockhub"
31+
chdir: "{{pg_src}}/contrib/raftable"
6832

6933
- name: build multimaster
7034
shell: "make clean && make -j {{makejobs}} install"
@@ -81,13 +45,17 @@
8145
- "max_wal_senders = 10"
8246
- "wal_sender_timeout = 0"
8347
- "max_replication_slots = 10"
48+
- "max_connections = 200"
8449
- "max_worker_processes = 100"
85-
- "shared_preload_libraries = 'multimaster'"
86-
- "multimaster.arbiters = '{{groups['nodes'][0]}}:5431'"
50+
- "shared_preload_libraries = 'raftable,multimaster'"
8751
- "multimaster.conn_strings = '{{connections}}'"
8852
- "multimaster.node_id = {{ node_id }}"
53+
- "multimaster.buffer_size = 65536"
8954
- "multimaster.queue_size = 1073741824"
55+
- "multimaster.arbiter_port = 5600"
56+
- "multimaster.vacuum_delay = 1"
9057
- "multimaster.workers = 32"
58+
- "multimaster.use_dtm = 0"
9159

9260
- name: restart postgrespro
9361
command: "{{pg_dst}}/bin/pg_ctl restart -w -D {{pg_datadir}} -l {{pg_datadir}}/pg.log"

contrib/mmts/tests/perf.results

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,3 +138,16 @@ Bench finished at Пн. февр. 15 18:37:50 MSK 2016
138138
Bench started at Пн. февр. 15 18:44:02 MSK 2016
139139
astro5:{tps:121774.204222, transactions:100000000, selects:200000000, updates:0, aborts:0, abort_percent: 0, readers:0, writers:200, update_percent:0, accounts:500000, iterations:500000, hosts:3}
140140
Bench finished at Пн. февр. 15 18:57:44 MSK 2016
141+
Bench started at Ср. апр. 13 13:52:07 MSK 2016
142+
143+
Bench finished at Ср. апр. 13 13:52:07 MSK 2016
144+
Bench started at Ср. апр. 13 13:52:45 MSK 2016
145+
Bench started at Ср. апр. 13 14:03:54 MSK 2016
146+
astro5:{tps:115156.025890, transactions:50000000, selects:100000000, updates:0, aborts:0, abort_percent: 0, readers:0, writers:100, update_percent:0, accounts:500000, iterations:500000, hosts:3}
147+
Bench finished at Ср. апр. 13 14:11:09 MSK 2016
148+
Bench started at Ср. апр. 13 14:13:55 MSK 2016
149+
astro5:{tps:16576.973635, transactions:1000000, selects:0, updates:2000758, aborts:820, abort_percent: 0, readers:0, writers:100, update_percent:100, accounts:500000, iterations:10000, hosts:3}
150+
Bench finished at Ср. апр. 13 14:14:56 MSK 2016
151+
Bench started at Ср. апр. 13 14:23:33 MSK 2016
152+
astro5:{tps:16078.719352, transactions:1000000, selects:0, updates:2000802, aborts:788, abort_percent: 0, readers:0, writers:100, update_percent:100, accounts:500000, iterations:10000, hosts:3}
153+
Bench finished at Ср. апр. 13 14:24:36 MSK 2016

contrib/mmts/tests/perf.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
- name: run transfers
4747
shell: >
4848
~/pg_cluster/install/bin/dtmbench {{connections}}
49-
-w {{ nconns }} -r 0 -n 500000 -a 500000 -p {{ up }} |
49+
-w {{ nconns }} -r 0 -n 10000 -a 500000 -p {{ up }} |
5050
tee -a perf.results |
5151
sed "s/^/`hostname`:/"
5252
register: transfers_result

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy