mirror of https://github.com/citusdata/citus.git
Add failure test for insert/select pushdown
parent
b15d1eee62
commit
c7efd8aff0
|
@ -0,0 +1,150 @@
|
|||
--
|
||||
-- failure_insert_select_pushdown
|
||||
--
|
||||
-- performs failure/cancellation test for insert/select pushed down to shards.
|
||||
--
|
||||
SELECT citus.mitmproxy('conn.allow()');
|
||||
mitmproxy
|
||||
-----------
|
||||
|
||||
(1 row)
|
||||
|
||||
CREATE SCHEMA insert_select_pushdown;
|
||||
SET SEARCH_PATH=insert_select_pushdown;
|
||||
SET citus.shard_count to 2;
|
||||
SET citus.shard_replication_factor to 1;
|
||||
SELECT pg_backend_pid() as pid \gset
|
||||
CREATE TABLE events_table(user_id int, event_id int, event_type int);
|
||||
CREATE TABLE events_summary(user_id int, event_id int, event_count int);
|
||||
SELECT create_distributed_table('events_table', 'user_id');
|
||||
create_distributed_table
|
||||
--------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
SELECT create_distributed_table('events_summary', 'user_id');
|
||||
create_distributed_table
|
||||
--------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
INSERT INTO events_table VALUES (1, 1, 3 ), (1, 2, 1), (1, 3, 2), (2, 4, 3), (3, 5, 1), (4, 7, 1), (4, 1, 9), (4, 3, 2);
|
||||
SELECT count(*) FROM events_summary;
|
||||
count
|
||||
-------
|
||||
0
|
||||
(1 row)
|
||||
|
||||
-- insert/select from one distributed table to another
|
||||
-- kill worker query
|
||||
SELECT citus.mitmproxy('conn.onQuery(query="^INSERT INTO insert_select_pushdown").kill()');
|
||||
mitmproxy
|
||||
-----------
|
||||
|
||||
(1 row)
|
||||
|
||||
INSERT INTO events_summary SELECT user_id, event_id, count(*) FROM events_table GROUP BY 1,2;
|
||||
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
|
||||
--verify nothing is modified
|
||||
SELECT citus.mitmproxy('conn.allow()');
|
||||
mitmproxy
|
||||
-----------
|
||||
|
||||
(1 row)
|
||||
|
||||
SELECT count(*) FROM events_summary;
|
||||
count
|
||||
-------
|
||||
0
|
||||
(1 row)
|
||||
|
||||
-- cancel worker query
|
||||
SELECT citus.mitmproxy('conn.onQuery(query="^INSERT INTO insert_select_pushdown").cancel(' || :pid || ')');
|
||||
mitmproxy
|
||||
-----------
|
||||
|
||||
(1 row)
|
||||
|
||||
INSERT INTO events_summary SELECT user_id, event_id, count(*) FROM events_table GROUP BY 1,2;
|
||||
ERROR: canceling statement due to user request
|
||||
--verify nothing is modified
|
||||
SELECT citus.mitmproxy('conn.allow()');
|
||||
mitmproxy
|
||||
-----------
|
||||
|
||||
(1 row)
|
||||
|
||||
SELECT count(*) FROM events_summary;
|
||||
count
|
||||
-------
|
||||
0
|
||||
(1 row)
|
||||
|
||||
-- test self insert/select
|
||||
SELECT count(*) FROM events_table;
|
||||
count
|
||||
-------
|
||||
8
|
||||
(1 row)
|
||||
|
||||
-- kill worker query
|
||||
SELECT citus.mitmproxy('conn.onQuery(query="^INSERT INTO insert_select_pushdown").kill()');
|
||||
mitmproxy
|
||||
-----------
|
||||
|
||||
(1 row)
|
||||
|
||||
INSERT INTO events_table SELECT * FROM events_table;
|
||||
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
|
||||
--verify nothing is modified
|
||||
SELECT citus.mitmproxy('conn.allow()');
|
||||
mitmproxy
|
||||
-----------
|
||||
|
||||
(1 row)
|
||||
|
||||
SELECT count(*) FROM events_table;
|
||||
count
|
||||
-------
|
||||
8
|
||||
(1 row)
|
||||
|
||||
-- cancel worker query
|
||||
SELECT citus.mitmproxy('conn.onQuery(query="^INSERT INTO insert_select_pushdown").cancel(' || :pid || ')');
|
||||
mitmproxy
|
||||
-----------
|
||||
|
||||
(1 row)
|
||||
|
||||
INSERT INTO events_table SELECT * FROM events_table;
|
||||
ERROR: canceling statement due to user request
|
||||
--verify nothing is modified
|
||||
SELECT citus.mitmproxy('conn.allow()');
|
||||
mitmproxy
|
||||
-----------
|
||||
|
||||
(1 row)
|
||||
|
||||
SELECT count(*) FROM events_table;
|
||||
count
|
||||
-------
|
||||
8
|
||||
(1 row)
|
||||
|
||||
RESET SEARCH_PATH;
|
||||
SELECT citus.mitmproxy('conn.allow()');
|
||||
mitmproxy
|
||||
-----------
|
||||
|
||||
(1 row)
|
||||
|
||||
DROP SCHEMA insert_select_pushdown CASCADE;
|
||||
NOTICE: drop cascades to 2 other objects
|
||||
DETAIL: drop cascades to table insert_select_pushdown.events_table
|
||||
drop cascades to table insert_select_pushdown.events_summary
|
|
@ -25,3 +25,4 @@ test: failure_vacuum
|
|||
test: failure_single_select
|
||||
test: failure_ref_tables
|
||||
test: failure_real_time_select
|
||||
test: failure_insert_select_pushdown
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
--
|
||||
-- failure_insert_select_pushdown
|
||||
--
|
||||
-- performs failure/cancellation test for insert/select pushed down to shards.
|
||||
--
|
||||
SELECT citus.mitmproxy('conn.allow()');
|
||||
|
||||
CREATE SCHEMA insert_select_pushdown;
|
||||
SET SEARCH_PATH=insert_select_pushdown;
|
||||
SET citus.shard_count to 2;
|
||||
SET citus.shard_replication_factor to 1;
|
||||
SELECT pg_backend_pid() as pid \gset
|
||||
|
||||
CREATE TABLE events_table(user_id int, event_id int, event_type int);
|
||||
CREATE TABLE events_summary(user_id int, event_id int, event_count int);
|
||||
SELECT create_distributed_table('events_table', 'user_id');
|
||||
SELECT create_distributed_table('events_summary', 'user_id');
|
||||
|
||||
INSERT INTO events_table VALUES (1, 1, 3 ), (1, 2, 1), (1, 3, 2), (2, 4, 3), (3, 5, 1), (4, 7, 1), (4, 1, 9), (4, 3, 2);
|
||||
|
||||
|
||||
SELECT count(*) FROM events_summary;
|
||||
|
||||
-- insert/select from one distributed table to another
|
||||
|
||||
-- kill worker query
|
||||
SELECT citus.mitmproxy('conn.onQuery(query="^INSERT INTO insert_select_pushdown").kill()');
|
||||
INSERT INTO events_summary SELECT user_id, event_id, count(*) FROM events_table GROUP BY 1,2;
|
||||
|
||||
--verify nothing is modified
|
||||
SELECT citus.mitmproxy('conn.allow()');
|
||||
SELECT count(*) FROM events_summary;
|
||||
|
||||
-- cancel worker query
|
||||
SELECT citus.mitmproxy('conn.onQuery(query="^INSERT INTO insert_select_pushdown").cancel(' || :pid || ')');
|
||||
INSERT INTO events_summary SELECT user_id, event_id, count(*) FROM events_table GROUP BY 1,2;
|
||||
|
||||
--verify nothing is modified
|
||||
SELECT citus.mitmproxy('conn.allow()');
|
||||
SELECT count(*) FROM events_summary;
|
||||
|
||||
-- test self insert/select
|
||||
SELECT count(*) FROM events_table;
|
||||
|
||||
-- kill worker query
|
||||
SELECT citus.mitmproxy('conn.onQuery(query="^INSERT INTO insert_select_pushdown").kill()');
|
||||
INSERT INTO events_table SELECT * FROM events_table;
|
||||
|
||||
--verify nothing is modified
|
||||
SELECT citus.mitmproxy('conn.allow()');
|
||||
SELECT count(*) FROM events_table;
|
||||
|
||||
-- cancel worker query
|
||||
SELECT citus.mitmproxy('conn.onQuery(query="^INSERT INTO insert_select_pushdown").cancel(' || :pid || ')');
|
||||
INSERT INTO events_table SELECT * FROM events_table;
|
||||
|
||||
--verify nothing is modified
|
||||
SELECT citus.mitmproxy('conn.allow()');
|
||||
SELECT count(*) FROM events_table;
|
||||
|
||||
|
||||
RESET SEARCH_PATH;
|
||||
SELECT citus.mitmproxy('conn.allow()');
|
||||
DROP SCHEMA insert_select_pushdown CASCADE;
|
Loading…
Reference in New Issue