pgcentralfoundation / pgrx

Build Postgres Extensions with Rust!
Other
3.57k stars 242 forks source link

make it easier to run multiple clusters with the same extension installed #1736

Open jyn514 opened 3 months ago

jyn514 commented 3 months ago

postgres has a plethora of features that can only be tested with multiple clusters, the biggest one being replication. unfortunately, it is not easy to run multiple clusters with pgrx. @workingjubilee suggested setting PGRX_HOME to different values between invocations of pgrx, but that requires rebuilding and reinstalling lots of things. it would be nice to have this as a built-in feature.

i wrote a shell script to work around this in the meantime, which i look forward to burning.

i am so sorry ```sh set -ex data=$HOME/.pgrx/data-16 conf=$data/postgresql.conf wal_backup=$(realpath ./wal-archive) mkdir -p $wal_backup cargo pgrx stop rm -r $data ~/.pgrx/16.log standby.log # recreate default config before we edit it cargo pgrx start cargo pgrx stop # listen_addresses = "" # already configured to localhost echo \ "shared_preload_libraries = 'my-extension' archive_command = 'test ! -f $wal_backup/%f && cp %p $wal_backup/%f' archive_mode = on archive_timeout = 5s # this is unreasonably short, but we only use this database for testing " >> $conf # create standby rm -rf data-standby cp -r $data data-standby touch data-standby/standby.signal cp $conf data-standby echo "\ # restore_command = '' primary_conninfo = 'postgresql://%2Fhome%2Fjyn%2F.pgrx' port = 28817 # avoid conflicting with the primary " >> data-standby/postgresql.conf cargo pgrx stop $(cargo pgrx info path 16)/bin/pg_ctl stop -D data-standby -o "-c unix_socket_directories=/home/jyn/.pgrx" || true killall postgres || true # standby cargo pgrx start # make sure to do this before starting the standby so we load the right version of the .so [ -e "/home/jyn/.pgrx/.s.PGSQL.28816" ] || exit 1 trap "cargo pgrx stop" EXIT $(cargo pgrx info path 16)/bin/pg_ctl start -D data-standby -l standby.log -o "-c unix_socket_directories=/home/jyn/.pgrx" trap "$(cargo pgrx info path 16)/bin/pg_ctl stop -D data-standby -o '-c unix_socket_directories=/home/jyn/.pgrx' >/dev/null" EXIT # run queries with $(cargo pgrx info path 16)/bin/psql -p 28817 -d my-extension -h ~/.pgrx ```
workingjubilee commented 3 months ago

that sure is bashed.