It turned out that reason of the occasional test failure is, pgpool
child process is gone before running ps command after pgbench
finishes. The cause is a kind mismatch FATAL error, "DISCARD ALL
cannot be executed within a pipeline". To fix this, run pgbench in
background and get the process size before pgbench finishes.
Discussion: https://www.pgpool.net/pipermail/pgpool-hackers/2023-May/004338.html
init_size=`ps l $pid|tail -1|awk '{print $7}'`
echo "init_size: $init_size"
- # run pgbench for a while
- $PGBENCH -M extended -S -T 30 test
+ # run pgbench for a while in background.
+ echo "Starting pgbench in background"
+ date
+ $PGBENCH -M extended -S -T 30 test &
+ # sleep 29 seconds so that we can get the process size before
+ # pgpool process $pid accidentaly exits.
+ sleep 29
+
+ date
after_size=`ps l $pid|tail -1|awk '{print $7}'`
delta=`expr $after_size - $init_size`
echo "initial process size: $init_size after size: $after_size delta: $delta"
+ wait
+ echo "pgbench done."
+ date
+
test $delta -eq 0
if [ $? != 0 ];then