Simple isolationtester dml vs. repair tests.

pull/917/head
Andres Freund 2016-10-26 06:41:02 -07:00
parent 121b868da5
commit dfe7b357c5
3 changed files with 311 additions and 0 deletions

View File

@ -0,0 +1,200 @@
Parsed test spec with 2 sessions
starting permutation: s2-invalidate-57637 s1-begin s1-insertone s2-repair s1-commit
master_create_worker_shards
step s2-invalidate-57637:
UPDATE pg_dist_shard_placement SET shardstate = '3' WHERE shardid = 102008 AND nodeport = 57637;
step s1-begin:
BEGIN;
step s1-insertone:
INSERT INTO test_table VALUES(1, 1);
step s2-repair:
SELECT master_copy_shard_placement(102008, 'localhost', 57638, 'localhost', 57637);
<waiting ...>
step s1-commit:
COMMIT;
step s2-repair: <... completed>
master_copy_shard_placement
starting permutation: s1-insertone s2-invalidate-57637 s1-begin s1-insertall s2-repair s1-commit
master_create_worker_shards
step s1-insertone:
INSERT INTO test_table VALUES(1, 1);
step s2-invalidate-57637:
UPDATE pg_dist_shard_placement SET shardstate = '3' WHERE shardid = 102008 AND nodeport = 57637;
step s1-begin:
BEGIN;
step s1-insertall:
INSERT INTO test_table SELECT test_id, data+1 FROM test_table;
step s2-repair:
SELECT master_copy_shard_placement(102008, 'localhost', 57638, 'localhost', 57637);
<waiting ...>
step s1-commit:
COMMIT;
step s2-repair: <... completed>
master_copy_shard_placement
starting permutation: s2-invalidate-57637 s2-begin s2-repair s1-insertone s2-commit s2-invalidate-57638 s1-display s2-invalidate-57637 s2-revalidate-57638 s1-display
master_create_worker_shards
step s2-invalidate-57637:
UPDATE pg_dist_shard_placement SET shardstate = '3' WHERE shardid = 102008 AND nodeport = 57637;
step s2-begin:
BEGIN;
step s2-repair:
SELECT master_copy_shard_placement(102008, 'localhost', 57638, 'localhost', 57637);
master_copy_shard_placement
step s1-insertone:
INSERT INTO test_table VALUES(1, 1);
<waiting ...>
step s2-commit:
COMMIT;
step s1-insertone: <... completed>
step s2-invalidate-57638:
UPDATE pg_dist_shard_placement SET shardstate = '3' WHERE shardid = 102008 AND nodeport = 57638;
step s1-display:
SELECT * FROM test_table WHERE test_id = 1;
test_id data
1 1
step s2-invalidate-57637:
UPDATE pg_dist_shard_placement SET shardstate = '3' WHERE shardid = 102008 AND nodeport = 57637;
step s2-revalidate-57638:
UPDATE pg_dist_shard_placement SET shardstate = '1' WHERE shardid = 102008 AND nodeport = 57638;
step s1-display:
SELECT * FROM test_table WHERE test_id = 1;
test_id data
1 1
starting permutation: s2-invalidate-57637 s1-prepared-insertone s2-begin s2-repair s1-prepared-insertone s2-commit s2-invalidate-57638 s1-display s2-invalidate-57637 s2-revalidate-57638 s1-display
master_create_worker_shards
step s2-invalidate-57637:
UPDATE pg_dist_shard_placement SET shardstate = '3' WHERE shardid = 102008 AND nodeport = 57637;
step s1-prepared-insertone:
EXECUTE insertone;
step s2-begin:
BEGIN;
step s2-repair:
SELECT master_copy_shard_placement(102008, 'localhost', 57638, 'localhost', 57637);
master_copy_shard_placement
step s1-prepared-insertone:
EXECUTE insertone;
<waiting ...>
step s2-commit:
COMMIT;
step s1-prepared-insertone: <... completed>
error in steps s2-commit s1-prepared-insertone: ERROR: prepared modifications cannot be executed on a shard while it is being copied
step s2-invalidate-57638:
UPDATE pg_dist_shard_placement SET shardstate = '3' WHERE shardid = 102008 AND nodeport = 57638;
step s1-display:
SELECT * FROM test_table WHERE test_id = 1;
test_id data
1 1
step s2-invalidate-57637:
UPDATE pg_dist_shard_placement SET shardstate = '3' WHERE shardid = 102008 AND nodeport = 57637;
step s2-revalidate-57638:
UPDATE pg_dist_shard_placement SET shardstate = '1' WHERE shardid = 102008 AND nodeport = 57638;
step s1-display:
SELECT * FROM test_table WHERE test_id = 1;
test_id data
1 1
starting permutation: s2-invalidate-57637 s1-insertone s1-prepared-insertall s2-begin s2-repair s1-prepared-insertall s2-commit s2-invalidate-57638 s1-display s2-invalidate-57637 s2-revalidate-57638 s1-display
master_create_worker_shards
step s2-invalidate-57637:
UPDATE pg_dist_shard_placement SET shardstate = '3' WHERE shardid = 102008 AND nodeport = 57637;
step s1-insertone:
INSERT INTO test_table VALUES(1, 1);
step s1-prepared-insertall:
EXECUTE insertall;
step s2-begin:
BEGIN;
step s2-repair:
SELECT master_copy_shard_placement(102008, 'localhost', 57638, 'localhost', 57637);
master_copy_shard_placement
step s1-prepared-insertall:
EXECUTE insertall;
<waiting ...>
step s2-commit:
COMMIT;
step s1-prepared-insertall: <... completed>
error in steps s2-commit s1-prepared-insertall: ERROR: prepared modifications cannot be executed on a shard while it is being copied
step s2-invalidate-57638:
UPDATE pg_dist_shard_placement SET shardstate = '3' WHERE shardid = 102008 AND nodeport = 57638;
step s1-display:
SELECT * FROM test_table WHERE test_id = 1;
test_id data
1 1
1 2
step s2-invalidate-57637:
UPDATE pg_dist_shard_placement SET shardstate = '3' WHERE shardid = 102008 AND nodeport = 57637;
step s2-revalidate-57638:
UPDATE pg_dist_shard_placement SET shardstate = '1' WHERE shardid = 102008 AND nodeport = 57638;
step s1-display:
SELECT * FROM test_table WHERE test_id = 1;
test_id data
1 1
1 2

View File

@ -1,2 +1,3 @@
test: isolation_cluster_management test: isolation_cluster_management
test: isolation_concurrent_dml test: isolation_concurrent_dml
test: isolation_dml_vs_repair

View File

@ -0,0 +1,110 @@
setup
{
ALTER SEQUENCE pg_catalog.pg_dist_shardid_seq RESTART 102008;
CREATE TABLE test_table (test_id integer NOT NULL, data int);
SELECT master_create_distributed_table('test_table', 'test_id', 'hash');
SELECT master_create_worker_shards('test_table', 1, 2);
}
teardown
{
DROP TABLE IF EXISTS test_table CASCADE;
}
session "s1"
setup
{
DEALLOCATE all;
TRUNCATE test_table;
PREPARE insertone AS INSERT INTO test_table VALUES(1, 1);
PREPARE insertall AS INSERT INTO test_table SELECT test_id, data+1 FROM test_table;
}
step "s1-begin"
{
BEGIN;
}
step "s1-insertone"
{
INSERT INTO test_table VALUES(1, 1);
}
step "s1-prepared-insertone"
{
EXECUTE insertone;
}
step "s1-insertall"
{
INSERT INTO test_table SELECT test_id, data+1 FROM test_table;
}
step "s1-prepared-insertall"
{
EXECUTE insertall;
}
step "s1-display"
{
SELECT * FROM test_table WHERE test_id = 1;
}
step "s1-commit"
{
COMMIT;
}
session "s2"
step "s2-begin"
{
BEGIN;
}
step "s2-invalidate-57637"
{
UPDATE pg_dist_shard_placement SET shardstate = '3' WHERE shardid = 102008 AND nodeport = 57637;
}
step "s2-revalidate-57637"
{
UPDATE pg_dist_shard_placement SET shardstate = '1' WHERE shardid = 102008 AND nodeport = 57637;
}
step "s2-invalidate-57638"
{
UPDATE pg_dist_shard_placement SET shardstate = '3' WHERE shardid = 102008 AND nodeport = 57638;
}
step "s2-revalidate-57638"
{
UPDATE pg_dist_shard_placement SET shardstate = '1' WHERE shardid = 102008 AND nodeport = 57638;
}
step "s2-repair"
{
SELECT master_copy_shard_placement(102008, 'localhost', 57638, 'localhost', 57637);
}
step "s2-commit"
{
COMMIT;
}
# verify that repair is blocked by ongoing modifying simple transaction
permutation "s2-invalidate-57637" "s1-begin" "s1-insertone" "s2-repair" "s1-commit"
# verify that repair is blocked by ongoing modifying insert...select transaction
permutation "s1-insertone" "s2-invalidate-57637" "s1-begin" "s1-insertall" "s2-repair" "s1-commit"
# verify that modifications wait for shard repair
permutation "s2-invalidate-57637" "s2-begin" "s2-repair" "s1-insertone" "s2-commit" "s2-invalidate-57638" "s1-display" "s2-invalidate-57637" "s2-revalidate-57638" "s1-display"
# verify that prepared plain modifications wait for shard repair (and then fail to avoid race)
permutation "s2-invalidate-57637" "s1-prepared-insertone" "s2-begin" "s2-repair" "s1-prepared-insertone" "s2-commit" "s2-invalidate-57638" "s1-display" "s2-invalidate-57637" "s2-revalidate-57638" "s1-display"
# verify that prepared INSERT ... SELECT waits for shard repair (and then fail to avoid race)
permutation "s2-invalidate-57637" "s1-insertone" "s1-prepared-insertall" "s2-begin" "s2-repair" "s1-prepared-insertall" "s2-commit" "s2-invalidate-57638" "s1-display" "s2-invalidate-57637" "s2-revalidate-57638" "s1-display"