Skip to content

Instantly share code, notes, and snippets.

@ronin13

ronin13/run.sh Secret

Created May 13, 2014 12:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ronin13/fc7f0a3a40c0823d8624 to your computer and use it in GitHub Desktop.
Save ronin13/fc7f0a3a40c0823d8624 to your computer and use it in GitHub Desktop.
#!/bin/bash -eu
##
#
# lp:1019473
# https://bugs.launchpad.net/codership-mysql/+bug/1019473
#
# BUG BACKGROUND:
#
# wsrep generates certification keys for tables with no PK nor UK, by
# taking a MD5 digest over the whole row. This makes it possible to replicate
# and control PA for key-less tables. Unfortunately this implementation
# had a bug which caused such row key hashing to be non deterministic, if row
# contains certain binary types (blob or text at least are vulnerable)
#
# TEST SETUP:
# - Two nodes are used in master slave mode.
# - Slave is configured with 4 applier threads
# - parent and child tables are created and populated
# - test load runs one connection, which issues a large detete for child
# table and one row delete for parent table. We try to make the applying
# of child table delete to last so long that parent table delete gets to
# apply in parallel.
#
# SUCCESS CRITERIA
#
# If bug is present, slave will crash for not being able to delete a rowk
#
MYSQL1="mysql --defaults-file=/pxc56/etc/my.cnf.local test"
MYSQL2="mysql --defaults-file=/pxc56/etc/my.cnf.local.2 test"
ROUNDS=1000
ROWS=5
USERS=3
echo "rounds=$ROUNDS"
echo "rows=$ROWS"
echo "users=$USERS"
insert1()
{
for r in $(seq 1 $ROUNDS); do
for i in $(seq 1 $ROWS); do
$MYSQL1 -e "
DELETE FROM lp1019473 WHERE fid=$i AND uid=$i;
INSERT INTO lp1019473 VALUES ($i,$i,'C-1')" || true
done;
done
}
insert2()
{
for r in $(seq 1 $ROUNDS); do
for i in $(seq 1 $ROWS); do
$MYSQL2 -e "
DELETE FROM lp1019473 WHERE fid=$i AND uid=$i;
INSERT INTO lp1019473 VALUES ($i,$i,'C-2')" || true
done;
done
}
createdb()
{
$MYSQL1 -e "drop table if exists lp1019473;";
$MYSQL1 -e "CREATE TABLE lp1019473 (
fid int(10) unsigned DEFAULT 0,
uid int(10) unsigned DEFAULT 0,
value text,
KEY uid (uid),
KEY fid (fid)
) ENGINE=InnoDB DEFAULT CHARSET=utf8"
}
cleandb()
{
$MYSQL1 -e "
DROP TABLE IF EXISTS test.lp1019473;"
}
#########################################################
#
# Test begins here
#
#########################################################
threads=$($MYSQL1 -e "SHOW VARIABLES LIKE 'wsrep_slave_threads'")
#echo "applier check: $threads"
#[ "$threads" = "wsrep_slave_threads 4" ] || { echo "NOT ENOUGH SLAVES"; exit 1; }
INITIAL_SIZE=`$MYSQL1 -e "SHOW STATUS LIKE 'wsrep_cluster_size';" | cut -f 2`
echo "Initial cluster size: $INITIAL_SIZE"
createdb
for u in $(seq 0 $USERS); do
insert1 &
insert2 &
done
wait
echo
echo "Done!"
echo
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment