Renamed UDF to worker_split_shard_replication_setup

users/saawasek/non_blocking_split_integrated
Sameer Awasekar 2022-06-03 12:05:37 +05:30
parent b425573b08
commit 672d198019
7 changed files with 18 additions and 20 deletions

View File

@ -19,7 +19,7 @@
#include "utils/lsyscache.h" #include "utils/lsyscache.h"
/* declarations for dynamic loading */ /* declarations for dynamic loading */
PG_FUNCTION_INFO_V1(split_shard_replication_setup); PG_FUNCTION_INFO_V1(worker_split_shard_replication_setup);
static HTAB *ShardInfoHashMap = NULL; static HTAB *ShardInfoHashMap = NULL;
@ -53,8 +53,7 @@ static ShardSplitInfo * CreateShardSplitInfo(uint64 sourceShardIdToSplit,
static void AddShardSplitInfoEntryForNodeInMap(ShardSplitInfo *shardSplitInfo); static void AddShardSplitInfoEntryForNodeInMap(ShardSplitInfo *shardSplitInfo);
static void PopulateShardSplitInfoInSM(ShardSplitInfo *shardSplitInfoArray, static void PopulateShardSplitInfoInSM(ShardSplitInfo *shardSplitInfoArray,
HTAB *shardInfoHashMap, HTAB *shardInfoHashMap,
dsm_handle dsmHandle, dsm_handle dsmHandle);
int shardSplitInfoCount);
static void SetupHashMapForShardInfo(void); static void SetupHashMapForShardInfo(void);
static uint32 NodeShardMappingHash(const void *key, Size keysize); static uint32 NodeShardMappingHash(const void *key, Size keysize);
@ -62,7 +61,7 @@ static int NodeShardMappingHashCompare(const void *left, const void *right, Size
/* /*
* split_shard_replication_setup UDF creates in-memory data structures * worker_split_shard_replication_setup UDF creates in-memory data structures
* to store the meta information about the shard undergoing split and new split * to store the meta information about the shard undergoing split and new split
* children along with their placements required during the catch up phase * children along with their placements required during the catch up phase
* of logical replication. * of logical replication.
@ -102,7 +101,7 @@ static int NodeShardMappingHashCompare(const void *left, const void *right, Size
* responsible. * responsible.
*/ */
Datum Datum
split_shard_replication_setup(PG_FUNCTION_ARGS) worker_split_shard_replication_setup(PG_FUNCTION_ARGS)
{ {
ArrayType *shardInfoArrayObject = PG_GETARG_ARRAYTYPE_P(0); ArrayType *shardInfoArrayObject = PG_GETARG_ARRAYTYPE_P(0);
int shardInfoArrayLength = ARR_DIMS(shardInfoArrayObject)[0]; int shardInfoArrayLength = ARR_DIMS(shardInfoArrayObject)[0];
@ -145,8 +144,7 @@ split_shard_replication_setup(PG_FUNCTION_ARGS)
PopulateShardSplitInfoInSM(splitShardInfoSMArray, PopulateShardSplitInfoInSM(splitShardInfoSMArray,
ShardInfoHashMap, ShardInfoHashMap,
dsmHandle, dsmHandle);
shardSplitInfoCount);
return dsmHandle; return dsmHandle;
} }
@ -429,8 +427,7 @@ AddShardSplitInfoEntryForNodeInMap(ShardSplitInfo *shardSplitInfo)
static void static void
PopulateShardSplitInfoInSM(ShardSplitInfo *shardSplitInfoArray, PopulateShardSplitInfoInSM(ShardSplitInfo *shardSplitInfoArray,
HTAB *shardInfoHashMap, HTAB *shardInfoHashMap,
dsm_handle dsmHandle, dsm_handle dsmHandle)
int shardSplitInfoCount)
{ {
HASH_SEQ_STATUS status; HASH_SEQ_STATUS status;
hash_seq_init(&status, shardInfoHashMap); hash_seq_init(&status, shardInfoHashMap);

View File

@ -1,7 +1,7 @@
CREATE OR REPLACE FUNCTION pg_catalog.split_shard_replication_setup( CREATE OR REPLACE FUNCTION pg_catalog.worker_split_shard_replication_setup(
shardInfo bigint[][]) shardInfo bigint[][])
RETURNS bigint RETURNS bigint
LANGUAGE C STRICT LANGUAGE C STRICT
AS 'MODULE_PATHNAME', $$split_shard_replication_setup$$; AS 'MODULE_PATHNAME', $$worker_split_shard_replication_setup$$;
COMMENT ON FUNCTION pg_catalog.split_shard_replication_setup(shardInfo bigint[][]) COMMENT ON FUNCTION pg_catalog.worker_split_shard_replication_setup(shardInfo bigint[][])
IS 'Replication setup for splitting a shard' IS 'Replication setup for splitting a shard'

View File

@ -1,7 +1,7 @@
CREATE OR REPLACE FUNCTION pg_catalog.split_shard_replication_setup( CREATE OR REPLACE FUNCTION pg_catalog.worker_split_shard_replication_setup(
shardInfo bigint[][]) shardInfo bigint[][])
RETURNS bigint RETURNS bigint
LANGUAGE C STRICT LANGUAGE C STRICT
AS 'MODULE_PATHNAME', $$split_shard_replication_setup$$; AS 'MODULE_PATHNAME', $$worker_split_shard_replication_setup$$;
COMMENT ON FUNCTION pg_catalog.split_shard_replication_setup(shardInfo bigint[][]) COMMENT ON FUNCTION pg_catalog.worker_split_shard_replication_setup(shardInfo bigint[][])
IS 'Replication setup for splitting a shard' IS 'Replication setup for splitting a shard'

View File

@ -2,7 +2,7 @@
* *
* shardsplit_shared_memory.h * shardsplit_shared_memory.h
* API's for creating and accessing shared memory segments to store * API's for creating and accessing shared memory segments to store
* shard split information. 'split_shard_replication_setup' UDF creates the * shard split information. 'worker_split_shard_replication_setup' UDF creates the
* shared memory and populates the contents. WAL sender processes are consumer * shared memory and populates the contents. WAL sender processes are consumer
* of split information for appropriate tuple routing. * of split information for appropriate tuple routing.
* *

View File

@ -6,7 +6,7 @@ DECLARE
memoryId bigint := 0; memoryId bigint := 0;
memoryIdText text; memoryIdText text;
begin begin
SELECT * into memoryId from split_shard_replication_setup(ARRAY[ARRAY[1,2,-2147483648,-1, targetNode1], ARRAY[1,3,0,2147483647,targetNode2]]); SELECT * into memoryId from worker_split_shard_replication_setup(ARRAY[ARRAY[1,2,-2147483648,-1, targetNode1], ARRAY[1,3,0,2147483647,targetNode2]]);
SELECT FORMAT('%s', memoryId) into memoryIdText; SELECT FORMAT('%s', memoryId) into memoryIdText;
return memoryIdText; return memoryIdText;
end end
@ -42,7 +42,7 @@ DECLARE
memoryId bigint := 0; memoryId bigint := 0;
memoryIdText text; memoryIdText text;
begin begin
SELECT * into memoryId from split_shard_replication_setup( SELECT * into memoryId from worker_split_shard_replication_setup(
ARRAY[ ARRAY[
ARRAY[4, 5, -2147483648,-1, targetNode1], ARRAY[4, 5, -2147483648,-1, targetNode1],
ARRAY[4, 6, 0 ,2147483647, targetNode2], ARRAY[4, 6, 0 ,2147483647, targetNode2],

View File

@ -242,6 +242,7 @@ ORDER BY 1;
function worker_partitioned_table_size(regclass) function worker_partitioned_table_size(regclass)
function worker_record_sequence_dependency(regclass,regclass,name) function worker_record_sequence_dependency(regclass,regclass,name)
function worker_save_query_explain_analyze(text,jsonb) function worker_save_query_explain_analyze(text,jsonb)
function worker_split_shard_replication_setup(bigint[])
schema citus schema citus
schema citus_internal schema citus_internal
schema columnar schema columnar

View File

@ -7,7 +7,7 @@ DECLARE
memoryId bigint := 0; memoryId bigint := 0;
memoryIdText text; memoryIdText text;
begin begin
SELECT * into memoryId from split_shard_replication_setup(ARRAY[ARRAY[1,2,-2147483648,-1, targetNode1], ARRAY[1,3,0,2147483647,targetNode2]]); SELECT * into memoryId from worker_split_shard_replication_setup(ARRAY[ARRAY[1,2,-2147483648,-1, targetNode1], ARRAY[1,3,0,2147483647,targetNode2]]);
SELECT FORMAT('%s', memoryId) into memoryIdText; SELECT FORMAT('%s', memoryId) into memoryIdText;
return memoryIdText; return memoryIdText;
end end
@ -45,7 +45,7 @@ DECLARE
memoryId bigint := 0; memoryId bigint := 0;
memoryIdText text; memoryIdText text;
begin begin
SELECT * into memoryId from split_shard_replication_setup( SELECT * into memoryId from worker_split_shard_replication_setup(
ARRAY[ ARRAY[
ARRAY[4, 5, -2147483648,-1, targetNode1], ARRAY[4, 5, -2147483648,-1, targetNode1],
ARRAY[4, 6, 0 ,2147483647, targetNode2], ARRAY[4, 6, 0 ,2147483647, targetNode2],