repro=AIO-Assert.sh.txt

text/plain

Filename: repro=AIO-Assert.sh.txt
Type: text/plain
Part: 1
Message: Re: Non-reproducible AIO failure
#!/bin/bash

# Choose server id
[  -n "$1" ] && SID=$1 || SID=01

PGBIN=`pwd`/tmp_install/tmp/postgres/bin

PGDATA=`pwd`/tmpdb$SID
export PGDATA

export PATH="$PGBIN:$PATH"
export LD_LIBRARY_PATH="$PGBIN/../lib"

rm server$SID.log

pg_ctl stop -m immediate >/dev/null 2>&1

rm -rf "$PGDATA"; initdb >initdb$SID.log 2>&1

export PGPORT=$((15430 + 10#$SID))

echo "
port=$PGPORT

fsync = off
autovacuum = off
restart_after_crash = off

shared_buffers = 128kB
" > $PGDATA/postgresql.auto.conf

pg_ctl start -l server$SID.log >/dev/null
export PGDATABASE=regression
createdb regression

# Define the function to execute opr_sanity cleanly without test_setup
psql -q -c "CREATE FUNCTION binary_coercible(oid, oid) RETURNS bool LANGUAGE SQL RETURN true"

res=0
for i in {1..100}; do
  echo "ITERATION $i" >psql${SID}.log
  psql -f src/test/regress/sql/opr_sanity.sql >>psql${SID}_1.log &
  psql -f src/test/regress/sql/opr_sanity.sql >>psql${SID}_2.log &
  wait
  grep TRAP server$SID.log && { res=1; break; }
done

pg_ctl stop -m immediate >/dev/null

exit $res