Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 535eae1

Browse files
kvapkelvich
authored andcommitted
Add a lock graph dumping function to multimaster sql api.
1 parent 42e0dc0 commit 535eae1

File tree

4 files changed

+34
-4
lines changed

4 files changed

+34
-4
lines changed

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));

multimaster.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ PG_FUNCTION_INFO_V1(mtm_get_snapshot);
107107
PG_FUNCTION_INFO_V1(mtm_get_nodes_state);
108108
PG_FUNCTION_INFO_V1(mtm_get_cluster_state);
109109
PG_FUNCTION_INFO_V1(mtm_make_table_local);
110+
PG_FUNCTION_INFO_V1(mtm_dump_lock_graph);
110111

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

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

21572183
/*
21582184
* -------------------------------------------

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
}

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)