[pgpool-hackers: 4465] abnormal behavior about PGPOOL RESET. and proposal a patch file.
reported that "pgpool reset" command fails if watchdog is enabled.
test=# PGPOOL RESET client_idle_limit;
SET
ERROR: Pgpool node id file �y/pgpool_node_id does not exist
DETAIL: If watchdog is enable, pgpool_node_id file is required
message type 0x5a arrived from server while idle
message type 0x43 arrived from server while idle
message type 0x5a arrived from server while idle
SetPgpoolNodeId() tried to obtain the path to the node id file by
using global variable config_file_dir and failed because it points to
an automatic variable in ParseConfigFile().
To fix this, change the config_file_dir from a pointer to an array and
save the path string into config_file_dir in ParseConfigFile().
Also regression test is added to 004.watchdog.
Bug reported and problem analysis by keiseo.
Back patch to V4.2 in which the node id file was introduced.
POOL_CONFIG g_pool_config; /* configuration values */
POOL_CONFIG *pool_config = &g_pool_config; /* for legacy reason pointer to the above struct */
static unsigned Lineno;
-char *config_file_dir = NULL; /* directory path of config file pgpool.conf */
+char config_file_dir[POOLMAXPATHLEN + 1]; /* directory path of config file pgpool.conf */
typedef enum {
POOL_KEY = 1,
/* get directory path of config file pgpool.conf */
strlcpy(buf, config_file, sizeof(buf));
get_parent_directory(buf);
- config_file_dir = buf;
+ strlcpy(config_file_dir, buf, sizeof(config_file_dir));
}
* pgpool: a language independent connection pool server for PostgreSQL
* written by Tatsuo Ishii
*
- * Copyright (c) 2003-2023 PgPool Global Development Group
+ * Copyright (c) 2003-2024 PgPool Global Development Group
*
* Permission to use, copy, modify, and distribute this software and
* its documentation for any purpose and without fee is hereby
} POOL_CONFIG;
extern POOL_CONFIG * pool_config;
-extern char *config_file_dir; /* directory path of config file pgpool.conf */
+extern char config_file_dir[]; /* directory path of config file pgpool.conf */
typedef enum
{
source $TESTLIBS
LEADER_DIR=leader
STANDBY_DIR=standby
+PSQL=$PGBIN/psql
success_count=0
rm -fr $LEADER_DIR
sleep 2
done
+# at this point the watchdog leader and stabdby are working.
+# check to see if "pgpool reset" command works.
+echo "Check pgpool reset command..."
+for i in 11000 11100
+do
+ echo "Check pgpool reset command on port $i..."
+ $PSQL -p $i -c "pgpool reset client_idle_limit" test
+ if [ $? = 0 ];then
+ success_count=$(( success_count + 1 ))
+ fi
+done
+
# step 2 stop leader pgpool and see if standby take over
$PGPOOL_INSTALL_DIR/bin/pgpool -f $LEADER_DIR/etc/pgpool.conf -m f stop
cd leader
./shutdownall
-echo "$success_count out of 4 successful";
+echo "$success_count out of 6 successful";
-if test $success_count -eq 4
+if test $success_count -eq 6
then
exit 0
fi