Adds initial code

packaging_validations
gindibay 2023-07-25 18:26:25 +03:00
parent c5557b7b6a
commit 16c8706136
7 changed files with 55 additions and 0 deletions

1
.gitignore vendored
View File

@ -55,3 +55,4 @@ lib*.pc
# style related temporary outputs
*.uncrustify
.venv
test-cluster/*

View File

@ -152,6 +152,7 @@ PG_FUNCTION_INFO_V1(master_disable_node);
PG_FUNCTION_INFO_V1(citus_activate_node);
PG_FUNCTION_INFO_V1(master_activate_node);
PG_FUNCTION_INFO_V1(citus_update_node);
PG_FUNCTION_INFO_V1(citus_pause_node);
PG_FUNCTION_INFO_V1(master_update_node);
PG_FUNCTION_INFO_V1(get_shard_id_for_distribution_column);
PG_FUNCTION_INFO_V1(citus_nodename_for_nodeid);
@ -1329,6 +1330,32 @@ citus_update_node(PG_FUNCTION_ARGS)
PG_RETURN_VOID();
}
Datum
citus_pause_node(PG_FUNCTION_ARGS)
{
CheckCitusVersion(ERROR);
int32 nodeId = PG_GETARG_INT32(0);
List *placementList = NIL;
WorkerNode *workerNode = FindNodeAnyClusterByNodeId(nodeId);
if (workerNode == NULL)
{
ereport(ERROR, (errcode(ERRCODE_NO_DATA_FOUND),
errmsg("node %u not found", nodeId)));
}
if (NodeIsPrimary(workerNode))
{
placementList = AllShardPlacementsOnNodeGroup(workerNode->groupId);
LockShardsInPlacementListMetadata(placementList, AccessExclusiveLock);
}
PG_RETURN_VOID();
}
/*
* master_update_node is a wrapper function for old UDF name.

View File

@ -1,3 +1,7 @@
-- citus--12.0-1--12.1-1
#include "udfs/citus_pause_node/12.1-1.sql"
-- bump version to 12.1-1

View File

@ -1,2 +1,4 @@
-- citus--12.1-1--12.0-1
-- this is an empty downgrade path since citus--12.0-1--12.1-1.sql is empty for now
DROP FUNCTION pg_catalog.citus_pause_node(int);

View File

@ -0,0 +1,9 @@
CREATE FUNCTION pg_catalog.citus_pause_node(node_id int)
RETURNS void
LANGUAGE C STRICT
AS 'MODULE_PATHNAME', $$citus_pause_node$$;
COMMENT ON FUNCTION pg_catalog.citus_pause_node(node_id int)
IS 'pauses node with given id which leads to add lock in tables and prevent any queries to be executed on that node';
REVOKE ALL ON FUNCTION pg_catalog.citus_pause_node(int) FROM PUBLIC;

View File

@ -0,0 +1,9 @@
CREATE FUNCTION pg_catalog.citus_pause_node(node_id int)
RETURNS void
LANGUAGE C STRICT
AS 'MODULE_PATHNAME', $$citus_pause_node$$;
COMMENT ON FUNCTION pg_catalog.citus_pause_node(node_id int)
IS 'pauses node with given id which leads to add lock in tables and prevent any queries to be executed on that node';
REVOKE ALL ON FUNCTION pg_catalog.citus_pause_node(int) FROM PUBLIC;

View File

@ -376,6 +376,9 @@ SELECT citus_update_node(:worker_1_node, 'localhost', 9992);
SELECT citus_nodename_for_nodeid(:worker_1_node);
SELECT citus_nodeport_for_nodeid(:worker_1_node);
--citus_pause_node allows pausing a node from the non-default cluster
--TODO add test cases here
SELECT nodeid AS worker_1_node FROM pg_dist_node WHERE nodeport=:worker_1_port \gset