mirror of https://github.com/citusdata/citus.git
Improve tests for round robin & router queries
parent
4d737177e6
commit
7443191397
|
@ -19,17 +19,16 @@ DECLARE
|
||||||
shardOfTheTask text;
|
shardOfTheTask text;
|
||||||
begin
|
begin
|
||||||
for r in execute qry loop
|
for r in execute qry loop
|
||||||
IF r LIKE '%port%' THEN
|
IF r LIKE '%port%' THEN
|
||||||
portOfTheTask = substring(r, '([0-9]{1,10})');
|
portOfTheTask = substring(r, '([0-9]{1,10})');
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
IF r LIKE '%' || table_name || '%' THEN
|
IF r LIKE '%' || table_name || '%' THEN
|
||||||
shardOfTheTask = substring(r, '([0-9]{1,10})');
|
shardOfTheTask = substring(r, '([0-9]{5,10})');
|
||||||
return QUERY SELECT shardOfTheTask || '@' || portOfTheTask ;
|
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
end loop;
|
end loop;
|
||||||
return;
|
return QUERY SELECT shardOfTheTask || '@' || portOfTheTask;
|
||||||
end; $$ language plpgsql;
|
end; $$ language plpgsql;
|
||||||
SET citus.explain_distributed_queries TO off;
|
SET citus.explain_distributed_queries TO off;
|
||||||
-- Check that our policies for assigning tasks to worker nodes run as expected.
|
-- Check that our policies for assigning tasks to worker nodes run as expected.
|
||||||
|
@ -300,11 +299,8 @@ SELECT count(DISTINCT value) FROM explain_outputs;
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
TRUNCATE explain_outputs;
|
TRUNCATE explain_outputs;
|
||||||
RESET citus.task_assignment_policy;
|
-- We should be able to use round-robin with router queries that
|
||||||
RESET client_min_messages;
|
|
||||||
-- we should be able to use round-robin with router queries that
|
|
||||||
-- only contains intermediate results
|
-- only contains intermediate results
|
||||||
BEGIN;
|
|
||||||
CREATE TABLE task_assignment_test_table_2 (test_id integer);
|
CREATE TABLE task_assignment_test_table_2 (test_id integer);
|
||||||
SELECT create_distributed_table('task_assignment_test_table_2', 'test_id');
|
SELECT create_distributed_table('task_assignment_test_table_2', 'test_id');
|
||||||
create_distributed_table
|
create_distributed_table
|
||||||
|
@ -312,17 +308,26 @@ SELECT create_distributed_table('task_assignment_test_table_2', 'test_id');
|
||||||
|
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
WITH q1 AS (SELECT * FROM task_assignment_test_table_2) SELECT * FROM q1;
|
SET citus.task_assignment_policy TO 'round-robin';
|
||||||
test_id
|
-- Run the query two times to make sure that it hits two different workers
|
||||||
---------
|
-- on consecutive runs
|
||||||
(0 rows)
|
INSERT INTO explain_outputs
|
||||||
|
SELECT parse_explain_output($cmd$
|
||||||
|
EXPLAIN WITH q1 AS (SELECT * FROM task_assignment_test_table_2) SELECT * FROM q1
|
||||||
|
$cmd$, 'task_assignment_test_table_2');
|
||||||
|
INSERT INTO explain_outputs
|
||||||
|
SELECT parse_explain_output($cmd$
|
||||||
|
EXPLAIN WITH q1 AS (SELECT * FROM task_assignment_test_table_2) SELECT * FROM q1
|
||||||
|
$cmd$, 'task_assignment_test_table_2');
|
||||||
|
-- The count should be 2 since the intermediate results are processed on
|
||||||
|
-- different workers
|
||||||
|
SELECT count(DISTINCT value) FROM explain_outputs;
|
||||||
|
count
|
||||||
|
-------
|
||||||
|
2
|
||||||
|
(1 row)
|
||||||
|
|
||||||
SET LOCAL citus.task_assignment_policy TO 'round-robin';
|
RESET citus.task_assignment_policy;
|
||||||
WITH q1 AS (SELECT * FROM task_assignment_test_table_2) SELECT * FROM q1;
|
RESET client_min_messages;
|
||||||
test_id
|
|
||||||
---------
|
|
||||||
(0 rows)
|
|
||||||
|
|
||||||
ROLLBACK;
|
|
||||||
DROP TABLE task_assignment_replicated_hash, task_assignment_nonreplicated_hash,
|
DROP TABLE task_assignment_replicated_hash, task_assignment_nonreplicated_hash,
|
||||||
task_assignment_reference_table, explain_outputs;
|
task_assignment_reference_table, task_assignment_test_table_2, explain_outputs;
|
||||||
|
|
|
@ -18,17 +18,16 @@ DECLARE
|
||||||
shardOfTheTask text;
|
shardOfTheTask text;
|
||||||
begin
|
begin
|
||||||
for r in execute qry loop
|
for r in execute qry loop
|
||||||
IF r LIKE '%port%' THEN
|
IF r LIKE '%port%' THEN
|
||||||
portOfTheTask = substring(r, '([0-9]{1,10})');
|
portOfTheTask = substring(r, '([0-9]{1,10})');
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
IF r LIKE '%' || table_name || '%' THEN
|
IF r LIKE '%' || table_name || '%' THEN
|
||||||
shardOfTheTask = substring(r, '([0-9]{1,10})');
|
shardOfTheTask = substring(r, '([0-9]{5,10})');
|
||||||
return QUERY SELECT shardOfTheTask || '@' || portOfTheTask ;
|
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
end loop;
|
end loop;
|
||||||
return;
|
return QUERY SELECT shardOfTheTask || '@' || portOfTheTask;
|
||||||
end; $$ language plpgsql;
|
end; $$ language plpgsql;
|
||||||
|
|
||||||
|
|
||||||
|
@ -236,19 +235,31 @@ $cmd$, 'task_assignment_nonreplicated_hash');
|
||||||
SELECT count(DISTINCT value) FROM explain_outputs;
|
SELECT count(DISTINCT value) FROM explain_outputs;
|
||||||
TRUNCATE explain_outputs;
|
TRUNCATE explain_outputs;
|
||||||
|
|
||||||
RESET citus.task_assignment_policy;
|
-- We should be able to use round-robin with router queries that
|
||||||
RESET client_min_messages;
|
|
||||||
|
|
||||||
-- we should be able to use round-robin with router queries that
|
|
||||||
-- only contains intermediate results
|
-- only contains intermediate results
|
||||||
BEGIN;
|
|
||||||
CREATE TABLE task_assignment_test_table_2 (test_id integer);
|
CREATE TABLE task_assignment_test_table_2 (test_id integer);
|
||||||
SELECT create_distributed_table('task_assignment_test_table_2', 'test_id');
|
SELECT create_distributed_table('task_assignment_test_table_2', 'test_id');
|
||||||
|
|
||||||
WITH q1 AS (SELECT * FROM task_assignment_test_table_2) SELECT * FROM q1;
|
SET citus.task_assignment_policy TO 'round-robin';
|
||||||
SET LOCAL citus.task_assignment_policy TO 'round-robin';
|
|
||||||
WITH q1 AS (SELECT * FROM task_assignment_test_table_2) SELECT * FROM q1;
|
-- Run the query two times to make sure that it hits two different workers
|
||||||
ROLLBACK;
|
-- on consecutive runs
|
||||||
|
INSERT INTO explain_outputs
|
||||||
|
SELECT parse_explain_output($cmd$
|
||||||
|
EXPLAIN WITH q1 AS (SELECT * FROM task_assignment_test_table_2) SELECT * FROM q1
|
||||||
|
$cmd$, 'task_assignment_test_table_2');
|
||||||
|
|
||||||
|
INSERT INTO explain_outputs
|
||||||
|
SELECT parse_explain_output($cmd$
|
||||||
|
EXPLAIN WITH q1 AS (SELECT * FROM task_assignment_test_table_2) SELECT * FROM q1
|
||||||
|
$cmd$, 'task_assignment_test_table_2');
|
||||||
|
|
||||||
|
-- The count should be 2 since the intermediate results are processed on
|
||||||
|
-- different workers
|
||||||
|
SELECT count(DISTINCT value) FROM explain_outputs;
|
||||||
|
|
||||||
|
RESET citus.task_assignment_policy;
|
||||||
|
RESET client_min_messages;
|
||||||
|
|
||||||
DROP TABLE task_assignment_replicated_hash, task_assignment_nonreplicated_hash,
|
DROP TABLE task_assignment_replicated_hash, task_assignment_nonreplicated_hash,
|
||||||
task_assignment_reference_table, explain_outputs;
|
task_assignment_reference_table, task_assignment_test_table_2, explain_outputs;
|
||||||
|
|
Loading…
Reference in New Issue