Skip to content

Instantly share code, notes, and snippets.

@benma
Last active April 26, 2016 11:37
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 benma/89176c3ade0eb46d83a74c2beb30d3d7 to your computer and use it in GitHub Desktop.
Save benma/89176c3ade0eb46d83a74c2beb30d3d7 to your computer and use it in GitHub Desktop.
postgres serialiazation errors where none should happen (false negatives)
#!/bin/bash
DBNAME=dbname
DBUSER=dbuser
N=150
sql () {
echo $1 | psql -h localhost $DBNAME $DBUSER
}
sql "drop table if exists test;create table test (key int, num int);" > /dev/null
STMT=""
for i in $(seq $N); do
STMT="$STMT insert into test(key, num) values($i, 0);"
done
sql "$STMT" > /dev/null
echo
echo "setup done"
for i in $(seq $N); do
sql "begin isolation level serializable; update test set num=1 where key=$i; commit;" > /dev/null &
done
echo "waiting"
wait
sql "select count(*) from test where num=0"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment