Wed Sep 26 15:19:59 PDT 2007
- Previous message: [Slony1-commit] slony1-engine/tests/testdeadlockddl - New directory
- Next message: [Slony1-commit] slony1-engine/src/ducttape test_8_logship.in test_8_logshipper.conf test_8_pgbench-1.sql
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Update of /home/cvsd/slony1/slony1-engine/tests/testdeadlockddl
In directory main.slony.info:/tmp/cvs-serv25749
Added Files:
README ddl_update_part2.sql ddl_updates.sql exec_ddl.sh
gen_weak_user.sh generate_dml.sh individual_ddl.sh
init_add_tables.ik init_cluster.ik init_create_set.ik
init_data.sql init_schema.sql init_subscribe_set.ik
schema.diff settings.ik
Log Message:
Add in a test that combines EXECUTE SCRIPT with an attempt at
deadlocking the subscriber node.
To try to help resolve issues Jeff Frost ran into...
--- NEW FILE: settings.ik ---
NUMCLUSTERS=${NUMCLUSTERS:-"1"}
NUMNODES=${NUMNODES:-"3"}
ORIGINNODE=1
WORKERS=${WORKERS:-"1"}
--- NEW FILE: init_cluster.ik ---
init cluster ( id=1, comment = 'Regress test node');
--- NEW FILE: ddl_update_part2.sql ---
create sequence t1seq;
alter table table1 add column seqed integer;
alter table table1 alter column seqed set default nextval('t1seq');
update table1 set seqed = nextval('t1seq');
alter table table1 add constraint seqed_unique UNIQUE(seqed);
--- NEW FILE: gen_weak_user.sh ---
weakuser=$1;
for i in 1 2 3 4; do
echo "grant select on table public.table${i} to ${weakuser};"
echo "grant select on table public.table${i}_id_seq to ${weakuser};"
done
echo "grant select on table public.billing_discount to ${weakuser};"
echo "grant select on table public.billing_discount_seq to ${weakuser};"
--- NEW FILE: generate_dml.sh ---
. support_funcs.sh
init_dml()
{
echo "init_dml()"
}
begin()
{
echo "begin()"
}
rollback()
{
echo "rollback()"
}
commit()
{
echo "commit()"
}
generate_initdata()
{
numrows=$(random_number 50 90)
i=0;
trippoint=`expr $numrows / 20`
j=0;
percent=0
status "generating ${numrows} transactions of random data"
percent=`expr $j \* 5`
status "$percent %"
GENDATA="$mktmp/generate.data"
echo "" > ${GENDATA}
while : ; do
txtalen=$(random_number 1 100)
txta=$(random_string ${txtalen})
txta=`echo ${txta} | sed -e "s/\\\\\\\/\\\\\\\\\\\\\\/g" -e "s/'/''/g"`
txtblen=$(random_number 1 100)
txtb=$(random_string ${txtblen})
txtb=`echo ${txtb} | sed -e "s/\\\\\\\/\\\\\\\\\\\\\\/g" -e "s/'/''/g"`
echo "INSERT INTO table1(data) VALUES ('${txta}');" >> $GENDATA
echo "INSERT INTO table2(table1_id,data) SELECT id, '${txtb}' FROM table1 WHERE data='${txta}';" >> $GENDATA
echo "INSERT INTO table3(table2_id) SELECT id FROM table2 WHERE data ='${txtb}';" >> $GENDATA
echo "INSERT INTO table4(data) VALUES ('${txtb}');" >> $GENDATA
if [ ${i} -ge ${numrows} ]; then
break;
else
i=$((${i} +1))
working=`expr $i % $trippoint`
if [ $working -eq 0 ]; then
j=`expr $j + 1`
percent=`expr $j \* 5`
status "$percent %"
fi
fi
done
status "done"
}
do_initdata()
{
LOG=${mktmp}/initdata.log
SCRIPT=${mktmp}/slonik.script
originnode=${ORIGINNODE:-"1"}
eval db=\$DB${originnode}
eval host=\$HOST${originnode}
eval user=\$USER${originnode}
eval port=\$PORT${originnode}
start_deadlock_inducing_queries
generate_initdata
launch_poll
status "loading data"
$pgbindir/psql -h $host -p $port -U $user -d $db < $mktmp/generate.data 1> $LOG 2> $LOG
if [ $? -ne 0 ]; then
warn 3 "do_initdata failed, see $mktmp/initdata.log for details"
fi
start_deadlock_inducing_queries
status "execute DDL script"
init_preamble
sh ${testname}/exec_ddl.sh ${testname} >> $SCRIPT
do_ik
status "completed DDL script"
status "Generate some more data"
generate_initdata
eval db=\$DB${originnode}
status "loading extra data to node $db"
$pgbindir/psql -h $host -p $port -U $user -d $db < $mktmp/generate.data 1> $LOG 2> $LOG
wait_for_catchup
status "done"
}
start_deadlock_inducing_queries()
{
status "start deadlock-inducing queries"
QUERY="
begin;
select id into temp table foo1 from table1 order by random() limit 5;
select id into temp table foo2 from table2 order by random() limit 5;
select id into temp table foo3 from table3 order by random() limit 5;
lock table4 in access share mode;
lock table2 in access share mode;
lock table1 in access share mode;
lock table3 in access share mode;
\!sh -c 'sleep 3'
select * from table1 order by random() limit 5;
\!sh -c 'sleep 1'
select * from table1 t1, table2 t2, table3 t3, foo1, foo2, foo3
where t1.id = t2.table1_id and t3.table2_id = t2.id and
foo1.id = t1.id limit 5;
\!sh -c 'sleep 2'
select * from table1 t1, table2 t2, table3 t3, foo1, foo2, foo3
where t1.id = t2.table1_id and t3.table2_id = t2.id and
foo2.id = t2.id limit 5;
\!sh -c 'sleep 1'
select * from table1 t1, table2 t2, table3 t3, foo1, foo2, foo3
where t1.id = t2.table1_id and t3.table2_id = t2.id and
foo3.id = t3.id limit 5;
\!sh -c 'sleep 2'
\!sh -c 'sleep 3'
select * from table1 order by random() limit 5;
\!sh -c 'sleep 1'
select * from table1 t1, table2 t2, table3 t3, foo1, foo2, foo3
where t1.id = t2.table1_id and t3.table2_id = t2.id and
foo1.id = t1.id limit 5;
\!sh -c 'sleep 2'
select * from table1 t1, table2 t2, table3 t3, foo1, foo2, foo3
where t1.id = t2.table1_id and t3.table2_id = t2.id and
foo2.id = t2.id limit 5;
\!sh -c 'sleep 1'
select * from table1 t1, table2 t2, table3 t3, foo1, foo2, foo3
where t1.id = t2.table1_id and t3.table2_id = t2.id and
foo3.id = t3.id limit 5;
\!sh -c 'sleep 2'
\!sh -c 'sleep 3'
select * from table1 order by random() limit 5;
\!sh -c 'sleep 1'
select * from table1 t1, table2 t2, table3 t3, foo1, foo2, foo3
where t1.id = t2.table1_id and t3.table2_id = t2.id and
foo1.id = t1.id limit 5;
\!sh -c 'sleep 2'
select * from table1 t1, table2 t2, table3 t3, foo1, foo2, foo3
where t1.id = t2.table1_id and t3.table2_id = t2.id and
foo2.id = t2.id limit 5;
\!sh -c 'sleep 1'
select * from table1 t1, table2 t2, table3 t3, foo1, foo2, foo3
where t1.id = t2.table1_id and t3.table2_id = t2.id and
foo3.id = t3.id limit 5;
\!sh -c 'sleep 2'
\!sh -c 'sleep 3'
select * from table1 order by random() limit 5;
\!sh -c 'sleep 1'
select * from table1 t1, table2 t2, table3 t3, foo1, foo2, foo3
where t1.id = t2.table1_id and t3.table2_id = t2.id and
foo1.id = t1.id limit 5;
\!sh -c 'sleep 2'
select * from table1 t1, table2 t2, table3 t3, foo1, foo2, foo3
where t1.id = t2.table1_id and t3.table2_id = t2.id and
foo2.id = t2.id limit 5;
\!sh -c 'sleep 1'
select * from table1 t1, table2 t2, table3 t3, foo1, foo2, foo3
where t1.id = t2.table1_id and t3.table2_id = t2.id and
foo3.id = t3.id limit 5;
\!sh -c 'sleep 2'
\!sh -c 'sleep 3'
select * from table1 order by random() limit 5;
\!sh -c 'sleep 1'
select * from table1 t1, table2 t2, table3 t3, foo1, foo2, foo3
where t1.id = t2.table1_id and t3.table2_id = t2.id and
foo1.id = t1.id limit 5;
\!sh -c 'sleep 2'
select * from table1 t1, table2 t2, table3 t3, foo1, foo2, foo3
where t1.id = t2.table1_id and t3.table2_id = t2.id and
foo2.id = t2.id limit 5;
\!sh -c 'sleep 1'
select * from table1 t1, table2 t2, table3 t3, foo1, foo2, foo3
where t1.id = t2.table1_id and t3.table2_id = t2.id and
foo3.id = t3.id limit 5;
\!sh -c 'sleep 2'
\!sh -c 'sleep 3'
select * from table1 order by random() limit 5;
\!sh -c 'sleep 1'
select * from table1 t1, table2 t2, table3 t3, foo1, foo2, foo3
where t1.id = t2.table1_id and t3.table2_id = t2.id and
foo1.id = t1.id limit 5;
\!sh -c 'sleep 2'
select * from table1 t1, table2 t2, table3 t3, foo1, foo2, foo3
where t1.id = t2.table1_id and t3.table2_id = t2.id and
foo2.id = t2.id limit 5;
\!sh -c 'sleep 1'
select * from table1 t1, table2 t2, table3 t3, foo1, foo2, foo3
where t1.id = t2.table1_id and t3.table2_id = t2.id and
foo3.id = t3.id limit 5;
\!sh -c 'sleep 2'
\!sh -c 'sleep 3'
select * from table1 order by random() limit 5;
\!sh -c 'sleep 1'
select * from table1 t1, table2 t2, table3 t3, foo1, foo2, foo3
where t1.id = t2.table1_id and t3.table2_id = t2.id and
foo1.id = t1.id limit 5;
\!sh -c 'sleep 2'
select * from table1 t1, table2 t2, table3 t3, foo1, foo2, foo3
where t1.id = t2.table1_id and t3.table2_id = t2.id and
foo2.id = t2.id limit 5;
\!sh -c 'sleep 1'
select * from table1 t1, table2 t2, table3 t3, foo1, foo2, foo3
where t1.id = t2.table1_id and t3.table2_id = t2.id and
foo3.id = t3.id limit 5;
\!sh -c 'sleep 2'
\!sh -c 'sleep 3'
select * from table1 order by random() limit 5;
\!sh -c 'sleep 1'
select * from table1 t1, table2 t2, table3 t3, foo1, foo2, foo3
where t1.id = t2.table1_id and t3.table2_id = t2.id and
foo1.id = t1.id limit 5;
\!sh -c 'sleep 2'
select * from table1 t1, table2 t2, table3 t3, foo1, foo2, foo3
where t1.id = t2.table1_id and t3.table2_id = t2.id and
foo2.id = t2.id limit 5;
\!sh -c 'sleep 1'
select * from table1 t1, table2 t2, table3 t3, foo1, foo2, foo3
where t1.id = t2.table1_id and t3.table2_id = t2.id and
foo3.id = t3.id limit 5;
\!sh -c 'sleep 2'
\!sh -c 'sleep 3'
select * from table1 order by random() limit 5;
\!sh -c 'sleep 1'
select * from table1 t1, table2 t2, table3 t3, foo1, foo2, foo3
where t1.id = t2.table1_id and t3.table2_id = t2.id and
foo1.id = t1.id limit 5;
\!sh -c 'sleep 2'
select * from table1 t1, table2 t2, table3 t3, foo1, foo2, foo3
where t1.id = t2.table1_id and t3.table2_id = t2.id and
foo2.id = t2.id limit 5;
\!sh -c 'sleep 1'
select * from table1 t1, table2 t2, table3 t3, foo1, foo2, foo3
where t1.id = t2.table1_id and t3.table2_id = t2.id and
foo3.id = t3.id limit 5;
\!sh -c 'sleep 2'
\!sh -c 'sleep 3'
select * from table1 order by random() limit 5;
\!sh -c 'sleep 1'
select * from table1 t1, table2 t2, table3 t3, foo1, foo2, foo3
where t1.id = t2.table1_id and t3.table2_id = t2.id and
foo1.id = t1.id limit 5;
\!sh -c 'sleep 2'
select * from table1 t1, table2 t2, table3 t3, foo1, foo2, foo3
where t1.id = t2.table1_id and t3.table2_id = t2.id and
foo2.id = t2.id limit 5;
\!sh -c 'sleep 1'
select * from table1 t1, table2 t2, table3 t3, foo1, foo2, foo3
where t1.id = t2.table1_id and t3.table2_id = t2.id and
foo3.id = t3.id limit 5;
\!sh -c 'sleep 2'
\!sh -c 'sleep 3'
select * from table1 order by random() limit 5;
\!sh -c 'sleep 1'
select * from table1 t1, table2 t2, table3 t3, foo1, foo2, foo3
where t1.id = t2.table1_id and t3.table2_id = t2.id and
foo1.id = t1.id limit 5;
\!sh -c 'sleep 2'
select * from table1 t1, table2 t2, table3 t3, foo1, foo2, foo3
where t1.id = t2.table1_id and t3.table2_id = t2.id and
foo2.id = t2.id limit 5;
\!sh -c 'sleep 1'
select * from table1 t1, table2 t2, table3 t3, foo1, foo2, foo3
where t1.id = t2.table1_id and t3.table2_id = t2.id and
foo3.id = t3.id limit 5;
\!sh -c 'sleep 2'
\!sh -c 'sleep 3'
select * from table1 order by random() limit 5;
\!sh -c 'sleep 1'
select * from table1 t1, table2 t2, table3 t3, foo1, foo2, foo3
where t1.id = t2.table1_id and t3.table2_id = t2.id and
foo1.id = t1.id limit 5;
\!sh -c 'sleep 2'
select * from table1 t1, table2 t2, table3 t3, foo1, foo2, foo3
where t1.id = t2.table1_id and t3.table2_id = t2.id and
foo2.id = t2.id limit 5;
\!sh -c 'sleep 1'
select * from table1 t1, table2 t2, table3 t3, foo1, foo2, foo3
where t1.id = t2.table1_id and t3.table2_id = t2.id and
foo3.id = t3.id limit 5;
\!sh -c 'sleep 2'
"
echo $QUERY
for i in 1 2 3 4 5 6 7 8; do
status "start query thread ${i}"
(echo "${QUERY}" | $pgbindir/psql -h $HOST2 -p $PORT2 -U $USER2 -d $DB2; status "end query thread ${i}")&
sleep 1
done
status "all deadlock-inducing queries running"
}
--- NEW FILE: individual_ddl.sh ---
testname=$1
node=$2
echo "
EXECUTE SCRIPT (
SET ID = 1,
FILENAME = '${testname}/ddl_update_part2.sql',
EVENT NODE = ${node},
EXECUTE ONLY ON = ${node}
);
"
--- NEW FILE: ddl_updates.sql ---
create sequence ncolseq;
alter table table4 add column newcol timestamptz;
alter table table4 alter column newcol set default now();
alter table table4 rename column id1 to col1;
alter table table4 rename column id2 to col2;
ALTER TABLE billing_discount ADD column "use_term" character(1);
ALTER TABLE billing_discount ALTER column use_term set default 'n';
ALTER TABLE billing_discount add constraint use_term_cons check (use_term in ('y','n'));
--- NEW FILE: init_add_tables.ik ---
set add table (id=1, set id=1, origin=1, fully qualified name = 'public.table1', comment='accounts table');
set add table (id=2, set id=1, origin=1, fully qualified name = 'public.table2', key='table2_id_key');
set add table (id=3, set id=1, origin=1, fully qualified name = 'public.table3');
set add table (id=4, set id=1, origin=1, fully qualified name = 'public.table4');
set add table (id=5, set id=1, origin=1, fully qualified name = 'public.billing_discount');
--- NEW FILE: init_create_set.ik ---
create set (id=1, origin=1); # no comment - should draw one in automagically
--- NEW FILE: init_data.sql ---
INSERT INTO table1(data) VALUES ('placeholder 1');
INSERT INTO table2(table1_id,data) VALUES (1,'placeholder 1');
INSERT INTO table3(table2_id) VALUES (1);
--- NEW FILE: init_schema.sql ---
CREATE TABLE table1(
id SERIAL PRIMARY KEY,
data TEXT
);
CREATE TABLE table2(
id SERIAL UNIQUE NOT NULL,
table1_id INT4 REFERENCES table1(id)
ON UPDATE CASCADE ON DELETE CASCADE,
data TEXT
);
CREATE TABLE table3(
id SERIAL,
table2_id INT4 REFERENCES table2(id)
ON UPDATE SET NULL ON DELETE SET NULL,
mod_date TIMESTAMPTZ NOT NULL DEFAULT now(),
data FLOAT NOT NULL DEFAULT random()
CONSTRAINT table3_date_check CHECK (mod_date <= now()),
primary key(id)
);
CREATE TABLE table4 (
id1 serial,
id2 serial,
data text,
primary key (id1, id2)
);
insert into table4 (data) values ('BA Baracus');
insert into table4 (data) values ('HM Murdoch');
insert into table4 (data) values ('Face');
insert into table4 (data) values ('Hannibal');
create sequence billing_discount_seq;
CREATE TABLE billing_discount (
discount_code character(2) NOT NULL,
billing_object_type character varying(10) NOT NULL,
billing_action_type character varying(10) NOT NULL,
discount_amount numeric(7,2) NOT NULL,
start_date timestamp with time zone NOT NULL,
end_date timestamp with time zone NOT NULL,
billing_discount_id integer DEFAULT nextval('billing_discount_seq'::text) NOT NULL,
registrar_id integer,
tld_id integer,
zone_id integer
);
ALTER TABLE ONLY billing_discount
ADD CONSTRAINT billing_discount_pkey PRIMARY KEY (billing_discount_id);
--- NEW FILE: schema.diff ---
SELECT id,data FROM table1 ORDER BY id
SELECT id,table1_id,data FROM table2 ORDER BY id
SELECT id,table2_id,mod_date, data FROM table3 ORDER BY id
select col1,col2,data,newcol from table4 order by col1,col2
--- NEW FILE: README ---
$Id: README,v 1.1 2007-09-26 22:19:57 cbbrowne Exp $
testdeadlockddl tries to induce DEADLOCK during application of DDL to
verify that the attempt to run the DDL on subscribers rolls back
properly when it fails.
--- NEW FILE: init_subscribe_set.ik ---
echo 'sleep a couple seconds';
sleep (seconds = 2);
subscribe set ( id = 1, provider = 1, receiver = 2, forward = no);
sync(id=1);
wait for event (origin=1, confirmed=2);
echo 'sleep a couple seconds';
sleep (seconds = 2);
subscribe set ( id = 1, provider = 1, receiver = 3, forward = no);
--- NEW FILE: exec_ddl.sh ---
testname=$1
echo "
EXECUTE SCRIPT (
SET ID = 1,
FILENAME = '${testname}/ddl_updates.sql',
EVENT NODE = 1
);
"
- Previous message: [Slony1-commit] slony1-engine/tests/testdeadlockddl - New directory
- Next message: [Slony1-commit] slony1-engine/src/ducttape test_8_logship.in test_8_logshipper.conf test_8_pgbench-1.sql
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Slony1-commit mailing list