Skip to content

Commit 6fae8cd

Browse files
committed
add mtm.poll_node function
1 parent c9e0dd8 commit 6fae8cd

File tree

4 files changed

+29
-2
lines changed

4 files changed

+29
-2
lines changed

contrib/mmts/check-recovery.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
rm -rf /home/knizhnik/postgres_cluster/contrib/mmts/tmp_check/log
1+
rm -rf /home/knizhnik/postgres_cluster/contrib/mmts/tmp_check
22
TESTDIR='/home/knizhnik/postgres_cluster/contrib/mmts' PATH="/home/knizhnik/postgres_cluster/tmp_install/home/knizhnik/postgres_cluster/dist/bin:$PATH" LD_LIBRARY_PATH="/home/knizhnik/postgres_cluster/tmp_install/home/knizhnik/postgres_cluster/dist/lib:$LD_LIBRARY_PATH" PGPORT='65432' PG_REGRESS='/home/knizhnik/postgres_cluster/contrib/mmts/../../src/test/regress/pg_regress' prove -I ../../src/test/perl/ --verbose t/001_basic_recovery.pl

contrib/mmts/multimaster--1.0.sql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ CREATE FUNCTION mtm.dump_lock_graph() RETURNS text
4444
AS 'MODULE_PATHNAME','mtm_dump_lock_graph'
4545
LANGUAGE C;
4646

47+
CREATE FUNCTION mtm.poll_node(nodeId integer, noWait boolean default FALSE) RETURNS boolean
48+
AS 'MODULE_PATHNAME','mtm_poll_node'
49+
LANGUAGE C;
50+
4751
CREATE TABLE IF NOT EXISTS mtm.ddl_log (issued timestamp with time zone not null, query text);
4852

4953
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: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ PG_MODULE_MAGIC;
103103
PG_FUNCTION_INFO_V1(mtm_start_replication);
104104
PG_FUNCTION_INFO_V1(mtm_stop_replication);
105105
PG_FUNCTION_INFO_V1(mtm_drop_node);
106+
PG_FUNCTION_INFO_V1(mtm_poll_node);
106107
PG_FUNCTION_INFO_V1(mtm_recover_node);
107108
PG_FUNCTION_INFO_V1(mtm_get_snapshot);
108109
PG_FUNCTION_INFO_V1(mtm_get_nodes_state);
@@ -2069,6 +2070,27 @@ mtm_drop_node(PG_FUNCTION_ARGS)
20692070
PG_RETURN_VOID();
20702071
}
20712072

2073+
Datum
2074+
mtm_poll_node(PG_FUNCTION_ARGS)
2075+
{
2076+
int nodeId = PG_GETARG_INT32(0);
2077+
bool nowait = PG_GETARG_BOOL(1);
2078+
bool online = true;
2079+
while (BIT_CHECK(Mtm->disabledNodeMask, nodeId-1)) {
2080+
if (nowait) {
2081+
online = false;
2082+
break;
2083+
} else {
2084+
MtmSleep(STATUS_POLL_DELAY);
2085+
}
2086+
}
2087+
if (!nowait) {
2088+
/* Just wait some time until logical repication channels will be reestablished */
2089+
MtmSleep(MtmNodeDisableDelay);
2090+
}
2091+
PG_RETURN_BOOL(online);
2092+
}
2093+
20722094
Datum
20732095
mtm_recover_node(PG_FUNCTION_ARGS)
20742096
{

contrib/mmts/t/001_basic_recovery.pl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@
6060
diag("starting node 2");
6161
$cluster->{nodes}->[2]->start;
6262
diag("sleeping 10");
63-
sleep(10); # XXX: here we can poll
63+
#sleep(10); # XXX: here we can poll
64+
$cluster->psql(0, 'postgres', "select mtm.poll_node(3);");
6465
diag("inserting 3");
6566
$cluster->psql(0, 'postgres', "insert into t values(3, 30);");
6667
diag("selecting");

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