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

Commit 0e79f78

Browse files
knizhnikkelvich
authored andcommitted
add mtm.poll_node function
1 parent b7551e4 commit 0e79f78

File tree

4 files changed

+29
-2
lines changed

4 files changed

+29
-2
lines changed

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

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

multimaster.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ PG_MODULE_MAGIC;
102102
PG_FUNCTION_INFO_V1(mtm_start_replication);
103103
PG_FUNCTION_INFO_V1(mtm_stop_replication);
104104
PG_FUNCTION_INFO_V1(mtm_drop_node);
105+
PG_FUNCTION_INFO_V1(mtm_poll_node);
105106
PG_FUNCTION_INFO_V1(mtm_recover_node);
106107
PG_FUNCTION_INFO_V1(mtm_get_snapshot);
107108
PG_FUNCTION_INFO_V1(mtm_get_nodes_state);
@@ -2068,6 +2069,27 @@ mtm_drop_node(PG_FUNCTION_ARGS)
20682069
PG_RETURN_VOID();
20692070
}
20702071

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

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