diff --git a/src/test/regress/expected/isolation_insert_select_repartition.out b/src/test/regress/expected/isolation_insert_select_repartition.out new file mode 100644 index 000000000..ab2579021 --- /dev/null +++ b/src/test/regress/expected/isolation_insert_select_repartition.out @@ -0,0 +1,249 @@ +Parsed test spec with 2 sessions + +starting permutation: s1-begin s2-begin s1-repartitioned-insert-select s2-delete-from-source s1-end s2-end s1-select-target +step s1-begin: BEGIN; +step s2-begin: BEGIN; +step s1-repartitioned-insert-select: INSERT INTO target_table SELECT * FROM source_table; +step s2-delete-from-source: DELETE FROM source_table; +step s1-end: END; +step s2-end: END; +step s1-select-target: SELECT * FROM target_table ORDER BY a; +a b + +1 1 +2 4 +3 9 +4 16 +5 25 +6 36 +7 49 +8 64 +9 81 +10 100 + +starting permutation: s1-begin s2-begin s1-repartitioned-insert-select s2-update-source s1-end s2-end s1-select-target +step s1-begin: BEGIN; +step s2-begin: BEGIN; +step s1-repartitioned-insert-select: INSERT INTO target_table SELECT * FROM source_table; +step s2-update-source: UPDATE source_table SET b = 50 - b; +step s1-end: END; +step s2-end: END; +step s1-select-target: SELECT * FROM target_table ORDER BY a; +a b + +1 1 +2 4 +3 9 +4 16 +5 25 +6 36 +7 49 +8 64 +9 81 +10 100 + +starting permutation: s1-begin s2-begin s1-repartitioned-insert-select s2-insert-into-source s1-end s2-end s1-select-target +step s1-begin: BEGIN; +step s2-begin: BEGIN; +step s1-repartitioned-insert-select: INSERT INTO target_table SELECT * FROM source_table; +step s2-insert-into-source: INSERT INTO source_table VALUES (0, 0); +step s1-end: END; +step s2-end: END; +step s1-select-target: SELECT * FROM target_table ORDER BY a; +a b + +1 1 +2 4 +3 9 +4 16 +5 25 +6 36 +7 49 +8 64 +9 81 +10 100 + +starting permutation: s1-begin s2-begin s2-delete-from-source s1-repartitioned-insert-select s1-end s2-end s1-select-target +step s1-begin: BEGIN; +step s2-begin: BEGIN; +step s2-delete-from-source: DELETE FROM source_table; +step s1-repartitioned-insert-select: INSERT INTO target_table SELECT * FROM source_table; +step s1-end: END; +step s2-end: END; +step s1-select-target: SELECT * FROM target_table ORDER BY a; +a b + +1 1 +2 4 +3 9 +4 16 +5 25 +6 36 +7 49 +8 64 +9 81 +10 100 + +starting permutation: s1-begin s2-begin s2-update-source s1-repartitioned-insert-select s1-end s2-end s1-select-target +step s1-begin: BEGIN; +step s2-begin: BEGIN; +step s2-update-source: UPDATE source_table SET b = 50 - b; +step s1-repartitioned-insert-select: INSERT INTO target_table SELECT * FROM source_table; +step s1-end: END; +step s2-end: END; +step s1-select-target: SELECT * FROM target_table ORDER BY a; +a b + +1 1 +2 4 +3 9 +4 16 +5 25 +6 36 +7 49 +8 64 +9 81 +10 100 + +starting permutation: s1-begin s2-begin s2-insert-into-source s1-repartitioned-insert-select s1-end s2-end s1-select-target +step s1-begin: BEGIN; +step s2-begin: BEGIN; +step s2-insert-into-source: INSERT INTO source_table VALUES (0, 0); +step s1-repartitioned-insert-select: INSERT INTO target_table SELECT * FROM source_table; +step s1-end: END; +step s2-end: END; +step s1-select-target: SELECT * FROM target_table ORDER BY a; +a b + +1 1 +2 4 +3 9 +4 16 +5 25 +6 36 +7 49 +8 64 +9 81 +10 100 + +starting permutation: s1-begin s2-begin s1-repartitioned-insert-select s2-delete-from-target s1-end s2-end s1-select-target +step s1-begin: BEGIN; +step s2-begin: BEGIN; +step s1-repartitioned-insert-select: INSERT INTO target_table SELECT * FROM source_table; +step s2-delete-from-target: DELETE FROM target_table; +step s1-end: END; +step s2-delete-from-target: <... completed> +step s2-end: END; +step s1-select-target: SELECT * FROM target_table ORDER BY a; +a b + + +starting permutation: s1-begin s2-begin s1-repartitioned-insert-select s2-update-target s1-end s2-end s1-select-target +step s1-begin: BEGIN; +step s2-begin: BEGIN; +step s1-repartitioned-insert-select: INSERT INTO target_table SELECT * FROM source_table; +step s2-update-target: UPDATE target_table SET b = 50 - b; +step s1-end: END; +step s2-update-target: <... completed> +step s2-end: END; +step s1-select-target: SELECT * FROM target_table ORDER BY a; +a b + +1 49 +2 46 +3 41 +4 34 +5 25 +6 14 +7 1 +8 -14 +9 -31 +10 -50 + +starting permutation: s1-begin s2-begin s1-repartitioned-insert-select s2-insert-into-target s1-end s2-end s1-select-target +step s1-begin: BEGIN; +step s2-begin: BEGIN; +step s1-repartitioned-insert-select: INSERT INTO target_table SELECT * FROM source_table; +step s2-insert-into-target: INSERT INTO target_table VALUES (0, 0); +step s1-end: END; +step s2-end: END; +step s1-select-target: SELECT * FROM target_table ORDER BY a; +a b + +0 0 +1 1 +2 4 +3 9 +4 16 +5 25 +6 36 +7 49 +8 64 +9 81 +10 100 + +starting permutation: s1-begin s2-begin s2-delete-from-target s1-repartitioned-insert-select s2-end s1-end s1-select-target +step s1-begin: BEGIN; +step s2-begin: BEGIN; +step s2-delete-from-target: DELETE FROM target_table; +step s1-repartitioned-insert-select: INSERT INTO target_table SELECT * FROM source_table; +step s2-end: END; +step s1-repartitioned-insert-select: <... completed> +step s1-end: END; +step s1-select-target: SELECT * FROM target_table ORDER BY a; +a b + +1 1 +2 4 +3 9 +4 16 +5 25 +6 36 +7 49 +8 64 +9 81 +10 100 + +starting permutation: s1-begin s2-begin s2-update-target s1-repartitioned-insert-select s2-end s1-end s1-select-target +step s1-begin: BEGIN; +step s2-begin: BEGIN; +step s2-update-target: UPDATE target_table SET b = 50 - b; +step s1-repartitioned-insert-select: INSERT INTO target_table SELECT * FROM source_table; +step s2-end: END; +step s1-repartitioned-insert-select: <... completed> +step s1-end: END; +step s1-select-target: SELECT * FROM target_table ORDER BY a; +a b + +1 1 +2 4 +3 9 +4 16 +5 25 +6 36 +7 49 +8 64 +9 81 +10 100 + +starting permutation: s1-begin s2-begin s2-insert-into-target s1-repartitioned-insert-select s2-end s1-end s1-select-target +step s1-begin: BEGIN; +step s2-begin: BEGIN; +step s2-insert-into-target: INSERT INTO target_table VALUES (0, 0); +step s1-repartitioned-insert-select: INSERT INTO target_table SELECT * FROM source_table; +step s2-end: END; +step s1-end: END; +step s1-select-target: SELECT * FROM target_table ORDER BY a; +a b + +0 0 +1 1 +2 4 +3 9 +4 16 +5 25 +6 36 +7 49 +8 64 +9 81 +10 100 diff --git a/src/test/regress/isolation_schedule b/src/test/regress/isolation_schedule index a4bb53818..91f0a8065 100644 --- a/src/test/regress/isolation_schedule +++ b/src/test/regress/isolation_schedule @@ -21,6 +21,7 @@ test: isolation_distributed_transaction_id test: isolation_dump_global_wait_edges test: isolation_citus_dist_activity +test: isolation_insert_select_repartition test: isolation_dml_vs_repair isolation_copy_placement_vs_copy_placement test: isolation_concurrent_dml isolation_data_migration diff --git a/src/test/regress/spec/isolation_insert_select_repartition.spec b/src/test/regress/spec/isolation_insert_select_repartition.spec new file mode 100644 index 000000000..3e2eeeb30 --- /dev/null +++ b/src/test/regress/spec/isolation_insert_select_repartition.spec @@ -0,0 +1,54 @@ +setup +{ + SET citus.shard_replication_factor TO 1; + SET citus.shard_count TO 4; + CREATE TABLE source_table(a int, b int); + SELECT create_distributed_table('source_table', 'a'); + SET citus.shard_count TO 3; + CREATE TABLE target_table(a int, b int); + SELECT create_distributed_table('target_table', 'a'); + + INSERT INTO source_table SELECT i, i * i FROM generate_series(1, 10) i; +} + +teardown +{ + DROP TABLE IF EXISTS source_table; + DROP TABLE IF EXISTS target_table; +} + +session "s1" +step "s1-begin" { BEGIN; } +step "s1-end" { END; } +step "s1-repartitioned-insert-select" { INSERT INTO target_table SELECT * FROM source_table; } +step "s1-select-target" { SELECT * FROM target_table ORDER BY a; } + +session "s2" +step "s2-begin" { BEGIN; } +step "s2-end" { END; } +step "s2-delete-from-source" { DELETE FROM source_table; } +step "s2-update-source" { UPDATE source_table SET b = 50 - b; } +step "s2-insert-into-source" { INSERT INTO source_table VALUES (0, 0); } +step "s2-delete-from-target" { DELETE FROM target_table; } +step "s2-update-target" { UPDATE target_table SET b = 50 - b; } +step "s2-insert-into-target" { INSERT INTO target_table VALUES (0, 0); } + +// INSERT/INTO shouldn't block DML on source_table +permutation "s1-begin" "s2-begin" "s1-repartitioned-insert-select" "s2-delete-from-source" "s1-end" "s2-end" "s1-select-target" +permutation "s1-begin" "s2-begin" "s1-repartitioned-insert-select" "s2-update-source" "s1-end" "s2-end" "s1-select-target" +permutation "s1-begin" "s2-begin" "s1-repartitioned-insert-select" "s2-insert-into-source" "s1-end" "s2-end" "s1-select-target" + +// INSERT/INTO shouldn't be blocked by DML on source_table +permutation "s1-begin" "s2-begin" "s2-delete-from-source" "s1-repartitioned-insert-select" "s1-end" "s2-end" "s1-select-target" +permutation "s1-begin" "s2-begin" "s2-update-source" "s1-repartitioned-insert-select" "s1-end" "s2-end" "s1-select-target" +permutation "s1-begin" "s2-begin" "s2-insert-into-source" "s1-repartitioned-insert-select" "s1-end" "s2-end" "s1-select-target" + +// INSERT/INTO should block UPDATE/DELETE on target_table, but not INSERT +permutation "s1-begin" "s2-begin" "s1-repartitioned-insert-select" "s2-delete-from-target" "s1-end" "s2-end" "s1-select-target" +permutation "s1-begin" "s2-begin" "s1-repartitioned-insert-select" "s2-update-target" "s1-end" "s2-end" "s1-select-target" +permutation "s1-begin" "s2-begin" "s1-repartitioned-insert-select" "s2-insert-into-target" "s1-end" "s2-end" "s1-select-target" + +// INSERT/INTO should be blocked by UPDATE/DELETe on target_table, but not INSERT +permutation "s1-begin" "s2-begin" "s2-delete-from-target" "s1-repartitioned-insert-select" "s2-end" "s1-end" "s1-select-target" +permutation "s1-begin" "s2-begin" "s2-update-target" "s1-repartitioned-insert-select" "s2-end" "s1-end" "s1-select-target" +permutation "s1-begin" "s2-begin" "s2-insert-into-target" "s1-repartitioned-insert-select" "s2-end" "s1-end" "s1-select-target"