mirror of https://github.com/citusdata/citus.git
Remove master_get_local_first_candidate_nodes
parent
fa5b8fb39f
commit
807beb7bc0
|
@ -9,7 +9,8 @@ EXTVERSIONS = 5.0 5.0-1 5.0-2 \
|
|||
5.1-1 5.1-2 5.1-3 5.1-4 5.1-5 5.1-6 5.1-7 5.1-8 \
|
||||
5.2-1 5.2-2 5.2-3 5.2-4 \
|
||||
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
|
||||
|
||||
# All citus--*.sql files in the source directory
|
||||
DATA = $(patsubst $(citus_abs_srcdir)/%.sql,%.sql,$(wildcard $(citus_abs_srcdir)/$(EXTENSION)--*--*.sql))
|
||||
|
@ -129,6 +130,8 @@ $(EXTENSION)--6.1-16.sql: $(EXTENSION)--6.1-15.sql $(EXTENSION)--6.1-15--6.1-16.
|
|||
cat $^ > $@
|
||||
$(EXTENSION)--6.1-17.sql: $(EXTENSION)--6.1-16.sql $(EXTENSION)--6.1-16--6.1-17.sql
|
||||
cat $^ > $@
|
||||
$(EXTENSION)--6.2-1.sql: $(EXTENSION)--6.1-17.sql $(EXTENSION)--6.1-17--6.2-1.sql
|
||||
cat $^ > $@
|
||||
|
||||
NO_PGXS = 1
|
||||
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
/* citus--6.1-17--6.2-1.sql */
|
||||
|
||||
SET search_path = 'pg_catalog';
|
||||
|
||||
DROP FUNCTION IF EXISTS master_get_local_first_candidate_nodes();
|
||||
|
||||
RESET search_path;
|
|
@ -1,6 +1,6 @@
|
|||
# Citus extension
|
||||
comment = 'Citus distributed database'
|
||||
default_version = '6.1-17'
|
||||
default_version = '6.2-1'
|
||||
module_pathname = '$libdir/citus'
|
||||
relocatable = false
|
||||
schema = pg_catalog
|
||||
|
|
|
@ -129,14 +129,6 @@ CREATE FUNCTION master_get_new_shardid()
|
|||
COMMENT ON FUNCTION master_get_new_shardid()
|
||||
IS 'fetch unique shardId';
|
||||
|
||||
CREATE FUNCTION master_get_local_first_candidate_nodes(OUT node_name text,
|
||||
OUT node_port bigint)
|
||||
RETURNS SETOF record
|
||||
LANGUAGE C STRICT ROWS 100
|
||||
AS 'MODULE_PATHNAME', $$master_get_local_first_candidate_nodes$$;
|
||||
COMMENT ON FUNCTION master_get_local_first_candidate_nodes()
|
||||
IS 'fetch set of candidate nodes for shard uploading choosing the local node first';
|
||||
|
||||
CREATE FUNCTION master_create_empty_shard(text)
|
||||
RETURNS bigint
|
||||
LANGUAGE C STRICT
|
||||
|
|
|
@ -77,7 +77,6 @@ PG_FUNCTION_INFO_V1(master_get_table_metadata);
|
|||
PG_FUNCTION_INFO_V1(master_get_table_ddl_events);
|
||||
PG_FUNCTION_INFO_V1(master_get_new_shardid);
|
||||
PG_FUNCTION_INFO_V1(master_get_new_placementid);
|
||||
PG_FUNCTION_INFO_V1(master_get_local_first_candidate_nodes);
|
||||
PG_FUNCTION_INFO_V1(master_get_round_robin_candidate_nodes);
|
||||
PG_FUNCTION_INFO_V1(master_get_active_worker_nodes);
|
||||
|
||||
|
@ -366,98 +365,6 @@ GetNextPlacementId(void)
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* master_get_local_first_candidate_nodes returns a set of candidate host names
|
||||
* and port numbers on which to place new shards. The function makes sure to
|
||||
* always allocate the first candidate node as the node the caller is connecting
|
||||
* from; and allocates additional nodes until the shard replication factor is
|
||||
* met. The function errors if the caller's remote node name is not found in the
|
||||
* membership list, or if the number of available nodes falls short of the
|
||||
* replication factor.
|
||||
*/
|
||||
Datum
|
||||
master_get_local_first_candidate_nodes(PG_FUNCTION_ARGS)
|
||||
{
|
||||
FuncCallContext *functionContext = NULL;
|
||||
uint32 desiredNodeCount = 0;
|
||||
uint32 currentNodeCount = 0;
|
||||
|
||||
if (SRF_IS_FIRSTCALL())
|
||||
{
|
||||
MemoryContext oldContext = NULL;
|
||||
TupleDesc tupleDescriptor = NULL;
|
||||
uint32 liveNodeCount = 0;
|
||||
bool hasOid = false;
|
||||
|
||||
/* create a function context for cross-call persistence */
|
||||
functionContext = SRF_FIRSTCALL_INIT();
|
||||
|
||||
/* switch to memory context appropriate for multiple function calls */
|
||||
oldContext = MemoryContextSwitchTo(functionContext->multi_call_memory_ctx);
|
||||
|
||||
functionContext->user_fctx = NIL;
|
||||
functionContext->max_calls = ShardReplicationFactor;
|
||||
|
||||
/* if enough live nodes, return an extra candidate node as backup */
|
||||
liveNodeCount = WorkerGetLiveNodeCount();
|
||||
if (liveNodeCount > ShardReplicationFactor)
|
||||
{
|
||||
functionContext->max_calls = ShardReplicationFactor + 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* This tuple descriptor must match the output parameters declared for
|
||||
* the function in pg_proc.
|
||||
*/
|
||||
tupleDescriptor = CreateTemplateTupleDesc(CANDIDATE_NODE_FIELDS, hasOid);
|
||||
TupleDescInitEntry(tupleDescriptor, (AttrNumber) 1, "node_name",
|
||||
TEXTOID, -1, 0);
|
||||
TupleDescInitEntry(tupleDescriptor, (AttrNumber) 2, "node_port",
|
||||
INT8OID, -1, 0);
|
||||
|
||||
functionContext->tuple_desc = BlessTupleDesc(tupleDescriptor);
|
||||
|
||||
MemoryContextSwitchTo(oldContext);
|
||||
}
|
||||
|
||||
functionContext = SRF_PERCALL_SETUP();
|
||||
desiredNodeCount = functionContext->max_calls;
|
||||
currentNodeCount = functionContext->call_cntr;
|
||||
|
||||
if (currentNodeCount < desiredNodeCount)
|
||||
{
|
||||
MemoryContext oldContext = NULL;
|
||||
List *currentNodeList = NIL;
|
||||
WorkerNode *candidateNode = NULL;
|
||||
Datum candidateDatum = 0;
|
||||
|
||||
/* switch to memory context appropriate for multiple function calls */
|
||||
oldContext = MemoryContextSwitchTo(functionContext->multi_call_memory_ctx);
|
||||
currentNodeList = functionContext->user_fctx;
|
||||
|
||||
candidateNode = WorkerGetLocalFirstCandidateNode(currentNodeList);
|
||||
if (candidateNode == NULL)
|
||||
{
|
||||
ereport(ERROR, (errmsg("could only find %u of %u required nodes",
|
||||
currentNodeCount, desiredNodeCount)));
|
||||
}
|
||||
|
||||
currentNodeList = lappend(currentNodeList, candidateNode);
|
||||
functionContext->user_fctx = currentNodeList;
|
||||
|
||||
MemoryContextSwitchTo(oldContext);
|
||||
|
||||
candidateDatum = WorkerNodeGetDatum(candidateNode, functionContext->tuple_desc);
|
||||
|
||||
SRF_RETURN_NEXT(functionContext, candidateDatum);
|
||||
}
|
||||
else
|
||||
{
|
||||
SRF_RETURN_DONE(functionContext);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* master_get_round_robin_candidate_nodes returns a set of candidate host names
|
||||
* and port numbers on which to place new shards. The function uses the round
|
||||
|
|
|
@ -126,7 +126,6 @@ extern Datum master_get_table_metadata(PG_FUNCTION_ARGS);
|
|||
extern Datum master_get_table_ddl_events(PG_FUNCTION_ARGS);
|
||||
extern Datum master_get_new_shardid(PG_FUNCTION_ARGS);
|
||||
extern Datum master_get_new_placementid(PG_FUNCTION_ARGS);
|
||||
extern Datum master_get_local_first_candidate_nodes(PG_FUNCTION_ARGS);
|
||||
extern Datum master_get_round_robin_candidate_nodes(PG_FUNCTION_ARGS);
|
||||
extern Datum master_get_active_worker_nodes(PG_FUNCTION_ARGS);
|
||||
|
||||
|
|
|
@ -75,6 +75,7 @@ ALTER EXTENSION citus UPDATE TO '6.1-14';
|
|||
ALTER EXTENSION citus UPDATE TO '6.1-15';
|
||||
ALTER EXTENSION citus UPDATE TO '6.1-16';
|
||||
ALTER EXTENSION citus UPDATE TO '6.1-17';
|
||||
ALTER EXTENSION citus UPDATE TO '6.2-1';
|
||||
-- ensure no objects were created outside pg_catalog
|
||||
SELECT COUNT(*)
|
||||
FROM pg_depend AS pgd,
|
||||
|
|
|
@ -75,6 +75,7 @@ ALTER EXTENSION citus UPDATE TO '6.1-14';
|
|||
ALTER EXTENSION citus UPDATE TO '6.1-15';
|
||||
ALTER EXTENSION citus UPDATE TO '6.1-16';
|
||||
ALTER EXTENSION citus UPDATE TO '6.1-17';
|
||||
ALTER EXTENSION citus UPDATE TO '6.2-1';
|
||||
|
||||
-- ensure no objects were created outside pg_catalog
|
||||
SELECT COUNT(*)
|
||||
|
|
Loading…
Reference in New Issue