#!/bin/bash

#1. create primary instance

initdb -D pg_test
echo "wal_consistency_checking = brin" >> pg_test/postgresql.conf
echo "port=53320" >> pg_test/postgresql.conf
pg_ctl start -D pg_test -l pg_test.logfile

#2. Create a standby instance

pg_basebackup -R -p 53320 -D pg_test_slave
echo "wal_consistency_checking = brin" >> pg_test_slave/postgresql.conf
echo "port=53321" >> pg_test_slave/postgresql.conf
pg_ctl start -D pg_test_slave -l pg_test_slave.logfile

#3. Execute brin_redo_abort.sql through psql, and find that the standby instance lost

psql -p 53320 -f brin_redo_abort.sql

#5. The primary instance cannot be restarted through pg_ctl restart -mi

pg_ctl restart -D pg_test -mi -l pg_test.logfile

