Last active
April 26, 2016 11:37
-
-
Save benma/89176c3ade0eb46d83a74c2beb30d3d7 to your computer and use it in GitHub Desktop.
postgres serialiazation errors where none should happen (false negatives)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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