mirror of https://github.com/citusdata/citus.git
Add tests for statement cancellation.
parent
17946b4ea6
commit
37d4c36683
|
@ -0,0 +1,127 @@
|
|||
Parsed test spec with 2 sessions
|
||||
|
||||
starting permutation: s1-timeout s1-sleep10000 s1-reset s1-drop
|
||||
step s1-timeout:
|
||||
SET statement_timeout = '100ms';
|
||||
|
||||
step s1-sleep10000:
|
||||
SELECT pg_sleep(10000) FROM cancel_table WHERE test_id = 1;
|
||||
|
||||
ERROR: canceling statement due to statement timeout
|
||||
step s1-reset:
|
||||
RESET ALL;
|
||||
|
||||
step s1-drop:
|
||||
|
||||
DROP TABLE cancel_table;
|
||||
|
||||
|
||||
starting permutation: s1-timeout s1-sleep10000 s1-reset s2-drop
|
||||
step s1-timeout:
|
||||
SET statement_timeout = '100ms';
|
||||
|
||||
step s1-sleep10000:
|
||||
SELECT pg_sleep(10000) FROM cancel_table WHERE test_id = 1;
|
||||
|
||||
ERROR: canceling statement due to statement timeout
|
||||
step s1-reset:
|
||||
RESET ALL;
|
||||
|
||||
step s2-drop:
|
||||
|
||||
DROP TABLE cancel_table;
|
||||
|
||||
|
||||
starting permutation: s1-timeout s1-begin s1-sleep10000 s1-rollback s1-reset s1-drop
|
||||
step s1-timeout:
|
||||
SET statement_timeout = '100ms';
|
||||
|
||||
step s1-begin:
|
||||
BEGIN;
|
||||
|
||||
step s1-sleep10000:
|
||||
SELECT pg_sleep(10000) FROM cancel_table WHERE test_id = 1;
|
||||
|
||||
ERROR: canceling statement due to statement timeout
|
||||
step s1-rollback:
|
||||
ROLLBACK;
|
||||
|
||||
step s1-reset:
|
||||
RESET ALL;
|
||||
|
||||
step s1-drop:
|
||||
|
||||
DROP TABLE cancel_table;
|
||||
|
||||
|
||||
starting permutation: s1-timeout s1-begin s1-sleep10000 s1-rollback s1-reset s2-drop
|
||||
step s1-timeout:
|
||||
SET statement_timeout = '100ms';
|
||||
|
||||
step s1-begin:
|
||||
BEGIN;
|
||||
|
||||
step s1-sleep10000:
|
||||
SELECT pg_sleep(10000) FROM cancel_table WHERE test_id = 1;
|
||||
|
||||
ERROR: canceling statement due to statement timeout
|
||||
step s1-rollback:
|
||||
ROLLBACK;
|
||||
|
||||
step s1-reset:
|
||||
RESET ALL;
|
||||
|
||||
step s2-drop:
|
||||
|
||||
DROP TABLE cancel_table;
|
||||
|
||||
|
||||
starting permutation: s1-timeout s1-begin s1-update1 s1-sleep10000 s1-rollback s1-reset s1-drop
|
||||
step s1-timeout:
|
||||
SET statement_timeout = '100ms';
|
||||
|
||||
step s1-begin:
|
||||
BEGIN;
|
||||
|
||||
step s1-update1:
|
||||
UPDATE cancel_table SET data = '' WHERE test_id = 1;
|
||||
|
||||
step s1-sleep10000:
|
||||
SELECT pg_sleep(10000) FROM cancel_table WHERE test_id = 1;
|
||||
|
||||
ERROR: canceling statement due to statement timeout
|
||||
step s1-rollback:
|
||||
ROLLBACK;
|
||||
|
||||
step s1-reset:
|
||||
RESET ALL;
|
||||
|
||||
step s1-drop:
|
||||
|
||||
DROP TABLE cancel_table;
|
||||
|
||||
|
||||
starting permutation: s1-timeout s1-begin s1-update1 s1-sleep10000 s1-rollback s1-reset s2-drop
|
||||
step s1-timeout:
|
||||
SET statement_timeout = '100ms';
|
||||
|
||||
step s1-begin:
|
||||
BEGIN;
|
||||
|
||||
step s1-update1:
|
||||
UPDATE cancel_table SET data = '' WHERE test_id = 1;
|
||||
|
||||
step s1-sleep10000:
|
||||
SELECT pg_sleep(10000) FROM cancel_table WHERE test_id = 1;
|
||||
|
||||
ERROR: canceling statement due to statement timeout
|
||||
step s1-rollback:
|
||||
ROLLBACK;
|
||||
|
||||
step s1-reset:
|
||||
RESET ALL;
|
||||
|
||||
step s2-drop:
|
||||
|
||||
DROP TABLE cancel_table;
|
||||
|
|
@ -5,6 +5,6 @@ test: isolation_add_node_vs_reference_table_operations
|
|||
# that come later can be parallelized
|
||||
test: isolation_cluster_management
|
||||
|
||||
test: isolation_dml_vs_repair isolation_copy_placement_vs_copy_placement
|
||||
test: isolation_dml_vs_repair isolation_copy_placement_vs_copy_placement isolation_cancellation
|
||||
test: isolation_concurrent_dml isolation_data_migration
|
||||
test: isolation_drop_shards isolation_copy_placement_vs_modification
|
||||
|
|
|
@ -0,0 +1,80 @@
|
|||
# Tests around cancelling statements. As we can't trigger cancel
|
||||
# interrupts directly, we use statement_timeout instead, which largely
|
||||
# behaves the same as proper cancellation.
|
||||
|
||||
setup
|
||||
{
|
||||
CREATE TABLE cancel_table (test_id integer NOT NULL, data text);
|
||||
SELECT create_distributed_table('cancel_table', 'test_id', 'hash');
|
||||
INSERT INTO cancel_table VALUES(1);
|
||||
}
|
||||
|
||||
teardown
|
||||
{
|
||||
DROP TABLE IF EXISTS cancel_table;
|
||||
}
|
||||
|
||||
session "s1"
|
||||
|
||||
step "s1-begin"
|
||||
{
|
||||
BEGIN;
|
||||
}
|
||||
|
||||
step "s1-commit"
|
||||
{
|
||||
COMMIT;
|
||||
}
|
||||
|
||||
step "s1-rollback"
|
||||
{
|
||||
ROLLBACK;
|
||||
}
|
||||
|
||||
step "s1-sleep10000"
|
||||
{
|
||||
SELECT pg_sleep(10000) FROM cancel_table WHERE test_id = 1;
|
||||
}
|
||||
|
||||
step "s1-timeout"
|
||||
{
|
||||
SET statement_timeout = '100ms';
|
||||
}
|
||||
|
||||
step "s1-update1"
|
||||
{
|
||||
UPDATE cancel_table SET data = '' WHERE test_id = 1;
|
||||
}
|
||||
|
||||
step "s1-reset"
|
||||
{
|
||||
RESET ALL;
|
||||
}
|
||||
|
||||
step "s1-drop"
|
||||
{
|
||||
|
||||
DROP TABLE cancel_table;
|
||||
}
|
||||
|
||||
session "s2"
|
||||
|
||||
step "s2-drop"
|
||||
{
|
||||
|
||||
DROP TABLE cancel_table;
|
||||
}
|
||||
|
||||
# check that statement cancel works for plain selects, drop table
|
||||
# afterwards to make sure sleep on workers is cancelled (thereby not
|
||||
# preventing drop via locks)
|
||||
permutation "s1-timeout" "s1-sleep10000" "s1-reset" "s1-drop"
|
||||
permutation "s1-timeout" "s1-sleep10000" "s1-reset" "s2-drop"
|
||||
|
||||
# check that statement cancel works for selects in transaction
|
||||
permutation "s1-timeout" "s1-begin" "s1-sleep10000" "s1-rollback" "s1-reset" "s1-drop"
|
||||
permutation "s1-timeout" "s1-begin" "s1-sleep10000" "s1-rollback" "s1-reset" "s2-drop"
|
||||
|
||||
# check that statement cancel works for selects in transaction, that previously wrote
|
||||
permutation "s1-timeout" "s1-begin" "s1-update1" "s1-sleep10000" "s1-rollback" "s1-reset" "s1-drop"
|
||||
permutation "s1-timeout" "s1-begin" "s1-update1" "s1-sleep10000" "s1-rollback" "s1-reset" "s2-drop"
|
Loading…
Reference in New Issue