mirror of https://github.com/citusdata/citus.git
Add master_add_secondary_node() UDF
parent
3f338a3fc6
commit
2e0916e15a
|
@ -11,7 +11,7 @@ EXTVERSIONS = 5.0 5.0-1 5.0-2 \
|
||||||
6.0-1 6.0-2 6.0-3 6.0-4 6.0-5 6.0-6 6.0-7 6.0-8 6.0-9 6.0-10 6.0-11 6.0-12 6.0-13 6.0-14 6.0-15 6.0-16 6.0-17 6.0-18 \
|
6.0-1 6.0-2 6.0-3 6.0-4 6.0-5 6.0-6 6.0-7 6.0-8 6.0-9 6.0-10 6.0-11 6.0-12 6.0-13 6.0-14 6.0-15 6.0-16 6.0-17 6.0-18 \
|
||||||
6.1-1 6.1-2 6.1-3 6.1-4 6.1-5 6.1-6 6.1-7 6.1-8 6.1-9 6.1-10 6.1-11 6.1-12 6.1-13 6.1-14 6.1-15 6.1-16 6.1-17 \
|
6.1-1 6.1-2 6.1-3 6.1-4 6.1-5 6.1-6 6.1-7 6.1-8 6.1-9 6.1-10 6.1-11 6.1-12 6.1-13 6.1-14 6.1-15 6.1-16 6.1-17 \
|
||||||
6.2-1 6.2-2 6.2-3 6.2-4 \
|
6.2-1 6.2-2 6.2-3 6.2-4 \
|
||||||
7.0-1 7.0-2 7.0-3 7.0-4 7.0-5 7.0-6 7.0-7 7.0-8 7.0-9
|
7.0-1 7.0-2 7.0-3 7.0-4 7.0-5 7.0-6 7.0-7 7.0-8 7.0-9 7.0-10
|
||||||
|
|
||||||
# All citus--*.sql files in the source directory
|
# All citus--*.sql files in the source directory
|
||||||
DATA = $(patsubst $(citus_abs_srcdir)/%.sql,%.sql,$(wildcard $(citus_abs_srcdir)/$(EXTENSION)--*--*.sql))
|
DATA = $(patsubst $(citus_abs_srcdir)/%.sql,%.sql,$(wildcard $(citus_abs_srcdir)/$(EXTENSION)--*--*.sql))
|
||||||
|
@ -157,6 +157,8 @@ $(EXTENSION)--7.0-8.sql: $(EXTENSION)--7.0-7.sql $(EXTENSION)--7.0-7--7.0-8.sql
|
||||||
cat $^ > $@
|
cat $^ > $@
|
||||||
$(EXTENSION)--7.0-9.sql: $(EXTENSION)--7.0-8.sql $(EXTENSION)--7.0-8--7.0-9.sql
|
$(EXTENSION)--7.0-9.sql: $(EXTENSION)--7.0-8.sql $(EXTENSION)--7.0-8--7.0-9.sql
|
||||||
cat $^ > $@
|
cat $^ > $@
|
||||||
|
$(EXTENSION)--7.0-10.sql: $(EXTENSION)--7.0-9.sql $(EXTENSION)--7.0-9--7.0-10.sql
|
||||||
|
cat $^ > $@
|
||||||
|
|
||||||
NO_PGXS = 1
|
NO_PGXS = 1
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
/* citus-7.0-9--7.0-10 */
|
||||||
|
|
||||||
|
SET search_path = 'pg_catalog';
|
||||||
|
|
||||||
|
CREATE FUNCTION master_add_secondary_node(nodename text,
|
||||||
|
nodeport integer,
|
||||||
|
primaryname text,
|
||||||
|
primaryport integer,
|
||||||
|
nodecluster name default 'default',
|
||||||
|
OUT nodeid integer,
|
||||||
|
OUT groupid integer,
|
||||||
|
OUT nodename text,
|
||||||
|
OUT nodeport integer,
|
||||||
|
OUT noderack text,
|
||||||
|
OUT hasmetadata boolean,
|
||||||
|
OUT isactive bool,
|
||||||
|
OUT noderole noderole,
|
||||||
|
OUT nodecluster name)
|
||||||
|
RETURNS record
|
||||||
|
LANGUAGE C STRICT
|
||||||
|
AS 'MODULE_PATHNAME', $$master_add_secondary_node$$;
|
||||||
|
COMMENT ON FUNCTION master_add_secondary_node(nodename text, nodeport integer,
|
||||||
|
primaryname text, primaryport integer,
|
||||||
|
nodecluster name)
|
||||||
|
IS 'add a secondary node to the cluster';
|
||||||
|
|
||||||
|
RESET search_path;
|
|
@ -1,6 +1,6 @@
|
||||||
# Citus extension
|
# Citus extension
|
||||||
comment = 'Citus distributed database'
|
comment = 'Citus distributed database'
|
||||||
default_version = '7.0-9'
|
default_version = '7.0-10'
|
||||||
module_pathname = '$libdir/citus'
|
module_pathname = '$libdir/citus'
|
||||||
relocatable = false
|
relocatable = false
|
||||||
schema = pg_catalog
|
schema = pg_catalog
|
||||||
|
|
|
@ -75,6 +75,7 @@ static WorkerNode * TupleToWorkerNode(TupleDesc tupleDescriptor, HeapTuple heapT
|
||||||
/* declarations for dynamic loading */
|
/* declarations for dynamic loading */
|
||||||
PG_FUNCTION_INFO_V1(master_add_node);
|
PG_FUNCTION_INFO_V1(master_add_node);
|
||||||
PG_FUNCTION_INFO_V1(master_add_inactive_node);
|
PG_FUNCTION_INFO_V1(master_add_inactive_node);
|
||||||
|
PG_FUNCTION_INFO_V1(master_add_secondary_node);
|
||||||
PG_FUNCTION_INFO_V1(master_remove_node);
|
PG_FUNCTION_INFO_V1(master_remove_node);
|
||||||
PG_FUNCTION_INFO_V1(master_disable_node);
|
PG_FUNCTION_INFO_V1(master_disable_node);
|
||||||
PG_FUNCTION_INFO_V1(master_activate_node);
|
PG_FUNCTION_INFO_V1(master_activate_node);
|
||||||
|
@ -169,6 +170,41 @@ master_add_inactive_node(PG_FUNCTION_ARGS)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* master_add_secondary_node adds a new secondary node to the cluster. It accepts as
|
||||||
|
* arguments the primary node it should share a group with.
|
||||||
|
*/
|
||||||
|
Datum
|
||||||
|
master_add_secondary_node(PG_FUNCTION_ARGS)
|
||||||
|
{
|
||||||
|
text *nodeName = PG_GETARG_TEXT_P(0);
|
||||||
|
int32 nodePort = PG_GETARG_INT32(1);
|
||||||
|
char *nodeNameString = text_to_cstring(nodeName);
|
||||||
|
|
||||||
|
text *primaryName = PG_GETARG_TEXT_P(2);
|
||||||
|
int32 primaryPort = PG_GETARG_INT32(3);
|
||||||
|
char *primaryNameString = text_to_cstring(primaryName);
|
||||||
|
int32 groupId = GroupForNode(primaryNameString, primaryPort);
|
||||||
|
|
||||||
|
Oid nodeRole = SecondaryNodeRoleId();
|
||||||
|
Name nodeClusterName = PG_GETARG_NAME(4);
|
||||||
|
char *nodeClusterString = NameStr(*nodeClusterName);
|
||||||
|
char *nodeRack = WORKER_DEFAULT_RACK;
|
||||||
|
bool hasMetadata = false;
|
||||||
|
bool isActive = true;
|
||||||
|
bool nodeAlreadyExists = false;
|
||||||
|
Datum nodeRecord;
|
||||||
|
|
||||||
|
CheckCitusVersion(ERROR);
|
||||||
|
|
||||||
|
nodeRecord = AddNodeMetadata(nodeNameString, nodePort, groupId, nodeRack,
|
||||||
|
hasMetadata, isActive, nodeRole, nodeClusterString,
|
||||||
|
&nodeAlreadyExists);
|
||||||
|
|
||||||
|
PG_RETURN_DATUM(nodeRecord);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* master_remove_node function removes the provided node from the pg_dist_node table of
|
* master_remove_node function removes the provided node from the pg_dist_node table of
|
||||||
* the master node and all nodes with metadata.
|
* the master node and all nodes with metadata.
|
||||||
|
|
|
@ -537,3 +537,24 @@ SELECT * FROM pg_dist_node WHERE nodeport=8887;
|
||||||
|
|
||||||
-- don't remove the secondary and unavailable nodes, check that no commands are sent to
|
-- don't remove the secondary and unavailable nodes, check that no commands are sent to
|
||||||
-- them in any of the remaining tests
|
-- them in any of the remaining tests
|
||||||
|
-- master_add_secondary_node lets you skip looking up the groupid
|
||||||
|
SELECT master_add_secondary_node('localhost', 9995, 'localhost', :worker_1_port);
|
||||||
|
master_add_secondary_node
|
||||||
|
------------------------------------------------------
|
||||||
|
(22,12,localhost,9995,default,f,t,secondary,default)
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT master_add_secondary_node('localhost', 9994, primaryname => 'localhost', primaryport => :worker_2_port);
|
||||||
|
master_add_secondary_node
|
||||||
|
------------------------------------------------------
|
||||||
|
(23,14,localhost,9994,default,f,t,secondary,default)
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT master_add_secondary_node('localhost', 9993, 'localhost', 2000);
|
||||||
|
ERROR: node at "localhost:2000" does not exist
|
||||||
|
SELECT master_add_secondary_node('localhost', 9992, 'localhost', :worker_1_port, nodecluster => 'second-cluster');
|
||||||
|
master_add_secondary_node
|
||||||
|
-------------------------------------------------------------
|
||||||
|
(24,12,localhost,9992,default,f,t,secondary,second-cluster)
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
|
|
@ -119,6 +119,7 @@ ALTER EXTENSION citus UPDATE TO '7.0-6';
|
||||||
ALTER EXTENSION citus UPDATE TO '7.0-7';
|
ALTER EXTENSION citus UPDATE TO '7.0-7';
|
||||||
ALTER EXTENSION citus UPDATE TO '7.0-8';
|
ALTER EXTENSION citus UPDATE TO '7.0-8';
|
||||||
ALTER EXTENSION citus UPDATE TO '7.0-9';
|
ALTER EXTENSION citus UPDATE TO '7.0-9';
|
||||||
|
ALTER EXTENSION citus UPDATE TO '7.0-10';
|
||||||
-- show running version
|
-- show running version
|
||||||
SHOW citus.version;
|
SHOW citus.version;
|
||||||
citus.version
|
citus.version
|
||||||
|
|
|
@ -232,3 +232,9 @@ SELECT * FROM pg_dist_node WHERE nodeport=8887;
|
||||||
|
|
||||||
-- don't remove the secondary and unavailable nodes, check that no commands are sent to
|
-- don't remove the secondary and unavailable nodes, check that no commands are sent to
|
||||||
-- them in any of the remaining tests
|
-- them in any of the remaining tests
|
||||||
|
|
||||||
|
-- master_add_secondary_node lets you skip looking up the groupid
|
||||||
|
SELECT master_add_secondary_node('localhost', 9995, 'localhost', :worker_1_port);
|
||||||
|
SELECT master_add_secondary_node('localhost', 9994, primaryname => 'localhost', primaryport => :worker_2_port);
|
||||||
|
SELECT master_add_secondary_node('localhost', 9993, 'localhost', 2000);
|
||||||
|
SELECT master_add_secondary_node('localhost', 9992, 'localhost', :worker_1_port, nodecluster => 'second-cluster');
|
||||||
|
|
|
@ -119,6 +119,7 @@ ALTER EXTENSION citus UPDATE TO '7.0-6';
|
||||||
ALTER EXTENSION citus UPDATE TO '7.0-7';
|
ALTER EXTENSION citus UPDATE TO '7.0-7';
|
||||||
ALTER EXTENSION citus UPDATE TO '7.0-8';
|
ALTER EXTENSION citus UPDATE TO '7.0-8';
|
||||||
ALTER EXTENSION citus UPDATE TO '7.0-9';
|
ALTER EXTENSION citus UPDATE TO '7.0-9';
|
||||||
|
ALTER EXTENSION citus UPDATE TO '7.0-10';
|
||||||
|
|
||||||
-- show running version
|
-- show running version
|
||||||
SHOW citus.version;
|
SHOW citus.version;
|
||||||
|
|
Loading…
Reference in New Issue