From 0a987e9c0ea9cf50528de2e440c006179b499a54 Mon Sep 17 00:00:00 2001 From: Murat Tuncer Date: Wed, 3 Oct 2018 12:23:27 +0300 Subject: [PATCH] Fix cte subquery failure test --- .../regress/expected/failure_cte_subquery.out | 70 ++++++++----------- src/test/regress/sql/failure_cte_subquery.sql | 19 ++--- 2 files changed, 38 insertions(+), 51 deletions(-) diff --git a/src/test/regress/expected/failure_cte_subquery.out b/src/test/regress/expected/failure_cte_subquery.out index a1bf9cf3b..5a8b9737d 100644 --- a/src/test/regress/expected/failure_cte_subquery.out +++ b/src/test/regress/expected/failure_cte_subquery.out @@ -51,15 +51,9 @@ FROM ERROR: server closed the connection unexpectedly This probably means the server terminated abnormally before or while processing the request. -CONTEXT: while executing command on localhost:57640 +CONTEXT: while executing command on localhost:9060 -- kill at the second copy (pull) -SELECT citus.mitmproxy('conn.allow()'); - mitmproxy ------------ - -(1 row) - -SELECT citus.mitmproxy('conn.onQuery(query="SELECT user_id FROM").kill()'); +SELECT citus.mitmproxy('conn.onQuery(query="SELECT user_id FROM cte_failure.events_table_102250").kill()'); mitmproxy ----------- @@ -91,15 +85,9 @@ FROM WARNING: could not consume data from worker node WARNING: could not consume data from worker node WARNING: could not consume data from worker node -ERROR: failed to execute task 2 +ERROR: failed to execute task 1 -- kill at the third copy (pull) -SELECT citus.mitmproxy('conn.allow()'); - mitmproxy ------------ - -(1 row) - SELECT citus.mitmproxy('conn.onQuery(query="SELECT DISTINCT users_table.user").kill()'); mitmproxy ----------- @@ -131,14 +119,8 @@ FROM WHERE foo.user_id = cte.user_id; WARNING: could not consume data from worker node WARNING: could not consume data from worker node -ERROR: failed to execute task 2 +ERROR: failed to execute task 1 -- cancel at the first copy (push) -SELECT citus.mitmproxy('conn.allow()'); - mitmproxy ------------ - -(1 row) - SELECT citus.mitmproxy('conn.onQuery(query="^COPY").cancel(' || :pid || ')'); mitmproxy ----------- @@ -170,12 +152,6 @@ FROM WHERE foo.user_id = cte.user_id; ERROR: canceling statement due to user request -- cancel at the second copy (pull) -SELECT citus.mitmproxy('conn.allow()'); - mitmproxy ------------ - -(1 row) - SELECT citus.mitmproxy('conn.onQuery(query="SELECT user_id FROM").cancel(' || :pid || ')'); mitmproxy ----------- @@ -207,12 +183,6 @@ FROM WHERE foo.user_id = cte.user_id; ERROR: canceling statement due to user request -- cancel at the third copy (pull) -SELECT citus.mitmproxy('conn.allow()'); - mitmproxy ------------ - -(1 row) - SELECT citus.mitmproxy('conn.onQuery(query="SELECT DISTINCT users_table.user").cancel(' || :pid || ')'); mitmproxy ----------- @@ -267,12 +237,6 @@ SELECT * FROM users_table ORDER BY 1, 2; WITH cte_delete as (DELETE FROM users_table WHERE user_name in ('A', 'D') RETURNING *) INSERT INTO users_table SELECT * FROM cte_delete; -- verify contents are the same -SELECT citus.mitmproxy('conn.allow()'); - mitmproxy ------------ - -(1 row) - SELECT * FROM users_table ORDER BY 1, 2; user_id | user_name ---------+----------- @@ -295,7 +259,7 @@ INSERT INTO users_table SELECT * FROM cte_delete; ERROR: server closed the connection unexpectedly This probably means the server terminated abnormally before or while processing the request. -CONTEXT: while executing command on localhost:57640 +CONTEXT: while executing command on localhost:9060 -- verify contents are the same SELECT citus.mitmproxy('conn.allow()'); mitmproxy @@ -325,7 +289,7 @@ INSERT INTO users_table SELECT * FROM cte_delete; ERROR: server closed the connection unexpectedly This probably means the server terminated abnormally before or while processing the request. -CONTEXT: while executing command on localhost:57640 +CONTEXT: while executing command on localhost:9060 -- verify contents are the same SELECT citus.mitmproxy('conn.allow()'); mitmproxy @@ -397,7 +361,29 @@ SELECT * FROM users_table ORDER BY 1, 2; 5 | E (5 rows) +-- test sequential delete/insert +SELECT citus.mitmproxy('conn.onQuery(query="^DELETE FROM").kill()'); + mitmproxy +----------- + +(1 row) + +BEGIN; +SET LOCAL citus.multi_shard_modify_mode = 'sequential'; +WITH cte_delete as (DELETE FROM users_table WHERE user_name in ('A', 'D') RETURNING *) +INSERT INTO users_table SELECT * FROM cte_delete; +ERROR: server closed the connection unexpectedly + This probably means the server terminated abnormally + before or while processing the request. +CONTEXT: while executing command on localhost:9060 +END; RESET SEARCH_PATH; +SELECT citus.mitmproxy('conn.allow()'); + mitmproxy +----------- + +(1 row) + DROP SCHEMA cte_failure CASCADE; NOTICE: drop cascades to 3 other objects DETAIL: drop cascades to table cte_failure.users_table diff --git a/src/test/regress/sql/failure_cte_subquery.sql b/src/test/regress/sql/failure_cte_subquery.sql index 8ae1ff948..502ef0e28 100644 --- a/src/test/regress/sql/failure_cte_subquery.sql +++ b/src/test/regress/sql/failure_cte_subquery.sql @@ -40,8 +40,7 @@ FROM WHERE foo.user_id = cte.user_id; -- kill at the second copy (pull) -SELECT citus.mitmproxy('conn.allow()'); -SELECT citus.mitmproxy('conn.onQuery(query="SELECT user_id FROM").kill()'); +SELECT citus.mitmproxy('conn.onQuery(query="SELECT user_id FROM cte_failure.events_table_102250").kill()'); WITH cte AS ( WITH local_cte AS ( @@ -68,7 +67,6 @@ FROM WHERE foo.user_id = cte.user_id; -- kill at the third copy (pull) -SELECT citus.mitmproxy('conn.allow()'); SELECT citus.mitmproxy('conn.onQuery(query="SELECT DISTINCT users_table.user").kill()'); WITH cte AS ( @@ -96,7 +94,6 @@ FROM WHERE foo.user_id = cte.user_id; -- cancel at the first copy (push) -SELECT citus.mitmproxy('conn.allow()'); SELECT citus.mitmproxy('conn.onQuery(query="^COPY").cancel(' || :pid || ')'); WITH cte AS ( @@ -124,7 +121,6 @@ FROM WHERE foo.user_id = cte.user_id; -- cancel at the second copy (pull) -SELECT citus.mitmproxy('conn.allow()'); SELECT citus.mitmproxy('conn.onQuery(query="SELECT user_id FROM").cancel(' || :pid || ')'); WITH cte AS ( @@ -152,7 +148,6 @@ FROM WHERE foo.user_id = cte.user_id; -- cancel at the third copy (pull) -SELECT citus.mitmproxy('conn.allow()'); SELECT citus.mitmproxy('conn.onQuery(query="SELECT DISTINCT users_table.user").cancel(' || :pid || ')'); WITH cte AS ( @@ -191,7 +186,6 @@ SELECT * FROM users_table ORDER BY 1, 2; WITH cte_delete as (DELETE FROM users_table WHERE user_name in ('A', 'D') RETURNING *) INSERT INTO users_table SELECT * FROM cte_delete; -- verify contents are the same -SELECT citus.mitmproxy('conn.allow()'); SELECT * FROM users_table ORDER BY 1, 2; -- kill connection during deletion @@ -230,7 +224,14 @@ INSERT INTO users_table SELECT * FROM cte_delete; SELECT citus.mitmproxy('conn.allow()'); SELECT * FROM users_table ORDER BY 1, 2; +-- test sequential delete/insert +SELECT citus.mitmproxy('conn.onQuery(query="^DELETE FROM").kill()'); +BEGIN; +SET LOCAL citus.multi_shard_modify_mode = 'sequential'; +WITH cte_delete as (DELETE FROM users_table WHERE user_name in ('A', 'D') RETURNING *) +INSERT INTO users_table SELECT * FROM cte_delete; +END; + RESET SEARCH_PATH; +SELECT citus.mitmproxy('conn.allow()'); DROP SCHEMA cte_failure CASCADE; - -