Skip to content

Commit df68923

Browse files
committed
Add a lock graph dumping function to multimaster sql api.
1 parent b1937fb commit df68923

File tree

4 files changed

+34
-4
lines changed

4 files changed

+34
-4
lines changed

contrib/mmts/multimaster--1.0.sql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ CREATE FUNCTION mtm.make_table_local(relation regclass) RETURNS void
4040
AS 'MODULE_PATHNAME','mtm_make_table_local'
4141
LANGUAGE C;
4242

43+
CREATE FUNCTION mtm.dump_lock_graph() RETURNS text
44+
AS 'MODULE_PATHNAME','mtm_dump_lock_graph'
45+
LANGUAGE C;
46+
4347
CREATE TABLE IF NOT EXISTS mtm.ddl_log (issued timestamp with time zone not null, query text);
4448

4549
CREATE TABLE IF NOT EXISTS mtm.local_tables(rel_schema text, rel_name text, primary key(rel_schema, rel_name));

contrib/mmts/multimaster.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ PG_FUNCTION_INFO_V1(mtm_get_snapshot);
108108
PG_FUNCTION_INFO_V1(mtm_get_nodes_state);
109109
PG_FUNCTION_INFO_V1(mtm_get_cluster_state);
110110
PG_FUNCTION_INFO_V1(mtm_make_table_local);
111+
PG_FUNCTION_INFO_V1(mtm_dump_lock_graph);
111112

112113
static Snapshot MtmGetSnapshot(Snapshot snapshot);
113114
static void MtmInitialize(void);
@@ -2154,6 +2155,31 @@ Datum mtm_make_table_local(PG_FUNCTION_ARGS)
21542155
return false;
21552156
}
21562157

2158+
Datum mtm_dump_lock_graph(PG_FUNCTION_ARGS)
2159+
{
2160+
StringInfo s = makeStringInfo();
2161+
int i;
2162+
for (i = 0; i < MtmNodes; i++)
2163+
{
2164+
size_t size;
2165+
char *data = RaftableGet(psprintf("lock-graph-%d", i+1), &size, NULL, true);
2166+
if (!data) continue;
2167+
GlobalTransactionId *gtid = (GlobalTransactionId *)data;
2168+
GlobalTransactionId *last = (GlobalTransactionId *)(data + size);
2169+
appendStringInfo(s, "node-%d lock graph: ", i+1);
2170+
while (gtid != last) {
2171+
GlobalTransactionId *src = gtid++;
2172+
appendStringInfo(s, "%d:%d -> ", src->node, src->xid);
2173+
while (gtid->node != 0) {
2174+
GlobalTransactionId *dst = gtid++;
2175+
appendStringInfo(s, "%d:%d, ", dst->node, dst->xid);
2176+
}
2177+
gtid += 1;
2178+
}
2179+
appendStringInfo(s, "\n");
2180+
}
2181+
return CStringGetTextDatum(s->data);
2182+
}
21572183

21582184
/*
21592185
* -------------------------------------------

contrib/mmts/t/002_dtmbench.pl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ sub allocate_ports
6060
listen_addresses = '$host'
6161
unix_socket_directories = ''
6262
port = $pgport
63-
max_prepared_transactions = 10
63+
max_prepared_transactions = 1000
6464
max_worker_processes = 10
6565
wal_level = logical
6666
fsync = off
@@ -103,13 +103,13 @@ sub allocate_ports
103103
push(@argv, '-n', 1000, '-a', 1000, '-w', 10, '-r', 1);
104104

105105
diag("running dtmbench -i");
106-
if (TestLib::run_log([@argv, '-i']))
106+
if (!TestLib::run_log([@argv, '-i']))
107107
{
108108
BAIL_OUT("dtmbench -i failed");
109109
}
110110

111111
diag("running dtmbench");
112-
if (TestLib::run_log(\@argv, '>', \$out))
112+
if (!TestLib::run_log(\@argv, '>', \$out))
113113
{
114114
fail("dtmbench failed");
115115
}

contrib/mmts/t/003_pgbench.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ sub allocate_ports
6262
listen_addresses = '$host'
6363
unix_socket_directories = ''
6464
port = $pgport
65-
max_prepared_transactions = 10
65+
max_prepared_transactions = 1000
6666
max_worker_processes = 10
6767
wal_level = logical
6868
fsync = off

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