test_many_tables

text/plain

Filename: test_many_tables
Type: text/plain
Part: 1
Message: pg_upgrade with parallel tablespace copying
:

. traprm

export QUIET=$((QUIET + 1))

> /rtmp/out

OLDREL=9.2
NEWREL=9.3
BRANCH=tablespace
SSD="f"

export PGOPTIONS="-c synchronous_commit=off"

for CYCLES in 2 4 8 16 32 64 128
do
	echo "$CYCLES" >> /rtmp/out
	for JOBLIMIT in 1 2
	do
		cd /pgsql/$REL
		pgsw $BRANCH
		cd -
		tools/setup $OLDREL $NEWREL
		sleep 2
		[ "$SSD" = "f" ] && tools/mv_to_archive
	
		# need for +16k
		for CONFIG in /u/pgsql.old/data/postgresql.conf /u/pgsql/data/postgresql.conf
		do
			pipe sed 's/#max_locks_per_transaction = 64/max_locks_per_transaction = 64000/' "$CONFIG"
			pipe sed 's/shared_buffers = 128MB/shared_buffers = 1GB/' "$CONFIG"
		done

		pgstart -w /u/pgsql.old/data
		for DIR in /archive/tmp/t1 /backup0/tmp/t2
		do	rm -rf "$DIR"
			mkdir "$DIR"
			chown postgres "$DIR"
			chmod 0700 "$DIR"
		done

		echo "CREATE TABLESPACE t1 LOCATION '/archive/tmp/t1';" | sql --echo-all test
		echo "CREATE TABLESPACE t2 LOCATION '/backup0/tmp/t2';" | sql --echo-all test

		for SPNO in $(jot 2)
		do
			for TBLNO in $(jot $(($CYCLES / 2)) )
			do 
				echo "CREATE TABLE test${SPNO}_${TBLNO} (x TEXT) TABLESPACE t$SPNO;"
				echo "ALTER TABLE test${SPNO}_${TBLNO} ALTER COLUMN x SET STORAGE EXTERNAL;"
				echo "INSERT INTO test${SPNO}_${TBLNO} SELECT repeat('x', 999000000);"
			done |
			PGOPTIONS="-c synchronous_commit=off" sql --single-transaction --echo-all test
		done
		pgstop /u/pgsql.old/data
		sleep 2
		# clear cache
		echo 3 > /proc/sys/vm/drop_caches
		# allow system to repopulate
		sleep 15
		/usr/bin/time --output=/rtmp/out --append --format '%e' tools/upgrade -j $JOBLIMIT || exit 
		sleep 2
	done
done

bell