[pgpool-hackers: 3973] Proposal: using environment variables instead of script arguments

Tatsuo Ishii ishii at sraoss.co.jp
Thu Jul 15 14:12:12 JST 2021


Currently following scripts receive necessary information as script
arguments.

failback_command
failover_command
follow_primary_command
recovery_1st_stage_command
recovery_2nd_stage_command

This is painful for both pgpool developers and users because:

- every time new argument is added, pgpool needs to update source code
  to add the argument. For example, an extension "pgpool_recovery"
  needs to be updated if new arguments are added. Thus we have 1.0,
  1.1, 1,2 and 1.3 versions of the extension. Moreover developers need
  to write upgrade scripts to update to newer version of extension.

- pgpool users need to remember what $1 is, $2 etc. are.

I propose to stop using arguments and use environment variables
instead. For a backward compatibility sake, it may be better to provide
both arguments and environment variables for Pgpool-II 4.3, then
eliminate arguments 4.4.

Here are list of proposed environment variables:

POOL_ATTACHED_NODE	DB node ID of the attached node
POOL_ATTACHED_HOST	Hostname of the attached node
POOL_ATTACHED_PORT	Port number of the attached node
POOL_ATTACHED_PGDATA	Database cluster directory of the attached node
POOL_DETACHED_NODE	DB node ID of the detached node
POOL_DETACHED_HOST	Hostname of the detached node
POOL_DETACHED_PORT	Port number of the detached node
POOL_DETACHED_PGDATA	Database cluster directory of the detached node
POOL_NEW_MAIN_NODE_ID	New main node ID
POOL_NEW_MAIN_NODE_HOST	Hostname of the new main node
POOL_NEW_MAIN_PORT	Port number of the new main node
POOL_NEW_MAIN_PGDATA	Database cluster directory of the new main node
POOL_NEW_PRIMARY_NODE_ID New primary node ID
POOL_NEW_PRIMARY_HOST	Hostname of the new primary node
POOL_NEW_PRIMARY_PORT	Port number of the new primary node
POOL_NEW_PRIMARY_PGDATA	Database cluster directory of the new primary node
POOL_OLD_MAIN_NODE_ID	Old main node ID
POOL_OLD_PRIMARY_NODE_ID Old primary node ID
POOL_OLD_PRIMARY_HOST	Hostname of the old primary node
POOL_OLD_PRIMARY_PORT	Port number of the old primary node
POOL_DETACHED_NODE	DB node ID of the detached node
POOL_DETACHED_HOST	Hostname of the detached node
POOL_DETACHED_PORT	Port number of the detached node
POOL_DETACHED_PGDATA	Database cluster directory of the detached node

Followings do not exist in the current arugument list but I would like
to add for consistency sake:

POOL_OLD_MAIN_HOST	Hostname of the old main node
POOL_OLD_MAIN_PORT	Port number of the old main node
POOL_OLD_MAIN_PGDATA	Database cluster directory of the old main node
POOL_OLD_PRIMARY_PGDATA	Database cluster directory of the old primary node

All variables are prefixed with "POOL_" to not conflict with user's
envrionment variables if any.

Comments and suggestions are welcome.
--
Tatsuo Ishii
SRA OSS, Inc. Japan
English: http://www.sraoss.co.jp/index_en.php
Japanese:http://www.sraoss.co.jp


More information about the pgpool-hackers mailing list