From a7014993c68a2965b0de23788625248dc2d39612 Mon Sep 17 00:00:00 2001 From: Paul Cioanca Date: Tue, 9 Jul 2024 17:27:11 +0300 Subject: [PATCH] chore: disable pg_net processing before running upgrades --- .../admin_api_scripts/pg_upgrade_scripts/initiate.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ansible/files/admin_api_scripts/pg_upgrade_scripts/initiate.sh b/ansible/files/admin_api_scripts/pg_upgrade_scripts/initiate.sh index b098fabb5..7398b5f5e 100755 --- a/ansible/files/admin_api_scripts/pg_upgrade_scripts/initiate.sh +++ b/ansible/files/admin_api_scripts/pg_upgrade_scripts/initiate.sh @@ -128,6 +128,14 @@ function handle_extensions { echo "ALTER SYSTEM SET password_encryption = 'md5';" >> $POST_UPGRADE_EXTENSION_SCRIPT fi + # Persisting pg_net.batch_size setting if it exists, setting it to the default of 200 if it doesn't + PG_NET_BATCH_SIZE_SETTING=$(run_sql -A -t -c "SELECT COALESCE( (SELECT setting from pg_settings where name = 'pg_net.batch_size'), '200')") + echo "ALTER SYSTEM SET pg_net.batch_size = $PG_NET_BATCH_SIZE_SETTING;" >> $POST_UPGRADE_EXTENSION_SCRIPT + + # Setting batch_size to zero to disable pg_net requests during upgrade; restarting pg_net worker processes to make setting active + run_sql -c "ALTER SYSTEM SET pg_net.batch_size = 0;" + run_sql -c "SELECT pg_reload_conf(); SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE backend_type ILIKE '%pg_net%';" + cat << EOF >> $POST_UPGRADE_EXTENSION_SCRIPT ALTER SYSTEM SET jit = off; SELECT pg_reload_conf();