From df88ab71b6beb5bfd97c9f04c24a2b25a4a04f2f Mon Sep 17 00:00:00 2001 From: SaitTalhaNisanci Date: Wed, 1 Apr 2020 12:50:33 +0300 Subject: [PATCH] normalize assign_distributed_transaction_id in tests --- .../distributed/executor/local_executor.c | 2 +- src/test/regress/bin/normalize.sed | 3 + .../expected/coordinator_shouldhaveshards.out | 72 ++++++++++++++----- .../local_shard_utility_command_execution.out | 12 +++- .../sql/coordinator_shouldhaveshards.sql | 24 +++++-- 5 files changed, 86 insertions(+), 27 deletions(-) diff --git a/src/backend/distributed/executor/local_executor.c b/src/backend/distributed/executor/local_executor.c index 4376a812c..2ac88d173 100644 --- a/src/backend/distributed/executor/local_executor.c +++ b/src/backend/distributed/executor/local_executor.c @@ -235,7 +235,7 @@ ExecuteLocalTaskListExtended(List *taskList, ParamListInfo orig_paramListInfo, totalRowsProcessed += LocallyPlanAndExecuteMultipleQueries( queryStringList, tupleStoreState); - return totalRowsProcessed; + continue; } Query *shardQuery = ParseQueryString(TaskQueryStringForAllPlacements(task), diff --git a/src/test/regress/bin/normalize.sed b/src/test/regress/bin/normalize.sed index 3e1b2d856..dd419886a 100644 --- a/src/test/regress/bin/normalize.sed +++ b/src/test/regress/bin/normalize.sed @@ -83,6 +83,9 @@ s/_id_other_column_ref_fkey/_id_fkey/g # intermediate_results s/(ERROR.*)pgsql_job_cache\/([0-9]+_[0-9]+_[0-9]+)\/(.*).data/\1pgsql_job_cache\/xx_x_xxx\/\3.data/g +# assign_distributed_transaction id params +s/(NOTICE.*)assign_distributed_transaction_id\([0-9]+, [0-9]+, '.*'\)/\1assign_distributed_transaction_id\(xx, xx, 'xxxxxxx'\)/g + # toast tables s/pg_toast_[0-9]+/pg_toast_xxxxx/g diff --git a/src/test/regress/expected/coordinator_shouldhaveshards.out b/src/test/regress/expected/coordinator_shouldhaveshards.out index 908e645c8..2c56fc580 100644 --- a/src/test/regress/expected/coordinator_shouldhaveshards.out +++ b/src/test/regress/expected/coordinator_shouldhaveshards.out @@ -121,8 +121,12 @@ SELECT y FROM test WHERE x = 1; (1 row) END; -SET citus.log_remote_commands TO ON; +SET citus.shard_count TO 6; +SET citus.log_remote_commands TO OFF; BEGIN; +SET citus.log_local_commands TO ON; +CREATE TABLE dist_table (a int); +INSERT INTO dist_table SELECT * FROM generate_series(1, 100); -- trigger local execution SELECT y FROM test WHERE x = 1; NOTICE: executing the command locally: SELECT y FROM coordinator_shouldhaveshards.test_1503000 test WHERE (x OPERATOR(pg_catalog.=) 1) @@ -131,34 +135,64 @@ NOTICE: executing the command locally: SELECT y FROM coordinator_shouldhaveshar 1 (1 row) -CREATE TABLE dist_table (a int); -INSERT INTO dist_table SELECT * FROM generate_series(1, 100); -- this should be run locally SELECT create_distributed_table('dist_table', 'a', colocate_with := 'none'); NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1503004, 'coordinator_shouldhaveshards', 'CREATE TABLE coordinator_shouldhaveshards.dist_table (a integer)');SELECT worker_apply_shard_ddl_command (1503004, 'coordinator_shouldhaveshards', 'ALTER TABLE coordinator_shouldhaveshards.dist_table OWNER TO postgres') -NOTICE: issuing BEGIN TRANSACTION ISOLATION LEVEL READ COMMITTED;SELECT assign_distributed_transaction_id(0, 5283, '2020-03-31 12:54:05.803455-07'); -DETAIL: on server postgres@localhost:xxxxx connectionId: 4 -NOTICE: issuing BEGIN TRANSACTION ISOLATION LEVEL READ COMMITTED;SELECT assign_distributed_transaction_id(0, 5283, '2020-03-31 12:54:05.803455-07'); -DETAIL: on server postgres@localhost:xxxxx connectionId: 5 -NOTICE: issuing SELECT worker_apply_shard_ddl_command (1503005, 'coordinator_shouldhaveshards', 'CREATE TABLE coordinator_shouldhaveshards.dist_table (a integer)');SELECT worker_apply_shard_ddl_command (1503005, 'coordinator_shouldhaveshards', 'ALTER TABLE coordinator_shouldhaveshards.dist_table OWNER TO postgres') -DETAIL: on server postgres@localhost:xxxxx connectionId: 4 -NOTICE: issuing SELECT worker_apply_shard_ddl_command (1503006, 'coordinator_shouldhaveshards', 'CREATE TABLE coordinator_shouldhaveshards.dist_table (a integer)');SELECT worker_apply_shard_ddl_command (1503006, 'coordinator_shouldhaveshards', 'ALTER TABLE coordinator_shouldhaveshards.dist_table OWNER TO postgres') -DETAIL: on server postgres@localhost:xxxxx connectionId: 5 +NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1503007, 'coordinator_shouldhaveshards', 'CREATE TABLE coordinator_shouldhaveshards.dist_table (a integer)');SELECT worker_apply_shard_ddl_command (1503007, 'coordinator_shouldhaveshards', 'ALTER TABLE coordinator_shouldhaveshards.dist_table OWNER TO postgres') NOTICE: executing the copy locally for shard xxxxx NOTICE: Copying data from local table... NOTICE: executing the copy locally for shard xxxxx -NOTICE: issuing COPY coordinator_shouldhaveshards.dist_table_1503005 (a) FROM STDIN WITH (format 'binary') -DETAIL: on server postgres@localhost:xxxxx connectionId: 4 -NOTICE: issuing COPY coordinator_shouldhaveshards.dist_table_1503006 (a) FROM STDIN WITH (format 'binary') -DETAIL: on server postgres@localhost:xxxxx connectionId: 5 -ERROR: could not open relation with OID 0 + create_distributed_table +--------------------------------------------------------------------- + +(1 row) + SELECT count(*) FROM dist_table; -ERROR: current transaction is aborted, commands ignored until end of transaction block -END; -SET citus.log_remote_commands TO OFF; +NOTICE: executing the command locally: SELECT count(*) AS count FROM coordinator_shouldhaveshards.dist_table_1503004 dist_table WHERE true +NOTICE: executing the command locally: SELECT count(*) AS count FROM coordinator_shouldhaveshards.dist_table_1503007 dist_table WHERE true + count +--------------------------------------------------------------------- + 100 +(1 row) + +ROLLBACK; +CREATE TABLE dist_table (a int); +INSERT INTO dist_table SELECT * FROM generate_series(1, 100); +BEGIN; +SET citus.log_local_commands TO ON; +-- trigger local execution +SELECT y FROM test WHERE x = 1; +NOTICE: executing the command locally: SELECT y FROM coordinator_shouldhaveshards.test_1503000 test WHERE (x OPERATOR(pg_catalog.=) 1) + y +--------------------------------------------------------------------- + 1 +(1 row) + +-- this should be run locally +SELECT create_distributed_table('dist_table', 'a', colocate_with := 'none'); +NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1503010, 'coordinator_shouldhaveshards', 'CREATE TABLE coordinator_shouldhaveshards.dist_table (a integer)');SELECT worker_apply_shard_ddl_command (1503010, 'coordinator_shouldhaveshards', 'ALTER TABLE coordinator_shouldhaveshards.dist_table OWNER TO postgres') +NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1503013, 'coordinator_shouldhaveshards', 'CREATE TABLE coordinator_shouldhaveshards.dist_table (a integer)');SELECT worker_apply_shard_ddl_command (1503013, 'coordinator_shouldhaveshards', 'ALTER TABLE coordinator_shouldhaveshards.dist_table OWNER TO postgres') +NOTICE: executing the copy locally for shard xxxxx +NOTICE: Copying data from local table... +NOTICE: executing the copy locally for shard xxxxx + create_distributed_table +--------------------------------------------------------------------- + +(1 row) + +SELECT count(*) FROM dist_table; +NOTICE: executing the command locally: SELECT count(*) AS count FROM coordinator_shouldhaveshards.dist_table_1503010 dist_table WHERE true +NOTICE: executing the command locally: SELECT count(*) AS count FROM coordinator_shouldhaveshards.dist_table_1503013 dist_table WHERE true + count +--------------------------------------------------------------------- + 100 +(1 row) + +ROLLBACK; DELETE FROM test; DROP TABLE test; DROP SCHEMA coordinator_shouldhaveshards CASCADE; +NOTICE: drop cascades to table dist_table SELECT 1 FROM master_set_node_property('localhost', :master_port, 'shouldhaveshards', false); ?column? --------------------------------------------------------------------- diff --git a/src/test/regress/expected/local_shard_utility_command_execution.out b/src/test/regress/expected/local_shard_utility_command_execution.out index b988f125c..a35869532 100644 --- a/src/test/regress/expected/local_shard_utility_command_execution.out +++ b/src/test/regress/expected/local_shard_utility_command_execution.out @@ -566,6 +566,16 @@ NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1 CREATE TABLE another_dist_table(a int); SELECT create_distributed_table('another_dist_table', 'a', colocate_with:='dist_table'); NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1500133, 'local_commands_test_schema', 'CREATE TABLE local_commands_test_schema.another_dist_table (a integer)');SELECT worker_apply_shard_ddl_command (1500133, 'local_commands_test_schema', 'ALTER TABLE local_commands_test_schema.another_dist_table OWNER TO postgres') +NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1500136, 'local_commands_test_schema', 'CREATE TABLE local_commands_test_schema.another_dist_table (a integer)');SELECT worker_apply_shard_ddl_command (1500136, 'local_commands_test_schema', 'ALTER TABLE local_commands_test_schema.another_dist_table OWNER TO postgres') +NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1500139, 'local_commands_test_schema', 'CREATE TABLE local_commands_test_schema.another_dist_table (a integer)');SELECT worker_apply_shard_ddl_command (1500139, 'local_commands_test_schema', 'ALTER TABLE local_commands_test_schema.another_dist_table OWNER TO postgres') +NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1500142, 'local_commands_test_schema', 'CREATE TABLE local_commands_test_schema.another_dist_table (a integer)');SELECT worker_apply_shard_ddl_command (1500142, 'local_commands_test_schema', 'ALTER TABLE local_commands_test_schema.another_dist_table OWNER TO postgres') +NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1500145, 'local_commands_test_schema', 'CREATE TABLE local_commands_test_schema.another_dist_table (a integer)');SELECT worker_apply_shard_ddl_command (1500145, 'local_commands_test_schema', 'ALTER TABLE local_commands_test_schema.another_dist_table OWNER TO postgres') +NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1500148, 'local_commands_test_schema', 'CREATE TABLE local_commands_test_schema.another_dist_table (a integer)');SELECT worker_apply_shard_ddl_command (1500148, 'local_commands_test_schema', 'ALTER TABLE local_commands_test_schema.another_dist_table OWNER TO postgres') +NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1500151, 'local_commands_test_schema', 'CREATE TABLE local_commands_test_schema.another_dist_table (a integer)');SELECT worker_apply_shard_ddl_command (1500151, 'local_commands_test_schema', 'ALTER TABLE local_commands_test_schema.another_dist_table OWNER TO postgres') +NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1500154, 'local_commands_test_schema', 'CREATE TABLE local_commands_test_schema.another_dist_table (a integer)');SELECT worker_apply_shard_ddl_command (1500154, 'local_commands_test_schema', 'ALTER TABLE local_commands_test_schema.another_dist_table OWNER TO postgres') +NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1500157, 'local_commands_test_schema', 'CREATE TABLE local_commands_test_schema.another_dist_table (a integer)');SELECT worker_apply_shard_ddl_command (1500157, 'local_commands_test_schema', 'ALTER TABLE local_commands_test_schema.another_dist_table OWNER TO postgres') +NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1500160, 'local_commands_test_schema', 'CREATE TABLE local_commands_test_schema.another_dist_table (a integer)');SELECT worker_apply_shard_ddl_command (1500160, 'local_commands_test_schema', 'ALTER TABLE local_commands_test_schema.another_dist_table OWNER TO postgres') +NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1500163, 'local_commands_test_schema', 'CREATE TABLE local_commands_test_schema.another_dist_table (a integer)');SELECT worker_apply_shard_ddl_command (1500163, 'local_commands_test_schema', 'ALTER TABLE local_commands_test_schema.another_dist_table OWNER TO postgres') create_distributed_table --------------------------------------------------------------------- @@ -726,7 +736,7 @@ TRUNCATE partitioning_test; DROP TABLE partitioning_test; -- cleanup at exit DROP SCHEMA local_commands_test_schema CASCADE; -NOTICE: drop cascades to 18 other objects +NOTICE: drop cascades to 28 other objects DROP SCHEMA foo_schema; SELECT 1 FROM master_set_node_property('localhost', :master_port, 'shouldhaveshards', false); ?column? diff --git a/src/test/regress/sql/coordinator_shouldhaveshards.sql b/src/test/regress/sql/coordinator_shouldhaveshards.sql index f978c2de5..60fe634c6 100644 --- a/src/test/regress/sql/coordinator_shouldhaveshards.sql +++ b/src/test/regress/sql/coordinator_shouldhaveshards.sql @@ -60,20 +60,32 @@ ALTER TABLE test DROP COLUMN z; SELECT y FROM test WHERE x = 1; END; -SET citus.log_remote_commands TO ON; + +SET citus.shard_count TO 6; +SET citus.log_remote_commands TO OFF; + BEGIN; --- trigger local execution -SELECT y FROM test WHERE x = 1; +SET citus.log_local_commands TO ON; CREATE TABLE dist_table (a int); INSERT INTO dist_table SELECT * FROM generate_series(1, 100); +-- trigger local execution +SELECT y FROM test WHERE x = 1; -- this should be run locally SELECT create_distributed_table('dist_table', 'a', colocate_with := 'none'); SELECT count(*) FROM dist_table; -END; - -SET citus.log_remote_commands TO OFF; +ROLLBACK; +CREATE TABLE dist_table (a int); +INSERT INTO dist_table SELECT * FROM generate_series(1, 100); +BEGIN; +SET citus.log_local_commands TO ON; +-- trigger local execution +SELECT y FROM test WHERE x = 1; +-- this should be run locally +SELECT create_distributed_table('dist_table', 'a', colocate_with := 'none'); +SELECT count(*) FROM dist_table; +ROLLBACK; DELETE FROM test; DROP TABLE test;