Update Tests

niupre/TestDeferredDropAndCleanup
Nitish Upreti 2022-08-30 16:04:02 -07:00
parent 28dceecfff
commit 46c8968603
5 changed files with 123 additions and 34 deletions

View File

@ -1,22 +1,24 @@
#include "isolation_mx_common.include.spec"
setup
{
SET citus.shard_count to 2;
SET citus.shard_replication_factor to 1;
SELECT setval('pg_dist_shardid_seq', 1500000);
-- Cleanup any orphan shards that might be left over from a previous run.
CREATE OR REPLACE FUNCTION run_try_drop_marked_shards()
RETURNS VOID
AS 'citus'
LANGUAGE C STRICT VOLATILE;
SELECT run_try_drop_marked_shards();
CREATE TABLE to_split_table (id int, value int);
SELECT create_distributed_table('to_split_table', 'id');
}
teardown
{
-- Cleanup any orphan shards that might be left over from a previous run.
CREATE OR REPLACE FUNCTION run_try_drop_marked_shards()
RETURNS VOID
AS 'citus'
LANGUAGE C STRICT VOLATILE;
SELECT run_try_drop_marked_shards();
DROP TABLE to_split_table;
}
@ -71,6 +73,21 @@ step "s1-copy"
COPY to_split_table FROM PROGRAM 'echo "1,1\n2,2\n3,3\n4,4\n5,5"' WITH CSV;
}
step "s1-lock-to-split-shard"
{
SELECT run_commands_on_session_level_connection_to_node('BEGIN; LOCK TABLE to_split_table_1500002 IN ACCESS SHARE MODE;');
}
step "s1-start-connection"
{
SELECT start_session_level_connection_to_node('localhost', 57638);
}
step "s1-stop-connection"
{
SELECT stop_session_level_connection_to_node();
}
step "s1-blocking-shard-split"
{
SELECT pg_catalog.citus_split_shard_by_split_points(
@ -92,6 +109,23 @@ step "s2-begin"
BEGIN;
}
step "s2-print-locks"
{
SELECT * FROM master_run_on_worker(
ARRAY['localhost']::text[],
ARRAY[57638]::int[],
ARRAY[
'SELECT CONCAT(relation::regclass, ''-'', locktype, ''-'', mode) AS LockInfo FROM pg_locks
WHERE relation::regclass::text = ''to_split_table_1500002'';'
]::text[],
false);
}
step "s2-show-pg_dist_cleanup"
{
SELECT object_name, object_type, policy_type FROM pg_dist_cleanup;
}
step "s2-blocking-shard-split"
{
SELECT pg_catalog.citus_split_shard_by_split_points(
@ -151,3 +185,8 @@ permutation "s1-insert" "s1-begin" "s1-blocking-shard-split" "s2-blocking-shard-
permutation "s1-load-cache" "s1-begin" "s1-select" "s2-begin" "s2-blocking-shard-split" "s1-ddl" "s2-commit" "s1-commit" "s2-print-cluster" "s2-print-index-count"
// The same tests without loading the cache at first
permutation "s1-begin" "s1-select" "s2-begin" "s2-blocking-shard-split" "s1-ddl" "s2-commit" "s1-commit" "s2-print-cluster" "s2-print-index-count"
// With Deferred drop, AccessShareLock (acquired by SELECTS) do not block split from completion.
permutation "s1-load-cache" "s1-start-connection" "s1-lock-to-split-shard" "s2-print-locks" "s2-blocking-shard-split" "s2-print-locks" "s2-show-pg_dist_cleanup" "s1-stop-connection"
// The same test above without loading the cache at first
permutation "s1-start-connection" "s1-lock-to-split-shard" "s2-print-locks" "s2-blocking-shard-split" "s2-print-cluster" "s2-show-pg_dist_cleanup" "s1-stop-connection"

View File

@ -2,15 +2,9 @@ setup
{
SELECT setval('pg_dist_shardid_seq', 1500000);
SET citus.shard_count to 2;
SET citus.next_operation_id to 17;
SET citus.shard_replication_factor to 1;
-- Cleanup any orphan shards that might be left over from a previous run.
CREATE OR REPLACE FUNCTION run_try_drop_marked_shards()
RETURNS VOID
AS 'citus'
LANGUAGE C STRICT VOLATILE;
SELECT run_try_drop_marked_shards();
CREATE TABLE reference_table (id int PRIMARY KEY, value int);
SELECT create_reference_table('reference_table');
@ -20,6 +14,13 @@ setup
teardown
{
-- Cleanup any orphan shards that might be left over from a previous run.
CREATE OR REPLACE FUNCTION run_try_drop_marked_shards()
RETURNS VOID
AS 'citus'
LANGUAGE C STRICT VOLATILE;
SELECT run_try_drop_marked_shards();
DROP TABLE table_to_split CASCADE;
DROP TABLE reference_table CASCADE;
}

View File

@ -1,3 +1,5 @@
#include "isolation_mx_common.include.spec"
// Test scenario for nonblocking split and concurrent INSERT/UPDATE/DELETE
// session s1 - Executes non-blocking shard split
// session s2 - Does concurrent writes
@ -10,6 +12,12 @@ setup
SET citus.shard_replication_factor to 1;
SELECT setval('pg_dist_shardid_seq', 1500000);
CREATE TABLE to_split_table (id int PRIMARY KEY, value int);
SELECT create_distributed_table('to_split_table', 'id');
}
teardown
{
-- Cleanup any orphan shards that might be left over from a previous run.
CREATE OR REPLACE FUNCTION run_try_drop_marked_shards()
RETURNS VOID
@ -17,12 +25,6 @@ setup
LANGUAGE C STRICT VOLATILE;
SELECT run_try_drop_marked_shards();
CREATE TABLE to_split_table (id int PRIMARY KEY, value int);
SELECT create_distributed_table('to_split_table', 'id');
}
teardown
{
DROP TABLE to_split_table;
}
@ -41,6 +43,21 @@ step "s1-load-cache"
TRUNCATE to_split_table;
}
step "s1-lock-to-split-shard"
{
SELECT run_commands_on_session_level_connection_to_node('BEGIN; LOCK TABLE to_split_table_1500001 IN ACCESS SHARE MODE;');
}
step "s1-start-connection"
{
SELECT start_session_level_connection_to_node('localhost', 57637);
}
step "s1-stop-connection"
{
SELECT stop_session_level_connection_to_node();
}
step "s1-non-blocking-shard-split"
{
SELECT pg_catalog.citus_split_shard_by_split_points(
@ -88,6 +105,32 @@ step "s2-end"
COMMIT;
}
step "s2-non-blocking-shard-split"
{
SELECT pg_catalog.citus_split_shard_by_split_points(
1500001,
ARRAY['-1073741824'],
ARRAY[1, 2],
'force_logical');
}
step "s2-print-locks"
{
SELECT * FROM master_run_on_worker(
ARRAY['localhost']::text[],
ARRAY[57637]::int[],
ARRAY[
'SELECT CONCAT(relation::regclass, ''-'', locktype, ''-'', mode) AS LockInfo FROM pg_locks
WHERE relation::regclass::text = ''to_split_table_1500001'';'
]::text[],
false);
}
step "s2-show-pg_dist_cleanup"
{
SELECT object_name, object_type, policy_type FROM pg_dist_cleanup;
}
step "s2-print-cluster"
{
-- row count per shard
@ -163,3 +206,9 @@ permutation "s1-load-cache" "s2-print-cluster" "s3-acquire-advisory-lock" "s1-be
permutation "s2-print-cluster" "s3-acquire-advisory-lock" "s1-begin" "s2-begin" "s1-non-blocking-shard-split" "s2-insert" "s2-end" "s2-print-cluster" "s3-release-advisory-lock" "s1-end" "s2-print-cluster"
permutation "s2-insert" "s2-print-cluster" "s3-acquire-advisory-lock" "s1-begin" "s1-non-blocking-shard-split" "s2-update" "s3-release-advisory-lock" "s1-end" "s2-print-cluster"
permutation "s2-insert" "s2-print-cluster" "s3-acquire-advisory-lock" "s1-begin" "s1-non-blocking-shard-split" "s2-delete" "s3-release-advisory-lock" "s1-end" "s2-print-cluster"
// With Deferred drop, AccessShareLock (acquired by SELECTS) do not block split from completion.
permutation "s1-load-cache" "s1-start-connection" "s1-lock-to-split-shard" "s2-print-locks" "s2-non-blocking-shard-split" "s2-print-locks" "s2-show-pg_dist_cleanup" "s1-stop-connection"
// The same test above without loading the cache at first
permutation "s1-start-connection" "s1-lock-to-split-shard" "s2-print-locks" "s2-non-blocking-shard-split" "s2-print-cluster" "s2-show-pg_dist_cleanup" "s1-stop-connection"

View File

@ -10,13 +10,6 @@ setup
SET citus.shard_count to 2;
SET citus.shard_replication_factor to 1;
-- Cleanup any orphan shards that might be left over from a previous run.
CREATE OR REPLACE FUNCTION run_try_drop_marked_shards()
RETURNS VOID
AS 'citus'
LANGUAGE C STRICT VOLATILE;
SELECT run_try_drop_marked_shards();
CREATE TABLE reference_table (id int PRIMARY KEY, value int);
SELECT create_reference_table('reference_table');
@ -26,6 +19,13 @@ setup
teardown
{
-- Cleanup any orphan shards that might be left over from a previous run.
CREATE OR REPLACE FUNCTION run_try_drop_marked_shards()
RETURNS VOID
AS 'citus'
LANGUAGE C STRICT VOLATILE;
SELECT run_try_drop_marked_shards();
DROP TABLE table_to_split CASCADE;
DROP TABLE reference_table CASCADE;
}

View File

@ -9,13 +9,6 @@ setup
SET citus.shard_replication_factor to 1;
SELECT setval('pg_dist_shardid_seq', 1500000);
-- Cleanup any orphan shards that might be left over from a previous run.
CREATE OR REPLACE FUNCTION run_try_drop_marked_shards()
RETURNS VOID
AS 'citus'
LANGUAGE C STRICT VOLATILE;
SELECT run_try_drop_marked_shards();
CREATE TABLE to_split_table (id int NOT NULL, value int);
CREATE UNIQUE INDEX split_table_index ON to_split_table(id);
ALTER TABLE to_split_table REPLICA IDENTITY USING INDEX split_table_index;
@ -25,6 +18,13 @@ setup
teardown
{
-- Cleanup any orphan shards that might be left over from a previous run.
CREATE OR REPLACE FUNCTION run_try_drop_marked_shards()
RETURNS VOID
AS 'citus'
LANGUAGE C STRICT VOLATILE;
SELECT run_try_drop_marked_shards();
DROP TABLE to_split_table CASCADE;
}