bdr: tests for ddl lock conflict
authorPetr Jelinek <pjmodos@pjmodos.net>
Fri, 15 Aug 2014 14:46:37 +0000 (16:46 +0200)
committerAndres Freund <andres@anarazel.de>
Mon, 8 Sep 2014 15:49:57 +0000 (17:49 +0200)
Makefile
expected/isolation/ddlconflict.out [new file with mode: 0644]
specs/isolation/ddlconflict.spec [new file with mode: 0644]

index 9bddac24158d515bf5b3a6889bbd27a88f059933..16ea3d7b4d31eed08d21d6e1f77a51ff9c9e6b8a 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -112,7 +112,8 @@ bdr_pgbench_check: bdr_pgbench_check.sh
 
 ISOLATIONCHECKS=\
    isolation/sleep5 \
-   isolation/waitforstart
+   isolation/waitforstart \
+   isolation/ddlconflict
 
 bdr_isolation_regress_check: all | submake-isolation submake-btree_gist
    [ -e pg_hba.conf ] || ln -s $(top_srcdir)/contrib/bdr/pg_hba.conf .
diff --git a/expected/isolation/ddlconflict.out b/expected/isolation/ddlconflict.out
new file mode 100644 (file)
index 0000000..cd1a432
--- /dev/null
@@ -0,0 +1,33 @@
+Parsed test spec with 2 sessions
+
+starting permutation: s1b s1ct s2b s2ct s1c s2c s2dt s1wait s2wait s2ct2
+step s1b: BEGIN;
+step s1ct: CREATE TABLE bdr_ddl_conflict_a(f1 int);
+step s2b: BEGIN;
+step s2ct: CREATE TABLE bdr_ddl_conflict_b(f1 int);
+ERROR:  database is locked against ddl by another node
+step s1c: COMMIT;
+step s2c: COMMIT;
+step s2dt: DROP TABLE bdr_ddl_conflict_a;
+step s1wait: SELECT pg_xlog_wait_remote_apply(pg_current_xlog_location(), pid) FROM pg_stat_replication;
+pg_xlog_wait_remote_apply
+
+               
+               
+               
+               
+               
+               
+step s2wait: SELECT pg_xlog_wait_remote_apply(pg_current_xlog_location(), pid) FROM pg_stat_replication; select * from pg_sleep(1);
+pg_xlog_wait_remote_apply
+
+               
+               
+               
+               
+               
+               
+pg_sleep       
+
+               
+step s2ct2: CREATE TABLE bdr_ddl_conflict_c(f1 int);
diff --git a/specs/isolation/ddlconflict.spec b/specs/isolation/ddlconflict.spec
new file mode 100644 (file)
index 0000000..0c3b6cf
--- /dev/null
@@ -0,0 +1,23 @@
+conninfo "node1" "dbname=node1"
+conninfo "node2" "dbname=node2"
+
+teardown
+{
+   DROP TABLE IF EXISTS bdr_ddl_conflict_a, bdr_ddl_conflict_b, bdr_ddl_conflict_c;
+}
+
+session "snode1"
+step "s1b" { BEGIN; }
+step "s1ct" { CREATE TABLE bdr_ddl_conflict_a(f1 int); }
+step "s1c" { COMMIT; }
+step "s1wait" { SELECT pg_xlog_wait_remote_apply(pg_current_xlog_location(), pid) FROM pg_stat_replication; }
+
+session "snode2"
+step "s2b" { BEGIN; }
+step "s2ct" { CREATE TABLE bdr_ddl_conflict_b(f1 int); }
+step "s2c" { COMMIT; }
+step "s2dt" { DROP TABLE bdr_ddl_conflict_a; }
+step "s2wait" { SELECT pg_xlog_wait_remote_apply(pg_current_xlog_location(), pid) FROM pg_stat_replication; select * from pg_sleep(1); }
+step "s2ct2" { CREATE TABLE bdr_ddl_conflict_c(f1 int); }
+
+permutation "s1b" "s1ct" "s2b" "s2ct" "s1c" "s2c" "s2dt" "s1wait" "s2wait" "s2ct2"