{"action":"created","comment":{"url":"https://api.github.com/repos/citusdata/citus/pulls/comments/206118153","pull_request_review_id":141514400,"id":206118153,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwNjExODE1Mw==","diff_hunk":"@@ -0,0 +1,890 @@\n+-- \n+--  Failure tests for COPY to reference tables \n+-- \n+CREATE SCHEMA create_distributed_table_non_empty_failure;\n+SET search_path TO 'create_distributed_table_non_empty_failure';\n+SELECT citus.mitmproxy('conn.allow()');\n+ mitmproxy \n+-----------\n+ \n+(1 row)\n+\n+-- we'll start with replication factor 1 and 2pc\n+SET citus.shard_replication_factor TO 1;\n+SET citus.shard_count to 4;\n+CREATE TABLE test_table(id int, value_1 int);\n+INSERT INTO test_table VALUES (1,1),(2,2),(3,3),(4,4);\n+-- in the first test, kill the first connection we sent from the coordinator\n+SELECT citus.mitmproxy('conn.kill()');\n+ mitmproxy \n+-----------\n+ \n+(1 row)\n+\n+SELECT create_distributed_table('test_table', 'id');\n+ERROR:  connection error: localhost:57640\n+DETAIL:  server closed the connection unexpectedly\n+\tThis probably means the server terminated abnormally\n+\tbefore or while processing the request.\n+SELECT count(*) FROM pg_dist_shard WHERE logicalrelid='create_distributed_table_non_empty_failure.test_table'::regclass;\n+ count \n+-------\n+     0\n+(1 row)\n+\n+-- in the first test, cancel the first connection we sent from the coordinator\n+SELECT citus.mitmproxy('conn.cancel(' ||  pg_backend_pid() || ')');\n+ mitmproxy \n+-----------\n+ \n+(1 row)\n+\n+SELECT create_distributed_table('test_table', 'id');\n+ERROR:  canceling statement due to user request\n+SELECT count(*) FROM pg_dist_shard WHERE logicalrelid='create_distributed_table_non_empty_failure.test_table'::regclass;\n+ count \n+-------\n+     0\n+(1 row)\n+\n+-- kill as soon as the coordinator sends CREATE SCHEMA\n+SELECT citus.mitmproxy('conn.onQuery(query=\"^CREATE SCHEMA\").kill()');\n+ mitmproxy \n+-----------\n+ \n+(1 row)\n+\n+SELECT create_distributed_table('test_table', 'id');\n+ERROR:  server closed the connection unexpectedly\n+\tThis probably means the server terminated abnormally\n+\tbefore or while processing the request.\n+CONTEXT:  while executing command on localhost:57640\n+SELECT citus.mitmproxy('conn.allow()');\n+ mitmproxy \n+-----------\n+ \n+(1 row)\n+\n+SELECT count(*) FROM pg_dist_shard WHERE logicalrelid='create_distributed_table_non_empty_failure.test_table'::regclass;\n+ count \n+-------\n+     0\n+(1 row)\n+\n+SELECT run_command_on_workers($$SELECT count(*) FROM information_schema.schemata WHERE schema_name = 'create_distributed_table_non_empty_failure'$$);\n+ run_command_on_workers \n+------------------------\n+ (localhost,57637,t,1)\n+ (localhost,57640,t,0)\n+(2 rows)\n+\n+-- cancel as soon as the coordinator sends CREATE SCHEMA\n+-- Note: Schema should be created in workers because Citus\n+-- does not check for interrupts until GetRemoteCommandResult is called.\n+-- Since we already sent the command at this stage, the schemas get created in workers\n+SELECT citus.mitmproxy('conn.onQuery(query=\"^CREATE SCHEMA\").cancel(' ||  pg_backend_pid() || ')');\n+ mitmproxy \n+-----------\n+ \n+(1 row)\n+\n+SELECT create_distributed_table('test_table', 'id');\n+ERROR:  canceling statement due to user request\n+SELECT citus.mitmproxy('conn.allow()');\n+ mitmproxy \n+-----------\n+ \n+(1 row)\n+\n+SELECT count(*) FROM pg_dist_shard WHERE logicalrelid='create_distributed_table_non_empty_failure.test_table'::regclass;\n+ count \n+-------\n+     0\n+(1 row)\n+\n+SELECT run_command_on_workers($$SELECT count(*) FROM information_schema.schemata WHERE schema_name = 'create_distributed_table_non_empty_failure'$$);\n+ run_command_on_workers \n+------------------------\n+ (localhost,57637,t,1)\n+ (localhost,57640,t,1)\n+(2 rows)\n+\n+SELECT run_command_on_workers($$DROP SCHEMA IF EXISTS create_distributed_table_non_empty_failure$$);\n+      run_command_on_workers       \n+-----------------------------------\n+ (localhost,57637,t,\"DROP SCHEMA\")\n+ (localhost,57640,t,\"DROP SCHEMA\")\n+(2 rows)\n+\n+-- kill as soon as the coordinator sends begin\n+SELECT citus.mitmproxy('conn.onQuery(query=\"^BEGIN TRANSACTION ISOLATION LEVEL READ COMMITTED\").kill()');\n+ mitmproxy \n+-----------\n+ \n+(1 row)\n+\n+SELECT create_distributed_table('test_table', 'id');\n+WARNING:  connection not open\n+CONTEXT:  while executing command on localhost:57640\n+ERROR:  connection error: localhost:57640\n+DETAIL:  connection not open\n+SELECT citus.mitmproxy('conn.allow()');\n+ mitmproxy \n+-----------\n+ \n+(1 row)\n+\n+SELECT count(*) FROM pg_dist_shard WHERE logicalrelid='create_distributed_table_non_empty_failure.test_table'::regclass;\n+ count \n+-------\n+     0\n+(1 row)\n+\n+SELECT run_command_on_workers($$SELECT count(*) FROM information_schema.schemata WHERE schema_name = 'create_distributed_table_non_empty_failure'$$);\n+ run_command_on_workers \n+------------------------\n+ (localhost,57637,t,1)\n+ (localhost,57640,t,1)\n+(2 rows)\n+\n+-- cancel as soon as the coordinator sends begin\n+-- shards will be created because we ignore cancel requests during the shard creation \n+-- Interrupts are hold in CreateShardsWithRoundRobinPolicy\n+SELECT citus.mitmproxy('conn.onQuery(query=\"^BEGIN TRANSACTION ISOLATION LEVEL READ COMMITTED\").cancel(' ||  pg_backend_pid() || ')');\n+ mitmproxy \n+-----------\n+ \n+(1 row)\n+\n+SELECT create_distributed_table('test_table', 'id');\n+WARNING:  cancel requests are ignored during shard creation\n+NOTICE:  Copying data from local table...\n+ create_distributed_table \n+--------------------------\n+ \n+(1 row)\n+\n+SELECT citus.mitmproxy('conn.allow()');\n+ mitmproxy \n+-----------\n+ \n+(1 row)\n+\n+SELECT count(*) FROM pg_dist_shard WHERE logicalrelid='create_distributed_table_non_empty_failure.test_table'::regclass;\n+ count \n+-------\n+     4\n+(1 row)\n+\n+SELECT run_command_on_workers($$SELECT count(*) FROM information_schema.schemata WHERE schema_name = 'create_distributed_table_non_empty_failure'$$);\n+ run_command_on_workers \n+------------------------\n+ (localhost,57637,t,1)\n+ (localhost,57640,t,1)\n+(2 rows)\n+\n+DROP TABLE test_table ;\n+CREATE TABLE test_table(id int, value_1 int);\n+INSERT INTO test_table VALUES (1,1),(2,2),(3,3),(4,4);\n+-- kill as soon as the coordinator sends CREATE TABLE\n+SELECT citus.mitmproxy('conn.onQuery(query=\"CREATE TABLE\").kill()');\n+ mitmproxy \n+-----------\n+ \n+(1 row)\n+\n+SELECT create_distributed_table('test_table', 'id');\n+ERROR:  server closed the connection unexpectedly\n+\tThis probably means the server terminated abnormally\n+\tbefore or while processing the request.\n+CONTEXT:  while executing command on localhost:57640\n+SELECT count(*) FROM pg_dist_shard WHERE logicalrelid='create_distributed_table_non_empty_failure.test_table'::regclass;\n+ count \n+-------\n+     0\n+(1 row)\n+\n+-- kill as soon as the coordinator sends COPY\n+SELECT citus.mitmproxy('conn.onQuery(query=\"COPY\").kill()');\n+ mitmproxy \n+-----------\n+ \n+(1 row)\n+\n+SELECT create_distributed_table('test_table', 'id');\n+NOTICE:  Copying data from local table...\n+ERROR:  server closed the connection unexpectedly\n+\tThis probably means the server terminated abnormally\n+\tbefore or while processing the request.\n+CONTEXT:  while executing command on localhost:57640\n+SELECT count(*) FROM pg_dist_shard WHERE logicalrelid='create_distributed_table_non_empty_failure.test_table'::regclass;\n+ count \n+-------\n+     0\n+(1 row)\n+\n+-- kill when the COPY is completed, it should be rollbacked properly\n+SELECT citus.mitmproxy('conn.onCommandComplete(command=\"COPY\").kill()');\n+ mitmproxy \n+-----------\n+ \n+(1 row)\n+\n+SELECT create_distributed_table('test_table', 'id');\n+NOTICE:  Copying data from local table...\n+ERROR:  failed to COPY to shard 102043 on localhost:57640\n+SELECT count(*) FROM pg_dist_shard WHERE logicalrelid='create_distributed_table_non_empty_failure.test_table'::regclass;\n+ count \n+-------\n+     0\n+(1 row)\n+\n+-- cancel as soon as the coordinator sends COPY, table \n+-- should not be created and rollbacked properly\n+SELECT citus.mitmproxy('conn.onQuery(query=\"COPY\").cancel(' ||  pg_backend_pid() || ')');\n+ mitmproxy \n+-----------\n+ \n+(1 row)\n+\n+SELECT create_distributed_table('test_table', 'id');\n+NOTICE:  Copying data from local table...\n+ERROR:  canceling statement due to user request\n+SELECT count(*) FROM pg_dist_shard WHERE logicalrelid='create_distributed_table_non_empty_failure.test_table'::regclass;\n+ count \n+-------\n+     0\n+(1 row)\n+\n+-- cancel when the COPY is completed, it should be rollbacked properly\n+SELECT citus.mitmproxy('conn.onCommandComplete(command=\"COPY\").cancel(' ||  pg_backend_pid() || ')');\n+ mitmproxy \n+-----------\n+ \n+(1 row)\n+\n+SELECT create_distributed_table('test_table', 'id');\n+NOTICE:  Copying data from local table...\n+ERROR:  canceling statement due to user request\n+SELECT count(*) FROM pg_dist_shard WHERE logicalrelid='create_distributed_table_non_empty_failure.test_table'::regclass;\n+ count \n+-------\n+     0\n+(1 row)\n+\n+-- immediately kill when we see prepare transaction to see if the command\n+-- successfully rollbacked the created shards\n+-- we don't want to see the prepared transaction numbers in the warnings\n+SET client_min_messages TO ERROR;\n+SELECT citus.mitmproxy('conn.onQuery(query=\"PREPARE TRANSACTION\").kill()');\n+ mitmproxy \n+-----------\n+ \n+(1 row)\n+\n+SELECT create_distributed_table('test_table', 'id');\n+ERROR:  connection not open\n+CONTEXT:  while executing command on localhost:57640\n+SELECT count(*) FROM pg_dist_shard WHERE logicalrelid='create_distributed_table_non_empty_failure.test_table'::regclass;\n+ count \n+-------\n+     0\n+(1 row)\n+\n+-- immediately cancel when we see prepare transaction to see if the command\n+-- successfully rollbacked the created shards\n+SELECT citus.mitmproxy('conn.onQuery(query=\"PREPARE TRANSACTION\").cancel(' ||  pg_backend_pid() || ')');\n+ mitmproxy \n+-----------\n+ \n+(1 row)\n+\n+SELECT create_distributed_table('test_table', 'id');\n+ERROR:  canceling statement due to user request\n+SELECT count(*) FROM pg_dist_shard WHERE logicalrelid='create_distributed_table_non_empty_failure.test_table'::regclass;\n+ count \n+-------\n+     0\n+(1 row)\n+\n+SELECT citus.mitmproxy('conn.allow()');\n+ mitmproxy \n+-----------\n+ \n+(1 row)\n+\n+SELECT recover_prepared_transactions();\n+ recover_prepared_transactions \n+-------------------------------\n+                             1\n+(1 row)\n+\n+-- kill as soon as the coordinator sends COMMIT\n+-- shards should be created and kill should not affect\n+SELECT citus.mitmproxy('conn.onQuery(query=\"^COMMIT PREPARED\").kill()');\n+ mitmproxy \n+-----------\n+ \n+(1 row)\n+\n+SELECT create_distributed_table('test_table', 'id');\n+ create_distributed_table \n+--------------------------\n+ \n+(1 row)\n+\n+SELECT count(*) FROM pg_dist_shard WHERE logicalrelid='create_distributed_table_non_empty_failure.test_table'::regclass;\n+ count \n+-------\n+     4\n+(1 row)\n+\n+SELECT citus.mitmproxy('conn.allow()');\n+ mitmproxy \n+-----------\n+ \n+(1 row)\n+\n+SELECT recover_prepared_transactions();\n+ recover_prepared_transactions \n+-------------------------------\n+                             2\n+(1 row)\n+\n+DROP TABLE test_table ;\n+CREATE TABLE test_table(id int, value_1 int);\n+INSERT INTO test_table VALUES (1,1),(2,2),(3,3),(4,4);\n+-- cancel as soon as the coordinator sends COMMIT\n+-- shards should be created and kill should not affect\n+SELECT citus.mitmproxy('conn.onQuery(query=\"^COMMIT PREPARED\").cancel(' ||  pg_backend_pid() || ')');\n+ mitmproxy \n+-----------\n+ \n+(1 row)\n+\n+SELECT create_distributed_table('test_table', 'id');\n+ create_distributed_table \n+--------------------------\n+ \n+(1 row)\n+\n+SELECT citus.mitmproxy('conn.allow()');\n+ mitmproxy \n+-----------\n+ \n+(1 row)\n+\n+SELECT count(*) FROM pg_dist_shard WHERE logicalrelid='create_distributed_table_non_empty_failure.test_table'::regclass;\n+ count \n+-------\n+     4\n+(1 row)\n+\n+DROP TABLE test_table ;\n+CREATE TABLE test_table(id int, value_1 int);\n+INSERT INTO test_table VALUES (1,1),(2,2),(3,3),(4,4);\n+-- kill as soon as the coordinator sends ROLLBACK\n+-- the command can be rollbacked\n+SELECT citus.mitmproxy('conn.onQuery(query=\"^ROLLBACK\").kill()');\n+ mitmproxy \n+-----------\n+ \n+(1 row)\n+\n+BEGIN;\n+SELECT create_distributed_table('test_table', 'id');\n+ create_distributed_table \n+--------------------------\n+ \n+(1 row)\n+\n+ROLLBACK;\n+SELECT count(*) FROM pg_dist_shard WHERE logicalrelid='create_distributed_table_non_empty_failure.test_table'::regclass;\n+ count \n+-------\n+     0\n+(1 row)\n+\n+-- cancel as soon as the coordinator sends ROLLBACK\n+-- should be rollbacked \n+SELECT citus.mitmproxy('conn.onQuery(query=\"^ROLLBACK\").cancel(' ||  pg_backend_pid() || ')');\n+ mitmproxy \n+-----------\n+ \n+(1 row)\n+\n+BEGIN;\n+SELECT create_distributed_table('test_table', 'id');\n+ create_distributed_table \n+--------------------------\n+ \n+(1 row)\n+\n+ROLLBACK;\n+SELECT citus.mitmproxy('conn.allow()');\n+ mitmproxy \n+-----------\n+ \n+(1 row)\n+\n+SELECT count(*) FROM pg_dist_shard WHERE logicalrelid='create_distributed_table_non_empty_failure.test_table'::regclass;\n+ count \n+-------\n+     0\n+(1 row)\n+\n+CREATE TABLE colocated_table(id int, value_1 int);\n+SELECT create_distributed_table('colocated_table', 'id');\n+ create_distributed_table \n+--------------------------\n+ \n+(1 row)\n+\n+-- Now, cancel the connection just after transaction is opened on\n+-- workers. Note that, when there is a colocated table, interrupts\n+-- are not held and we can cancel in the middle of the execution\n+SELECT citus.mitmproxy('conn.onQuery(query=\"^BEGIN TRANSACTION ISOLATION LEVEL READ COMMITTED\").cancel(' || pg_backend_pid() || ')');\n+ mitmproxy \n+-----------\n+ \n+(1 row)\n+\n+SELECT create_distributed_table('test_table', 'id', colocate_with => 'colocated_table');\n+ERROR:  canceling statement due to user request\n+SELECT count(*) FROM pg_dist_shard WHERE logicalrelid='create_distributed_table_non_empty_failure.test_table'::regclass;\n+ count \n+-------\n+     0\n+(1 row)\n+\n+-- Now, cancel the connection just after transaction is opened on\n+-- workers. Note that, when there is a colocated table, interrupts\n+-- are not held and we can cancel in the middle of the execution\n+SELECT citus.mitmproxy('conn.onQuery(query=\"^BEGIN TRANSACTION ISOLATION LEVEL READ COMMITTED\").kill()');\n+ mitmproxy \n+-----------\n+ \n+(1 row)\n+\n+SELECT create_distributed_table('test_table', 'id', colocate_with => 'colocated_table');\n+ERROR:  connection error: localhost:57640\n+DETAIL:  connection not open\n+SELECT count(*) FROM pg_dist_shard WHERE logicalrelid='create_distributed_table_non_empty_failure.test_table'::regclass;\n+ count \n+-------\n+     0\n+(1 row)\n+\n+SELECT citus.mitmproxy('conn.allow()');\n+ mitmproxy \n+-----------\n+ \n+(1 row)\n+\n+SELECT run_command_on_workers($$SELECT count(*) FROM information_schema.tables WHERE table_schema = 'create_distributed_table_non_empty_failure' and table_name LIKE 'test_table%'$$);\n+ run_command_on_workers \n+------------------------\n+ (localhost,57637,t,0)\n+ (localhost,57640,t,0)\n+(2 rows)\n+\n+-- Now run the same tests with 1pc\n+DROP TABLE colocated_table;\n+DROP TABLE test_table;\n+CREATE TABLE test_table(id int, value_1 int);\n+INSERT INTO test_table VALUES (1,1),(2,2),(3,3),(4,4);\n+SET citus.multi_shard_commit_protocol TO '1pc';\n+SELECT citus.mitmproxy('conn.kill()');\n+ mitmproxy \n+-----------\n+ \n+(1 row)\n+\n+SELECT create_distributed_table('test_table', 'id');\n+ERROR:  connection error: localhost:57640\n+DETAIL:  server closed the connection unexpectedly\n+\tThis probably means the server terminated abnormally\n+\tbefore or while processing the request.\n+SELECT citus.mitmproxy('conn.allow()');\n+ mitmproxy \n+-----------\n+ \n+(1 row)\n+\n+SELECT count(*) FROM pg_dist_shard WHERE logicalrelid='create_distributed_table_non_empty_failure.test_table'::regclass;\n+ count \n+-------\n+     0\n+(1 row)\n+\n+SELECT run_command_on_workers($$SELECT count(*) FROM information_schema.tables WHERE table_schema = 'create_distributed_table_non_empty_failure' and table_name LIKE 'test_table%'$$);\n+ run_command_on_workers \n+------------------------\n+ (localhost,57637,t,0)\n+ (localhost,57640,t,0)\n+(2 rows)\n+\n+-- in the first test, cancel the first connection we sent from the coordinator\n+SELECT citus.mitmproxy('conn.cancel(' ||  pg_backend_pid() || ')');\n+ mitmproxy \n+-----------\n+ \n+(1 row)\n+\n+SELECT create_distributed_table('test_table', 'id');\n+ERROR:  canceling statement due to user request\n+SELECT citus.mitmproxy('conn.allow()');\n+ mitmproxy \n+-----------\n+ \n+(1 row)\n+\n+SELECT count(*) FROM pg_dist_shard WHERE logicalrelid='create_distributed_table_non_empty_failure.test_table'::regclass;\n+ count \n+-------\n+     0\n+(1 row)\n+\n+SELECT run_command_on_workers($$SELECT count(*) FROM information_schema.tables WHERE table_schema = 'create_distributed_table_non_empty_failure' and table_name LIKE 'test_table%'$$);\n+ run_command_on_workers \n+------------------------\n+ (localhost,57637,t,0)\n+ (localhost,57640,t,0)\n+(2 rows)\n+\n+-- kill as soon as the coordinator sends CREATE SCHEMA\n+SELECT citus.mitmproxy('conn.onQuery(query=\"^CREATE SCHEMA\").kill()');\n+ mitmproxy \n+-----------\n+ \n+(1 row)\n+\n+SELECT create_distributed_table('test_table', 'id');\n+ERROR:  server closed the connection unexpectedly\n+\tThis probably means the server terminated abnormally\n+\tbefore or while processing the request.\n+CONTEXT:  while executing command on localhost:57640\n+SELECT citus.mitmproxy('conn.allow()');\n+ mitmproxy \n+-----------\n+ \n+(1 row)\n+\n+SELECT count(*) FROM pg_dist_shard WHERE logicalrelid='create_distributed_table_non_empty_failure.test_table'::regclass;\n+ count \n+-------\n+     0\n+(1 row)\n+\n+SELECT run_command_on_workers($$SELECT count(*) FROM information_schema.tables WHERE table_schema = 'create_distributed_table_non_empty_failure' and table_name LIKE 'test_table%'$$);\n+ run_command_on_workers \n+------------------------\n+ (localhost,57637,t,0)\n+ (localhost,57640,t,0)\n+(2 rows)\n+\n+SELECT run_command_on_workers($$SELECT count(*) FROM information_schema.schemata WHERE schema_name = 'create_distributed_table_non_empty_failure'$$);\n+ run_command_on_workers \n+------------------------\n+ (localhost,57637,t,1)\n+ (localhost,57640,t,1)\n+(2 rows)\n+\n+-- cancel as soon as the coordinator sends CREATE SCHEMA\n+-- Note: Schema should be created in workers because Citus\n+-- does not check for interrupts until GetRemoteCommandResult is called.\n+-- Since we already sent the command at this stage, the schemas get created in workers\n+SELECT citus.mitmproxy('conn.onQuery(query=\"^CREATE SCHEMA\").cancel(' ||  pg_backend_pid() || ')');\n+ mitmproxy \n+-----------\n+ \n+(1 row)\n+\n+SELECT create_distributed_table('test_table', 'id');\n+ERROR:  canceling statement due to user request\n+SELECT citus.mitmproxy('conn.allow()');\n+ mitmproxy \n+-----------\n+ \n+(1 row)\n+\n+SELECT citus.mitmproxy('conn.allow()');\n+ mitmproxy \n+-----------\n+ \n+(1 row)\n+\n+SELECT count(*) FROM pg_dist_shard WHERE logicalrelid='create_distributed_table_non_empty_failure.test_table'::regclass;\n+ count \n+-------\n+     0\n+(1 row)\n+\n+SELECT run_command_on_workers($$SELECT count(*) FROM information_schema.tables WHERE table_schema = 'create_distributed_table_non_empty_failure' and table_name LIKE 'test_table%'$$);\n+ run_command_on_workers \n+------------------------\n+ (localhost,57637,t,0)\n+ (localhost,57640,t,0)\n+(2 rows)\n+\n+SELECT run_command_on_workers($$SELECT count(*) FROM information_schema.schemata WHERE schema_name = 'create_distributed_table_non_empty_failure'$$);\n+ run_command_on_workers \n+------------------------\n+ (localhost,57637,t,1)\n+ (localhost,57640,t,1)\n+(2 rows)\n+\n+SELECT run_command_on_workers($$DROP SCHEMA IF EXISTS create_distributed_table_non_empty_failure$$);\n+      run_command_on_workers       \n+-----------------------------------\n+ (localhost,57637,t,\"DROP SCHEMA\")\n+ (localhost,57640,t,\"DROP SCHEMA\")\n+(2 rows)\n+\n+-- kill as soon as the coordinator sends begin\n+SELECT citus.mitmproxy('conn.onQuery(query=\"^BEGIN TRANSACTION ISOLATION LEVEL READ COMMITTED\").kill()');\n+ mitmproxy \n+-----------\n+ \n+(1 row)\n+\n+SELECT create_distributed_table('test_table', 'id');\n+ERROR:  connection error: localhost:57640\n+DETAIL:  connection not open\n+SELECT citus.mitmproxy('conn.allow()');\n+ mitmproxy \n+-----------\n+ \n+(1 row)\n+\n+SELECT count(*) FROM pg_dist_shard WHERE logicalrelid='create_distributed_table_non_empty_failure.test_table'::regclass;\n+ count \n+-------\n+     0\n+(1 row)\n+\n+SELECT run_command_on_workers($$SELECT count(*) FROM information_schema.schemata WHERE schema_name = 'create_distributed_table_non_empty_failure'$$);\n+ run_command_on_workers \n+------------------------\n+ (localhost,57637,t,1)\n+ (localhost,57640,t,1)\n+(2 rows)\n+\n+-- cancel as soon as the coordinator sends begin\n+-- shards will be created because we ignore cancel requests during the shard creation \n+-- Interrupts are hold in CreateShardsWithRoundRobinPolicy\n+SELECT citus.mitmproxy('conn.onQuery(query=\"^BEGIN TRANSACTION ISOLATION LEVEL READ COMMITTED\").cancel(' ||  pg_backend_pid() || ')');\n+ mitmproxy \n+-----------\n+ \n+(1 row)\n+\n+SELECT create_distributed_table('test_table', 'id');\n+ create_distributed_table \n+--------------------------\n+ \n+(1 row)\n+\n+SELECT citus.mitmproxy('conn.allow()');\n+ mitmproxy \n+-----------\n+ \n+(1 row)\n+\n+SELECT count(*) FROM pg_dist_shard WHERE logicalrelid='create_distributed_table_non_empty_failure.test_table'::regclass;\n+ count \n+-------\n+     4\n+(1 row)\n+\n+SELECT run_command_on_workers($$SELECT count(*) FROM information_schema.schemata WHERE schema_name = 'create_distributed_table_non_empty_failure'$$);\n+ run_command_on_workers \n+------------------------\n+ (localhost,57637,t,1)\n+ (localhost,57640,t,1)\n+(2 rows)\n+\n+DROP TABLE test_table ;\n+CREATE TABLE test_table(id int, value_1 int);\n+INSERT INTO test_table VALUES (1,1),(2,2),(3,3),(4,4);\n+-- kill as soon as the coordinator sends CREATE TABLE\n+SELECT citus.mitmproxy('conn.onQuery(query=\"CREATE TABLE\").kill()');\n+ mitmproxy \n+-----------\n+ \n+(1 row)\n+\n+SELECT create_distributed_table('test_table', 'id');\n+ERROR:  server closed the connection unexpectedly\n+\tThis probably means the server terminated abnormally\n+\tbefore or while processing the request.\n+CONTEXT:  while executing command on localhost:57640\n+SELECT count(*) FROM pg_dist_shard WHERE logicalrelid='create_distributed_table_non_empty_failure.test_table'::regclass;\n+ count \n+-------\n+     0\n+(1 row)\n+\n+-- kill as soon as the coordinator sends COPY\n+SELECT citus.mitmproxy('conn.onQuery(query=\"COPY\").kill()');\n+ mitmproxy \n+-----------\n+ \n+(1 row)\n+\n+SELECT create_distributed_table('test_table', 'id');\n+ERROR:  server closed the connection unexpectedly\n+\tThis probably means the server terminated abnormally\n+\tbefore or while processing the request.\n+CONTEXT:  while executing command on localhost:57640\n+SELECT count(*) FROM pg_dist_shard WHERE logicalrelid='create_distributed_table_non_empty_failure.test_table'::regclass;\n+ count \n+-------\n+     0\n+(1 row)\n+\n+-- kill when the COPY is completed, it should be rollbacked properly\n+SELECT citus.mitmproxy('conn.onCommandComplete(command=\"COPY\").kill()');\n+ mitmproxy \n+-----------\n+ \n+(1 row)\n+\n+SELECT create_distributed_table('test_table', 'id');\n+ERROR:  failed to COPY to shard 102107 on localhost:57640\n+SELECT count(*) FROM pg_dist_shard WHERE logicalrelid='create_distributed_table_non_empty_failure.test_table'::regclass;\n+ count \n+-------\n+     0\n+(1 row)\n+\n+-- cancel as soon as the coordinator sends COPY, table \n+-- should not be created and rollbacked properly\n+SELECT citus.mitmproxy('conn.onQuery(query=\"COPY\").cancel(' ||  pg_backend_pid() || ')');\n+ mitmproxy \n+-----------\n+ \n+(1 row)\n+\n+SELECT create_distributed_table('test_table', 'id');\n+ERROR:  canceling statement due to user request\n+SELECT count(*) FROM pg_dist_shard WHERE logicalrelid='create_distributed_table_non_empty_failure.test_table'::regclass;\n+ count \n+-------\n+     0\n+(1 row)\n+\n+-- cancel when the COPY is completed, it should be rollbacked properly\n+SELECT citus.mitmproxy('conn.onCommandComplete(command=\"COPY\").cancel(' ||  pg_backend_pid() || ')');\n+ mitmproxy \n+-----------\n+ \n+(1 row)\n+\n+SELECT create_distributed_table('test_table', 'id');\n+ERROR:  canceling statement due to user request\n+SELECT count(*) FROM pg_dist_shard WHERE logicalrelid='create_distributed_table_non_empty_failure.test_table'::regclass;\n+ count \n+-------\n+     0\n+(1 row)\n+\n+-- kill as soon as the coordinator sends ROLLBACK\n+-- the command can be rollbacked\n+SELECT citus.mitmproxy('conn.onQuery(query=\"^ROLLBACK\").kill()');\n+ mitmproxy \n+-----------\n+ \n+(1 row)\n+\n+BEGIN;\n+SELECT create_distributed_table('test_table', 'id');\n+ create_distributed_table \n+--------------------------\n+ \n+(1 row)\n+\n+ROLLBACK;\n+SELECT count(*) FROM pg_dist_shard WHERE logicalrelid='create_distributed_table_non_empty_failure.test_table'::regclass;\n+ count \n+-------\n+     0\n+(1 row)\n+\n+-- cancel as soon as the coordinator sends ROLLBACK","path":"src/test/regress/expected/failure_create_distributed_table_non_empty.out","position":396,"original_position":814,"commit_id":"9a01fd519d3c0dd5f1b677f082d0c107c06b3b56","original_commit_id":"7fd2543f651a72f5d66efdb0ff82e471775264cb","user":{"login":"furkansahin","id":6233557,"node_id":"MDQ6VXNlcjYyMzM1NTc=","avatar_url":"https://avatars3.githubusercontent.com/u/6233557?v=4","gravatar_id":"","url":"https://api.github.com/users/furkansahin","html_url":"https://github.com/furkansahin","followers_url":"https://api.github.com/users/furkansahin/followers","following_url":"https://api.github.com/users/furkansahin/following{/other_user}","gists_url":"https://api.github.com/users/furkansahin/gists{/gist_id}","starred_url":"https://api.github.com/users/furkansahin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/furkansahin/subscriptions","organizations_url":"https://api.github.com/users/furkansahin/orgs","repos_url":"https://api.github.com/users/furkansahin/repos","events_url":"https://api.github.com/users/furkansahin/events{/privacy}","received_events_url":"https://api.github.com/users/furkansahin/received_events","type":"User","site_admin":false},"body":"added","created_at":"2018-07-30T12:42:50Z","updated_at":"2018-07-30T12:42:50Z","html_url":"https://github.com/citusdata/citus/pull/2280#discussion_r206118153","pull_request_url":"https://api.github.com/repos/citusdata/citus/pulls/2280","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/citusdata/citus/pulls/comments/206118153"},"html":{"href":"https://github.com/citusdata/citus/pull/2280#discussion_r206118153"},"pull_request":{"href":"https://api.github.com/repos/citusdata/citus/pulls/2280"}},"in_reply_to_id":205638794},"pull_request":{"url":"https://api.github.com/repos/citusdata/citus/pulls/2280","id":200954295,"node_id":"MDExOlB1bGxSZXF1ZXN0MjAwOTU0Mjk1","html_url":"https://github.com/citusdata/citus/pull/2280","diff_url":"https://github.com/citusdata/citus/pull/2280.diff","patch_url":"https://github.com/citusdata/citus/pull/2280.patch","issue_url":"https://api.github.com/repos/citusdata/citus/issues/2280","number":2280,"state":"open","locked":false,"title":"Add create_distributed_table (with data) failure tests","user":{"login":"furkansahin","id":6233557,"node_id":"MDQ6VXNlcjYyMzM1NTc=","avatar_url":"https://avatars3.githubusercontent.com/u/6233557?v=4","gravatar_id":"","url":"https://api.github.com/users/furkansahin","html_url":"https://github.com/furkansahin","followers_url":"https://api.github.com/users/furkansahin/followers","following_url":"https://api.github.com/users/furkansahin/following{/other_user}","gists_url":"https://api.github.com/users/furkansahin/gists{/gist_id}","starred_url":"https://api.github.com/users/furkansahin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/furkansahin/subscriptions","organizations_url":"https://api.github.com/users/furkansahin/orgs","repos_url":"https://api.github.com/users/furkansahin/repos","events_url":"https://api.github.com/users/furkansahin/events{/privacy}","received_events_url":"https://api.github.com/users/furkansahin/received_events","type":"User","site_admin":false},"body":"Adds failure tests for create_distributed_table UDF on non-empty table","created_at":"2018-07-12T10:20:25Z","updated_at":"2018-07-30T12:42:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":"755ee49d8e044e7e518302992d3587180f01dc5f","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":324367882,"node_id":"MDU6TGFiZWwzMjQzNjc4ODI=","url":"https://api.github.com/repos/citusdata/citus/labels/needs%20review","name":"needs review","color":"eeeeee","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/citusdata/citus/pulls/2280/commits","review_comments_url":"https://api.github.com/repos/citusdata/citus/pulls/2280/comments","review_comment_url":"https://api.github.com/repos/citusdata/citus/pulls/comments{/number}","comments_url":"https://api.github.com/repos/citusdata/citus/issues/2280/comments","statuses_url":"https://api.github.com/repos/citusdata/citus/statuses/9a01fd519d3c0dd5f1b677f082d0c107c06b3b56","head":{"label":"citusdata:failure-create_distributed_table-non-empty","ref":"failure-create_distributed_table-non-empty","sha":"9a01fd519d3c0dd5f1b677f082d0c107c06b3b56","user":{"login":"citusdata","id":2545424,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI1NDU0MjQ=","avatar_url":"https://avatars2.githubusercontent.com/u/2545424?v=4","gravatar_id":"","url":"https://api.github.com/users/citusdata","html_url":"https://github.com/citusdata","followers_url":"https://api.github.com/users/citusdata/followers","following_url":"https://api.github.com/users/citusdata/following{/other_user}","gists_url":"https://api.github.com/users/citusdata/gists{/gist_id}","starred_url":"https://api.github.com/users/citusdata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/citusdata/subscriptions","organizations_url":"https://api.github.com/users/citusdata/orgs","repos_url":"https://api.github.com/users/citusdata/repos","events_url":"https://api.github.com/users/citusdata/events{/privacy}","received_events_url":"https://api.github.com/users/citusdata/received_events","type":"Organization","site_admin":false},"repo":{"id":50874442,"node_id":"MDEwOlJlcG9zaXRvcnk1MDg3NDQ0Mg==","name":"citus","full_name":"citusdata/citus","owner":{"login":"citusdata","id":2545424,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI1NDU0MjQ=","avatar_url":"https://avatars2.githubusercontent.com/u/2545424?v=4","gravatar_id":"","url":"https://api.github.com/users/citusdata","html_url":"https://github.com/citusdata","followers_url":"https://api.github.com/users/citusdata/followers","following_url":"https://api.github.com/users/citusdata/following{/other_user}","gists_url":"https://api.github.com/users/citusdata/gists{/gist_id}","starred_url":"https://api.github.com/users/citusdata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/citusdata/subscriptions","organizations_url":"https://api.github.com/users/citusdata/orgs","repos_url":"https://api.github.com/users/citusdata/repos","events_url":"https://api.github.com/users/citusdata/events{/privacy}","received_events_url":"https://api.github.com/users/citusdata/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/citusdata/citus","description":"Scalable PostgreSQL for multi-tenant and real-time workloads","fork":false,"url":"https://api.github.com/repos/citusdata/citus","forks_url":"https://api.github.com/repos/citusdata/citus/forks","keys_url":"https://api.github.com/repos/citusdata/citus/keys{/key_id}","collaborators_url":"https://api.github.com/repos/citusdata/citus/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/citusdata/citus/teams","hooks_url":"https://api.github.com/repos/citusdata/citus/hooks","issue_events_url":"https://api.github.com/repos/citusdata/citus/issues/events{/number}","events_url":"https://api.github.com/repos/citusdata/citus/events","assignees_url":"https://api.github.com/repos/citusdata/citus/assignees{/user}","branches_url":"https://api.github.com/repos/citusdata/citus/branches{/branch}","tags_url":"https://api.github.com/repos/citusdata/citus/tags","blobs_url":"https://api.github.com/repos/citusdata/citus/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/citusdata/citus/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/citusdata/citus/git/refs{/sha}","trees_url":"https://api.github.com/repos/citusdata/citus/git/trees{/sha}","statuses_url":"https://api.github.com/repos/citusdata/citus/statuses/{sha}","languages_url":"https://api.github.com/repos/citusdata/citus/languages","stargazers_url":"https://api.github.com/repos/citusdata/citus/stargazers","contributors_url":"https://api.github.com/repos/citusdata/citus/contributors","subscribers_url":"https://api.github.com/repos/citusdata/citus/subscribers","subscription_url":"https://api.github.com/repos/citusdata/citus/subscription","commits_url":"https://api.github.com/repos/citusdata/citus/commits{/sha}","git_commits_url":"https://api.github.com/repos/citusdata/citus/git/commits{/sha}","comments_url":"https://api.github.com/repos/citusdata/citus/comments{/number}","issue_comment_url":"https://api.github.com/repos/citusdata/citus/issues/comments{/number}","contents_url":"https://api.github.com/repos/citusdata/citus/contents/{+path}","compare_url":"https://api.github.com/repos/citusdata/citus/compare/{base}...{head}","merges_url":"https://api.github.com/repos/citusdata/citus/merges","archive_url":"https://api.github.com/repos/citusdata/citus/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/citusdata/citus/downloads","issues_url":"https://api.github.com/repos/citusdata/citus/issues{/number}","pulls_url":"https://api.github.com/repos/citusdata/citus/pulls{/number}","milestones_url":"https://api.github.com/repos/citusdata/citus/milestones{/number}","notifications_url":"https://api.github.com/repos/citusdata/citus/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/citusdata/citus/labels{/name}","releases_url":"https://api.github.com/repos/citusdata/citus/releases{/id}","deployments_url":"https://api.github.com/repos/citusdata/citus/deployments","created_at":"2016-02-01T21:58:39Z","updated_at":"2018-07-30T11:40:27Z","pushed_at":"2018-07-30T12:42:24Z","git_url":"git://github.com/citusdata/citus.git","ssh_url":"git@github.com:citusdata/citus.git","clone_url":"https://github.com/citusdata/citus.git","svn_url":"https://github.com/citusdata/citus","homepage":"https://www.citusdata.com","size":10897,"stargazers_count":2818,"watchers_count":2818,"language":"C","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":203,"mirror_url":null,"archived":false,"open_issues_count":530,"license":{"key":"agpl-3.0","name":"GNU Affero General Public License v3.0","spdx_id":"AGPL-3.0","url":"https://api.github.com/licenses/agpl-3.0","node_id":"MDc6TGljZW5zZTE="},"forks":203,"open_issues":530,"watchers":2818,"default_branch":"master"}},"base":{"label":"citusdata:master","ref":"master","sha":"6ac0434cf3a96dd7c1ce7b5409c607d8a270a5cf","user":{"login":"citusdata","id":2545424,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI1NDU0MjQ=","avatar_url":"https://avatars2.githubusercontent.com/u/2545424?v=4","gravatar_id":"","url":"https://api.github.com/users/citusdata","html_url":"https://github.com/citusdata","followers_url":"https://api.github.com/users/citusdata/followers","following_url":"https://api.github.com/users/citusdata/following{/other_user}","gists_url":"https://api.github.com/users/citusdata/gists{/gist_id}","starred_url":"https://api.github.com/users/citusdata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/citusdata/subscriptions","organizations_url":"https://api.github.com/users/citusdata/orgs","repos_url":"https://api.github.com/users/citusdata/repos","events_url":"https://api.github.com/users/citusdata/events{/privacy}","received_events_url":"https://api.github.com/users/citusdata/received_events","type":"Organization","site_admin":false},"repo":{"id":50874442,"node_id":"MDEwOlJlcG9zaXRvcnk1MDg3NDQ0Mg==","name":"citus","full_name":"citusdata/citus","owner":{"login":"citusdata","id":2545424,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI1NDU0MjQ=","avatar_url":"https://avatars2.githubusercontent.com/u/2545424?v=4","gravatar_id":"","url":"https://api.github.com/users/citusdata","html_url":"https://github.com/citusdata","followers_url":"https://api.github.com/users/citusdata/followers","following_url":"https://api.github.com/users/citusdata/following{/other_user}","gists_url":"https://api.github.com/users/citusdata/gists{/gist_id}","starred_url":"https://api.github.com/users/citusdata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/citusdata/subscriptions","organizations_url":"https://api.github.com/users/citusdata/orgs","repos_url":"https://api.github.com/users/citusdata/repos","events_url":"https://api.github.com/users/citusdata/events{/privacy}","received_events_url":"https://api.github.com/users/citusdata/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/citusdata/citus","description":"Scalable PostgreSQL for multi-tenant and real-time workloads","fork":false,"url":"https://api.github.com/repos/citusdata/citus","forks_url":"https://api.github.com/repos/citusdata/citus/forks","keys_url":"https://api.github.com/repos/citusdata/citus/keys{/key_id}","collaborators_url":"https://api.github.com/repos/citusdata/citus/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/citusdata/citus/teams","hooks_url":"https://api.github.com/repos/citusdata/citus/hooks","issue_events_url":"https://api.github.com/repos/citusdata/citus/issues/events{/number}","events_url":"https://api.github.com/repos/citusdata/citus/events","assignees_url":"https://api.github.com/repos/citusdata/citus/assignees{/user}","branches_url":"https://api.github.com/repos/citusdata/citus/branches{/branch}","tags_url":"https://api.github.com/repos/citusdata/citus/tags","blobs_url":"https://api.github.com/repos/citusdata/citus/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/citusdata/citus/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/citusdata/citus/git/refs{/sha}","trees_url":"https://api.github.com/repos/citusdata/citus/git/trees{/sha}","statuses_url":"https://api.github.com/repos/citusdata/citus/statuses/{sha}","languages_url":"https://api.github.com/repos/citusdata/citus/languages","stargazers_url":"https://api.github.com/repos/citusdata/citus/stargazers","contributors_url":"https://api.github.com/repos/citusdata/citus/contributors","subscribers_url":"https://api.github.com/repos/citusdata/citus/subscribers","subscription_url":"https://api.github.com/repos/citusdata/citus/subscription","commits_url":"https://api.github.com/repos/citusdata/citus/commits{/sha}","git_commits_url":"https://api.github.com/repos/citusdata/citus/git/commits{/sha}","comments_url":"https://api.github.com/repos/citusdata/citus/comments{/number}","issue_comment_url":"https://api.github.com/repos/citusdata/citus/issues/comments{/number}","contents_url":"https://api.github.com/repos/citusdata/citus/contents/{+path}","compare_url":"https://api.github.com/repos/citusdata/citus/compare/{base}...{head}","merges_url":"https://api.github.com/repos/citusdata/citus/merges","archive_url":"https://api.github.com/repos/citusdata/citus/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/citusdata/citus/downloads","issues_url":"https://api.github.com/repos/citusdata/citus/issues{/number}","pulls_url":"https://api.github.com/repos/citusdata/citus/pulls{/number}","milestones_url":"https://api.github.com/repos/citusdata/citus/milestones{/number}","notifications_url":"https://api.github.com/repos/citusdata/citus/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/citusdata/citus/labels{/name}","releases_url":"https://api.github.com/repos/citusdata/citus/releases{/id}","deployments_url":"https://api.github.com/repos/citusdata/citus/deployments","created_at":"2016-02-01T21:58:39Z","updated_at":"2018-07-30T11:40:27Z","pushed_at":"2018-07-30T12:42:24Z","git_url":"git://github.com/citusdata/citus.git","ssh_url":"git@github.com:citusdata/citus.git","clone_url":"https://github.com/citusdata/citus.git","svn_url":"https://github.com/citusdata/citus","homepage":"https://www.citusdata.com","size":10897,"stargazers_count":2818,"watchers_count":2818,"language":"C","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":203,"mirror_url":null,"archived":false,"open_issues_count":530,"license":{"key":"agpl-3.0","name":"GNU Affero General Public License v3.0","spdx_id":"AGPL-3.0","url":"https://api.github.com/licenses/agpl-3.0","node_id":"MDc6TGljZW5zZTE="},"forks":203,"open_issues":530,"watchers":2818,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/citusdata/citus/pulls/2280"},"html":{"href":"https://github.com/citusdata/citus/pull/2280"},"issue":{"href":"https://api.github.com/repos/citusdata/citus/issues/2280"},"comments":{"href":"https://api.github.com/repos/citusdata/citus/issues/2280/comments"},"review_comments":{"href":"https://api.github.com/repos/citusdata/citus/pulls/2280/comments"},"review_comment":{"href":"https://api.github.com/repos/citusdata/citus/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/citusdata/citus/pulls/2280/commits"},"statuses":{"href":"https://api.github.com/repos/citusdata/citus/statuses/9a01fd519d3c0dd5f1b677f082d0c107c06b3b56"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"furkansahin"}}