pgpool2.git
3 years agoAdd relase notes.
Masaya Kawamoto [Thu, 17 Feb 2022 01:15:44 +0000 (01:15 +0000)]
Add relase notes.

3 years agoEnhance parameter status handling.
Tatsuo Ishii [Sun, 13 Feb 2022 04:15:55 +0000 (13:15 +0900)]
Enhance parameter status handling.

When a parameter status message arrives from backend, Pgpool-II
memorized it but did not forward to frontend.  This commit allows
forwarding a parameter status message to frontend.

3 years agoFixed the streaming replication check process not to retry if it cannot connect to...
Bo Peng [Thu, 10 Feb 2022 02:02:38 +0000 (11:02 +0900)]
Fixed the streaming replication check process not to retry if it cannot connect to the backend.

If the backend takes so long to respond, the connection times out,
then the streaming replication check process will continue to retry.
This retry causes a long time failover.

3 years agoFix missed static declaration.
Tatsuo Ishii [Wed, 9 Feb 2022 23:58:26 +0000 (08:58 +0900)]
Fix missed static declaration.

The static declaration of fork_follow_child() was missing.

3 years agoFix mistake in previous commit for pgpool_setup.in.
Tatsuo Ishii [Sun, 6 Feb 2022 23:29:18 +0000 (08:29 +0900)]
Fix mistake in previous commit for pgpool_setup.in.

In the commit it mistakenly replace master_node_id with main_node_id.

3 years agoFix failover() to deal with the case when no former primary node exists.
Tatsuo Ishii [Sun, 6 Feb 2022 08:11:52 +0000 (17:11 +0900)]
Fix failover() to deal with the case when no former primary node exists.

Consider a case when no primary node exists when Pgpool-II starts
up. In this case Req_info->primary_node_id is -1. failover() did not
consider this and skipped to call find_primary_node_repeatedly().
Also follow_master_command was not executed if
Req_info->primary_node_id is -1.

This commit fixes the bug above.

Discussion: https://www.pgpool.net/pipermail/pgpool-hackers/2022-February/004114.html

3 years agoFix pgpool_setup in failover scrip creation.
Tatsuo Ishii [Sun, 6 Feb 2022 07:23:46 +0000 (16:23 +0900)]
Fix pgpool_setup in failover scrip creation.

When pgpool_set creates failover.sh, it did not consider the case when
no primary server existed.

3 years agoAdd restriction about set_config.
Tatsuo Ishii [Wed, 2 Feb 2022 06:46:50 +0000 (15:46 +0900)]
Add restriction about set_config.

3 years agoFix memory leak pointed out by Coverity.
Tatsuo Ishii [Wed, 2 Feb 2022 01:19:26 +0000 (10:19 +0900)]
Fix memory leak pointed out by Coverity.

Actually it's a false positive.

3 years agoFix health check process issues pointed out by Coverity.
Tatsuo Ishii [Wed, 2 Feb 2022 01:04:06 +0000 (10:04 +0900)]
Fix health check process issues pointed out by Coverity.

Fix possible NULL terminate missing and memory leak when running in test mode.

3 years agoFix long standing bug with pcp_node_info.
Tatsuo Ishii [Mon, 31 Jan 2022 02:45:33 +0000 (11:45 +0900)]
Fix long standing bug with pcp_node_info.

It appears that occasionally pcp_node_info shows backend_status field
as "quarantine" when it should be "down". While pcp_node_info shows
the status, first it checks the backend_status member in BackendInfo
struct. If it is 3, then checks quarantine member. If it is other than
0, then the backend_status field is shown as "quarantine". So if
garbage remains in quarantine member, it is shown as "quarantine". The
BackendInfo struct is transferred from pcp_worker process to pcp
frontend client. Unfortunately when the quarantine member was added by
commit 54af632c, it was forgotten to modify pcp_worker.c and
pcp_frontend.c so that the "quarantine" member is transferred.

Fix is needed to be back patched to 3.7, when the "quarantine" member
was first added.

Discussion: https://www.pgpool.net/pipermail/pgpool-hackers/2022-January/004110.html

3 years agoTest: fix pgpool_setup and watchdog_setup binary PATH in noinstall mode.
Bo Peng [Thu, 13 Jan 2022 05:34:22 +0000 (14:34 +0900)]
Test: fix pgpool_setup and watchdog_setup binary PATH in noinstall mode.

3 years agoUpdate Makefile.in
Bo Peng [Wed, 12 Jan 2022 10:56:27 +0000 (19:56 +0900)]
Update Makefile.in

3 years agoAllow to run regression test against existing installation without recompiling.
Tatsuo Ishii [Wed, 22 Dec 2021 01:13:20 +0000 (10:13 +0900)]
Allow to run regression test against existing installation without recompiling.

It is possible to run regression test using existing installation.

regression.sh -m noinstall

However some of tests fail in this case because those tests require
pgpool to be compiled with variable HEALTHCHECK_DEBUG is set. This is
only possible in following procedure.

make clean
cd src/test/regression
./regress.sh

To run the regression test against existing installation new config
variable "health_check_test" is added. The source code is always
compiled as if HEALTHCHECK_DEBUG is set. The test facility is not
activated unless health_check_test is set to on.

For now I push to only master branch. After some tests, I am going to
push to all supported branches. I know adding new parameter to stable
branches is unusual but the feature is for enhancing test and it is
not visible to ordinal users. So I think my plan is justified by them.

Discussion: https://www.pgpool.net/pipermail/pgpool-hackers/2021-December/004078.html

3 years agoDoc: add restriction regarding ParameterStatus and in_hot_standby parameter.
Tatsuo Ishii [Fri, 7 Jan 2022 01:07:55 +0000 (10:07 +0900)]
Doc: add restriction regarding ParameterStatus and in_hot_standby parameter.

3 years agoSuppress message length log for in_hot_standby.
Tatsuo Ishii [Thu, 6 Jan 2022 07:53:42 +0000 (16:53 +0900)]
Suppress message length log for in_hot_standby.

PostgreSQL 14 introduced new config parameter: in_hot_standby
https://www.postgresql.org/docs/14/runtime-config-preset.html
The value is either "on" for standby servers or "off" for primary
servers. As a result pgpool log is fladded by the messages:

2021-12-16 10:40:34.855: psql pid 366965: LOG:  reading message length
2021-12-16 10:40:34.855: psql pid 366965: DETAIL:  message length (22) in slot 1 does not match with slot 0(23)

To avoid this, only complain if the parameter name is not in_hot_standby.
Also the message is enhanced to show the parameter name.

2022-01-05 13:05:15.993: psql pid 642877: LOG:  ParameterStatus "TimeZone": node 1 message length 30 is different from main node message length 24

Discussion: https://www.pgpool.net/pipermail/pgpool-hackers/2021-December/004077.html

3 years agoDoc: add "exclude" settings to /etc/yum.repos.d/pgdg-redhat-all.repo so that Pgpool...
Bo Peng [Tue, 4 Jan 2022 12:59:59 +0000 (21:59 +0900)]
Doc: add "exclude" settings to /etc/yum.repos.d/pgdg-redhat-all.repo so that Pgpool-II is not installed from PostgreSQL YUM repository.

3 years agoDoc: fix documentation typos.
pengbo [Tue, 4 Jan 2022 05:34:19 +0000 (14:34 +0900)]
Doc: fix documentation typos.

Patch is created by Umar Hayat.

3 years agoDoc: fix release notes.
Masaya Kawamoto [Thu, 23 Dec 2021 07:22:27 +0000 (07:22 +0000)]
Doc: fix release notes.

3 years agoPrepare 4.0.17 V4_0_17 V4_0_17_RPM
Masaya Kawamoto [Wed, 22 Dec 2021 09:09:58 +0000 (09:09 +0000)]
Prepare 4.0.17

3 years agoAdd release notes.
Masaya Kawamoto [Wed, 22 Dec 2021 08:39:19 +0000 (08:39 +0000)]
Add release notes.

3 years agoRevert "Add validations of wd_lifecheck_password and recovery_password format"
Tatsuo Ishii [Sat, 11 Dec 2021 00:41:42 +0000 (09:41 +0900)]
Revert "Add validations of wd_lifecheck_password and recovery_password format"

This reverts commit 1a3516908dbb6cf0b1eb07493fb2d95544a38a84.

This commit caused failure in regression test due to pcp_recovery_node_error:
recovery node 1...ERROR:  invalid password format for recovery_user: t-ishii
DETAIL:  md5 hashed password is not allowed here

3 years agoAdd validations of wd_lifecheck_password and recovery_password format
Masaya Kawamoto [Fri, 10 Dec 2021 04:48:30 +0000 (04:48 +0000)]
Add validations of wd_lifecheck_password and recovery_password format

wd_lifecheck_password and recovery_password are not allowed to be md5
hashed password format but pgpool did not check them.

3 years agoDoc: fix typo in pcp_watchdog_info manual.
Tatsuo Ishii [Thu, 9 Dec 2021 23:24:27 +0000 (08:24 +0900)]
Doc: fix typo in pcp_watchdog_info manual.

3 years agoSuppress bison warnings regarding yacc incompatibility.
Tatsuo Ishii [Fri, 3 Dec 2021 05:40:23 +0000 (14:40 +0900)]
Suppress bison warnings regarding yacc incompatibility.

Run bison without yacc compatibility may raise some risks, so just suppress warnings.

3 years agoDoc: fix typos.
Bo Peng [Thu, 25 Nov 2021 06:19:45 +0000 (15:19 +0900)]
Doc: fix typos.

3 years agoFix redundant code.
Tatsuo Ishii [Mon, 22 Nov 2021 07:31:39 +0000 (16:31 +0900)]
Fix redundant code.

Patch contributed by Lu Chenyang.

3 years agoPrepare 4.0.16 V4_0_16 V4_0_16_RPM
Masaya Kawamoto [Thu, 18 Nov 2021 03:00:33 +0000 (03:00 +0000)]
Prepare 4.0.16

3 years agoFix release note version.
Masaya Kawamoto [Thu, 18 Nov 2021 02:57:53 +0000 (02:57 +0000)]
Fix release note version.

3 years agoAdd release notes for Pgpool-II 4.0.16
Masaya Kawamoto [Thu, 18 Nov 2021 02:34:59 +0000 (02:34 +0000)]
Add release notes for Pgpool-II 4.0.16

3 years agoReject extraneous data after SSL encryption handshake.
Tatsuo Ishii [Wed, 17 Nov 2021 10:26:11 +0000 (19:26 +0900)]
Reject extraneous data after SSL encryption handshake.

In the server side implementation of SSL negotiation
(pool_ssl_negotiate_serverclient()), it was possible for a
man-in-the-middle attacker to inject arbitrary SQL commands. This is
possible if Pgpool-II is configured to use cert authentication or
hostssl + trust. This resembles PostgreSQL's CVE-2021-23214.

Similarly, in the client side implementation of SSL negotiation
(pool_ssl_negotiate_clientserver()), it was possible for a
man-in-the-middle attacker to inject arbitrary responses. This is
possible if PostgreSQL is using trust authentication with a clientcert
requirement. It is not possible with cert authentication because
Pgpool-II does not implement the cert authentication between Pgpool-II

To fix these reject extraneous data in the read buffer after SSL
encryption handshake.
and PostgreSQL. This resembles PostgreSQL's CVE-2021-23222.

3 years agoDeal with PostgreSQL 14 while processing pg_terminate_backend().
Tatsuo Ishii [Tue, 16 Nov 2021 00:45:31 +0000 (09:45 +0900)]
Deal with PostgreSQL 14 while processing pg_terminate_backend().

Do not reject two arguments form of pg_terminate_backend() as
PostgreSQL 14 or after accept two arguments.

3 years agoFix occasional 073.pg_terminate_backend regression test failure.
Tatsuo Ishii [Tue, 16 Nov 2021 00:02:47 +0000 (09:02 +0900)]
Fix occasional 073.pg_terminate_backend regression test failure.

The test used "ps -ef" command to find the process which is running
SELECT command.  However in some cases the "ps -ef" command omits part
of "SELECT" in its output and this made the test fail.
So use "ps -efw" instead of "ps -ef" to prevent it.

3 years agoRename regression test 074.
Bo Peng [Mon, 8 Nov 2021 08:27:38 +0000 (17:27 +0900)]
Rename regression test 074.

3 years agoEnhance SIGHLD handler of Pgpool-II main process.
Tatsuo Ishii [Sun, 24 Oct 2021 07:22:33 +0000 (16:22 +0900)]
Enhance SIGHLD handler of Pgpool-II main process.

When Pgpool-II child is killed by SIGKILL signal, the SIGHLD handler
just emitted LOG level message as other signals.  But SIGKILL is an
important event, for example killed by OOM killer. So emit a WARNING
level message instead.

Per suggestion from Michail Alexakis.
Discussion: https://www.pgpool.net/pipermail/pgpool-general/2021-October/007808.html

3 years agoFix signal handler for SIGTERM, SIGINT and SIGQUIT.
Tatsuo Ishii [Tue, 12 Oct 2021 01:40:11 +0000 (10:40 +0900)]
Fix signal handler for SIGTERM, SIGINT and SIGQUIT.

It did not properly save errno and it was possible to overwrite errno.

3 years agoDoc: fix documentaion typos.
Bo Peng [Wed, 6 Oct 2021 01:33:04 +0000 (10:33 +0900)]
Doc: fix documentaion typos.

3 years agoFix documentation typos.
Bo Peng [Mon, 4 Oct 2021 11:25:27 +0000 (20:25 +0900)]
Fix documentation typos.

Patch is created by Kazufumi Noto.

4 years agoFix psql command path to avoid test failure.
Bo Peng [Thu, 23 Sep 2021 11:44:27 +0000 (20:44 +0900)]
Fix psql command path to avoid test failure.

4 years agoFix occasional hang in COPY FROM.
Tatsuo Ishii [Thu, 16 Sep 2021 07:27:28 +0000 (16:27 +0900)]
Fix occasional hang in COPY FROM.

If an error occurs while doing COPY FROM, it was possible the
Pgpool-II waited forever for a response from backend after COPY end
marker was sent from frontend. Pgpool expected a new message arrives
to socket, but it is possible that the message (in this case an error
message) is already in the backend read buffer. The fix is, check the
buffer is empty or not before reading from the socket.  New test case
(07.copy_hang) is also added.

The bug was found by Bo Peng.

4 years agoFix pgpool_setup to do nothing when no new main node is available.
Tatsuo Ishii [Wed, 25 Aug 2021 00:52:39 +0000 (09:52 +0900)]
Fix pgpool_setup to do nothing when no new main node is available.

When no new main node is available due to there's only 1 node
remaining, pgpool_setup tried to promote a node with node id -1.  This
is impossible. Fix is just skipping whole failover process if new main
node id is -1.

4 years agoFix the incorrect display of load balancing node in raw mode.
Bo Peng [Wed, 18 Aug 2021 08:00:28 +0000 (17:00 +0900)]
Fix the incorrect display of load balancing node in raw mode.

In raw mode, Pgpool-II sends all queies to main node.
This is harmless, but it may confuse users.

4 years agoUpdate Makefile.in and configure.
Bo Peng [Tue, 10 Aug 2021 12:08:16 +0000 (21:08 +0900)]
Update Makefile.in and configure.

4 years agoFix "ar: `u' modifier ignored since `D' is the default (see `U')" warnings.
Tatsuo Ishii [Tue, 10 Aug 2021 10:07:59 +0000 (19:07 +0900)]
Fix "ar: `u' modifier ignored since `D' is the default (see `U')" warnings.

The warning can be eliminated by changing arguments of ar command from
"cru" to "cr".  There were two places of the warnings: src/libs/pcp
and src/watchdog.  For the former, we need to fix libtool, which is
generated by configure. So fix configure.ac.  For the latter, just fix
src/watchdog/Makefile.am.

4 years agoDoc: fix typo in Japanese release note.
Masaya Kawamoto [Tue, 10 Aug 2021 01:37:44 +0000 (01:37 +0000)]
Doc: fix typo in Japanese release note.

4 years agoDoc: Mention that double quotes are required in "PGPOOL SHOW" command if the paramete...
Bo Peng [Mon, 9 Aug 2021 01:43:47 +0000 (10:43 +0900)]
Doc: Mention that double quotes are required in "PGPOOL SHOW" command if the parameter contains uppercase letters.

4 years agoFix backend_flag* parameter shown twice while executing "pgpool show all".
Tatsuo Ishii [Sun, 8 Aug 2021 04:19:33 +0000 (13:19 +0900)]
Fix backend_flag* parameter shown twice while executing "pgpool show all".

There are two entries of "backend_flag" for "ALLOW_TO_FAILOVER" and
"ALWAYS_PRIMARY" in the config variable struct. This is mostly ok but
"pgpool show all" command displayed both backend_flag entries, which
looks redundant. The reason for this is, report_all_variables() shows
grouped variables first then other variables except already shown as
grouped variables.  Unfortunately build_variable groups() is not smart
enough to build grouped variable data: it only registers the first
backend_flag entry and leaves the second entry. Since the second entry
is not a grouped variable, backend_flag is shown firstly as a grouped
variable and then is show as a non grouped variable in
report_all_variables(). To fix this, mark that the second variable is
also a grouped variable (the flag is set by
build_config_variables()). See bug 728 for the report of the problem.

Also add/fix comments.

4 years agoPrepare 4.0.15 V4_0_15 V4_0_15_RPM
Masaya Kawamoto [Tue, 3 Aug 2021 02:39:37 +0000 (02:39 +0000)]
Prepare 4.0.15

4 years agoAdd release notes.
Masaya Kawamoto [Tue, 3 Aug 2021 02:12:01 +0000 (02:12 +0000)]
Add release notes.

4 years agoDoc: Fix documentation typos.
Bo Peng [Wed, 14 Jul 2021 14:05:16 +0000 (23:05 +0900)]
Doc: Fix documentation typos.

4 years agoFix query cache to not cache SQLValueFunctions (CURRENT_TIME, CURRENT_USER etc.).
Tatsuo Ishii [Wed, 7 Jul 2021 04:03:59 +0000 (13:03 +0900)]
Fix query cache to not cache SQLValueFunctions (CURRENT_TIME, CURRENT_USER etc.).

Checking SQLValueFunctions was missed whether to be cached or not and
they were regarded as non function objects. As a result they were
cached.

Also add more test cases.

4 years agoDoc: fix typo in in memory query cache document.
Tatsuo Ishii [Tue, 6 Jul 2021 23:44:03 +0000 (08:44 +0900)]
Doc: fix typo in in memory query cache document.

4 years agoAdd buffer length check.
Tatsuo Ishii [Fri, 2 Jul 2021 03:50:29 +0000 (12:50 +0900)]
Add buffer length check.

get_info_from_conninfo() did not check the size of the provided
buffers.  Add length parameters so that it can check the buffer size.

4 years agoFix sending invalid message in SI mode.
Tatsuo Ishii [Thu, 1 Jul 2021 04:41:34 +0000 (13:41 +0900)]
Fix sending invalid message in SI mode.

When a query is aborted by specific reason like serialization error,
Pgpool-II sends error query to abort transactions running on non main
nodes. The message length of the query was incorrect and it caused
"invalid string in message" error on backend.

4 years agoFix rsync parameter in pgpool_setup.
Tatsuo Ishii [Mon, 28 Jun 2021 05:59:06 +0000 (14:59 +0900)]
Fix rsync parameter in pgpool_setup.

It did not exclude "log" directory, which is the default logging
directory in recent PostgreSQL versions. This made hard to examine
PostgreSQL log, since it is copied from primary server.

4 years agoFix 031.connection_life_time.
Tatsuo Ishii [Mon, 21 Jun 2021 01:25:49 +0000 (10:25 +0900)]
Fix 031.connection_life_time.

The test script executed pcp_recovery_node but it always failed
because it tried to connect to UNIX domain socket.

4 years agoUpdate Copyright year.
Tatsuo Ishii [Thu, 17 Jun 2021 23:03:21 +0000 (08:03 +0900)]
Update Copyright year.

4 years agoFix pgpool_setup in creating base backup script.
Tatsuo Ishii [Tue, 15 Jun 2021 08:10:54 +0000 (17:10 +0900)]
Fix pgpool_setup in creating base backup script.

4 years agoDoc: fix wd_life_point description
Masaya Kawamoto [Wed, 2 Jun 2021 07:53:21 +0000 (07:53 +0000)]
Doc: fix wd_life_point description

The description of the default value was lacked in the Japanese doc.

4 years agoEnhance watchdog_setup script.
Tatsuo Ishii [Sat, 29 May 2021 08:32:38 +0000 (17:32 +0900)]
Enhance watchdog_setup script.

shutdownall script generated by watchdog_setup shutdowns in the node
number order i.e.: 0, 1, 2...  This causes PostgreSQL backend shutdown
when pgpool0 node went down and node 1, 2... trigger failover event,
which is not necessary in the whole shutdown sequence.  Shutting down
in the reverse order (...2, 1, 0) should prevent this and shorten the
whole shutdown sequence.

Also this should prevent occasional 018.detach_primary and
028.watchdog_enable_consensus_with_half_votes test timeout (they use
watchdog_setup).

4 years agoFix maximum length of hostnames including domain name.
Tatsuo Ishii [Thu, 27 May 2021 10:15:46 +0000 (19:15 +0900)]
Fix maximum length of hostnames including domain name.

The maximum length of hostnames was 128, which is not incorrect.
Moreover there were multiple places where the maximum length of hostname is defined.
So create unified definition of it in libpcp_ext.h.

Discussion: https://www.pgpool.net/pipermail/pgpool-hackers/2021-May/003904.html

4 years agoFix watchdog communication race condition.
Tatsuo Ishii [Fri, 21 May 2021 23:00:05 +0000 (08:00 +0900)]
Fix watchdog communication race condition.

Watchdog sends information from the watchdog process to the Pgpool-II
main process using SIGUSR1. To pass detailed messages it uses shared
memory area. First it sets a message to the shared memory area then
sends SIGUSR1 to the main process. The main process received the
signal and the signal handler sets a global variable so that
sigusr1_interrupt_processor() processes it. However it is possible
that while sigusr1_interrupt_processor() is running new signal
arrives. In this case the new signal is caught but the global variable
is set to 0 after sigusr1_interrupt_processor() returns. This means
that the new message is not processed until new signal arrives, which
could cause significant delay before the message was processed.

To fix the problem, sigusr1_interrupt_processor() is repeatedly called
until there's no pending message.

Discussion: https://www.pgpool.net/pipermail/pgpool-hackers/2021-May/003901.html

4 years agoFix for bug:684: Watchdog node status not updating after rebooting.
Muhammad Usama [Thu, 20 May 2021 12:30:02 +0000 (17:30 +0500)]
Fix for bug:684: Watchdog node status not updating after rebooting.

A node should broadcast its status to the whole cluster after
joining the cluster as standby.

4 years agoFix "file name is too long (max 99)" error while creating a tarball. V4_0_14 V4_0_14_RPM
Bo Peng [Wed, 19 May 2021 13:52:03 +0000 (22:52 +0900)]
Fix "file name is too long (max 99)" error while creating a tarball.

4 years agoPrepare 4.0.14.
Bo Peng [Wed, 19 May 2021 13:12:26 +0000 (22:12 +0900)]
Prepare 4.0.14.

4 years agoAdd release notes.
Bo Peng [Wed, 19 May 2021 12:53:05 +0000 (21:53 +0900)]
Add release notes.

4 years agoDoc: fix typo.
Tatsuo Ishii [Tue, 18 May 2021 02:23:26 +0000 (11:23 +0900)]
Doc: fix typo.

4 years agoUpdate copyright year.
Tatsuo Ishii [Fri, 14 May 2021 02:44:47 +0000 (11:44 +0900)]
Update copyright year.

4 years agoFix warning on elog format.
Tatsuo Ishii [Wed, 12 May 2021 01:47:17 +0000 (10:47 +0900)]
Fix warning on elog format.

In file included from main/pgpool_main.c:53:0:
main/pgpool_main.c: In function ‘initialize_shared_mem_objects’:
main/pgpool_main.c:3664:12: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘size_t {aka long unsigned int}’ [-Wformat=]

4 years agoRevert "Fix memory leak in pcp_node_info."
Tatsuo Ishii [Thu, 13 May 2021 11:50:29 +0000 (20:50 +0900)]
Revert "Fix memory leak in pcp_node_info."

This reverts commit 39af6d0181e090ec01c87fcc05fca0954da54274.

4 years agoFix memory leak in pcp_node_info.
Tatsuo Ishii [Wed, 12 May 2021 02:33:56 +0000 (11:33 +0900)]
Fix memory leak in pcp_node_info.

Detected by Covery.

4 years agoDoc: update copyright year.
Tatsuo Ishii [Tue, 11 May 2021 05:35:19 +0000 (14:35 +0900)]
Doc: update copyright year.

4 years agoDoc: fix description about heartbeat_device.
Tatsuo Ishii [Tue, 11 May 2021 05:26:24 +0000 (14:26 +0900)]
Doc: fix description about heartbeat_device.

It did not mention the parameter can only be used if Pgpool-II started
as root.

4 years agoFix broken database/app redirect preference in statement level load balancing mode.
Bo Peng [Wed, 5 May 2021 10:01:11 +0000 (19:01 +0900)]
Fix broken database/app redirect preference in statement level load balancing mode.

Reported in bug707.

4 years agoFix watchdog_setup to not fail when -n is not specified.
Tatsuo Ishii [Wed, 5 May 2021 00:26:58 +0000 (09:26 +0900)]
Fix watchdog_setup to not fail when -n is not specified.

watchdog_setup failed if -n (number of PostgreSQL clusters) is not
specified. Now if -n is not specified, assume "-n = 2", which is same
as in pgpool_setup.

4 years agoDoc: fix typo.
Tatsuo Ishii [Tue, 4 May 2021 21:56:13 +0000 (06:56 +0900)]
Doc: fix typo.

4 years agoFix pgpool_setup to not show an error.
Tatsuo Ishii [Mon, 3 May 2021 07:47:24 +0000 (16:47 +0900)]
Fix pgpool_setup to not show an error.

In the streaming replication mode pgpool_setup showed error:
:
:
recovery node 2...pcp_recovery_node -- Command Successful
done.
creating follow primary script
psql: error: server closed the connection unexpectedly
      This probably means the server terminated abnormally
      before or while processing the request.
shutdown all
:
:
While creating followers, pgpool_setup confirmed using
wait_for_pgpool_startup that pgpool comes up online except the last
node. This is unnecessary and it should confirm that pgpool comes up
even in the last node.

4 years agoFix watchdog_setup.
Tatsuo Ishii [Fri, 30 Apr 2021 10:49:35 +0000 (19:49 +0900)]
Fix watchdog_setup.

watchdog_setup creates database cluster entity under pgpool0. In other
pgpool nodes's pgpool.conf just has the port number for PostgreSQL in
pgpool0.  But backend_data_directory remains their own PostgreSQL
cluster. For example:

backend_data_directory0 = '/home/t-ishii/work/Pgpool-II/current/x/pgpool2/data0'

This is fine until online recovery runs. If it referrers to the
database cluster directory, which is not correct of course.  Fix this
by replacing database cluster directories with symlinks to
pgppol/data0 and so on. This will reduce disk space.

4 years agoFix verify_backend_node_status().
Tatsuo Ishii [Tue, 27 Apr 2021 08:24:14 +0000 (17:24 +0900)]
Fix verify_backend_node_status().

It is possible that backend_hostname is Unix domain socket but
wal_receiver connects via TCP/IP localhost.
verify_backend_node_status() should accept this as normal.  This
actually happened in the Pgpool-II cluster created by pgpool_setup.  I
found this while testing detach_false_primary.

4 years agoFix copyright.
Tatsuo Ishii [Sun, 25 Apr 2021 08:38:20 +0000 (17:38 +0900)]
Fix copyright.

Pgproto was originally written by me and then contributed to PgPool
Global Development Group in 2018.

4 years agoDoc: fix compile error.
Tatsuo Ishii [Tue, 20 Apr 2021 04:44:29 +0000 (13:44 +0900)]
Doc: fix compile error.

4 years agoDoc: enhance client authentication document.
Tatsuo Ishii [Tue, 20 Apr 2021 00:31:52 +0000 (09:31 +0900)]
Doc: enhance client authentication document.

Mention that pg_md5 command requires --config-file option.

4 years agoFix bug with 074 test script.
Tatsuo Ishii [Fri, 16 Apr 2021 07:54:52 +0000 (16:54 +0900)]
Fix bug with 074 test script.

The script tried to execute in SI mode even in V4_1_STABLE and
V4_0_STABLE.  Of course this is wrong because SI mode was implemented
in 4.2.

4 years agoDoc: enhance show pool_cache manual.
Tatsuo Ishii [Tue, 13 Apr 2021 04:28:38 +0000 (13:28 +0900)]
Doc: enhance show pool_cache manual.

Add note that not all columns shows meaningful values when cache
storage is memcached.

4 years agoFix regression test 072 and 074.
Tatsuo Ishii [Mon, 12 Apr 2021 03:00:54 +0000 (12:00 +0900)]
Fix regression test 072 and 074.

In these tests pgproto is used. However the script forgot to specify
the path to the command.  It is interesting that test 072 is keeping
reporting ok. This is because the test script does not care even if
pgproto does not found.

4 years agoAdd new regression test 074.bug700_memqcache_bug_segfault_at_close_complete which...
Tatsuo Ishii [Sun, 11 Apr 2021 05:25:31 +0000 (14:25 +0900)]
Add new regression test 074.bug700_memqcache_bug_segfault_at_close_complete which was missed in the previous commit.

The test was missed in commit: a531e783c90a88ab429d0de83fadb7e41c787a92

4 years agoFix pgpool crash when query cache enabled.
Tatsuo Ishii [Fri, 9 Apr 2021 10:32:56 +0000 (19:32 +0900)]
Fix pgpool crash when query cache enabled.

Pgpool-II crashed upon receiving CloseComplete.
This only happened in other than streaming and logical replication mode.

The minimum test case is as follows:

'P' "S1" "SELECT 1" 0
'B' "P1" "S1" 0 0 0
'E' "P1" 0
'C' 'P' "P1"
'B' "P2" "S1" 0 0 0
'E' "P2" 0
'C' 'P' "P2"
'S'
'Y'
'X'

A query statement S1 is bound to portal P1 and P1 is closed. When
CommandComplete message arrives, CloseComplete() discard temp query
cache buffer corresponding to the query context. Unfortunately it
forgot to set NULL to query_context->temp_cache. So whnen next time
other portal P2 which was also bound to S1 is closed, CloseComplete()
tries to free memory which was already freed by previous
CloseComplete. This leads to a segfault.

Fix is set NULL to query_context->temp_cache when the CloseComplete()
is called.

The reason why in streaming and logical replication this does occur
is, unlike other mode, in these mode query_context->temp_cache is
already freed and set to NULL when CommandComplete arrives.

Also new regression test
074.bug700_memqcache_bug_segfault_at_close_complete is added.

Per bug 700.

4 years agoFix that query cache is not created in other than streaming and logical replication...
Tatsuo Ishii [Mon, 5 Apr 2021 02:03:06 +0000 (11:03 +0900)]
Fix that query cache is not created in other than streaming and logical replication mode.

We used to create query cache in ReadyForQuery() in extended query
mode in other than streaming and logical replication mode. However if
following message sequence is sent from frontend, the query cache was
never created because pool_is_cache_safe() returns false in
pool_handle_query_cache(). Why? Because pool_is_cache_safe() examines
the current query context, and the current query context is for "END"
message.

'P' "" "BEGIN" 0
'B' "" "" 0 0 0
'E' "" 0
'P' "S1" "SELECT 1" 0
'B' "S1" "S1" 0 0 0
'E' "S1" 0
'P' "" "END" 0
'B' "" "" 0 0 0
'E' "" 0
'S'
'Y'
'X'

So this commit changes CommandComplete() so that
pool_handle_query_cache() gets called in not only streaming and
logical replication mode. pool_handle_query_cache() will create a
temporary query cache and it will be processed when next time
ReadyForQuery() is called for an END message.

I found the bug while taking care of:
https://www.pgpool.net/mantisbt/view.php?id=700

Note that if the transaction is ended by a simple query message "END",
the bug does not appear because extended query SELECT messages will be
followed by a SYNC message, which will produce a Ready for query
message, and ReadyForQuery() will happily register query cache since
this time pool_is_cache_safe() returns true.

I think this is a long standing bug. The reason why this was not found
earlier is, despite the similar message sequence is created by the JDBC
driver, CommandComplete() already handles in the way described above.

4 years agoEnhance debug message upon receiving startup packet.
Tatsuo Ishii [Tue, 16 Mar 2021 01:27:22 +0000 (10:27 +0900)]
Enhance debug message upon receiving startup packet.

While processing a startup packet, database name, user name and
application name are printed in DEBUG1, but other guc variables (if
any) were not printed. This is not helpful when studying errors like
"connection exists but startup packet length is not identical" problem
(see https://www.pgpool.net/mantisbt/view.php?id=696). With this
commit guc variables are now printed something like:

2021-03-16 10:21:32: child pid 5155: DEBUG:  reading startup packet
2021-03-16 10:21:32: child pid 5155: DETAIL:  guc name: client_encoding value: UTF8

4 years agoDoc: enhance pcp_detach_node manual.
Tatsuo Ishii [Sat, 20 Feb 2021 00:45:16 +0000 (09:45 +0900)]
Doc: enhance pcp_detach_node manual.

Add more detailed description when the command is executed.

4 years agoPrepare 4.0.13. V4_0_13 V4_0_13_RPM
Bo Peng [Wed, 17 Feb 2021 09:23:56 +0000 (18:23 +0900)]
Prepare 4.0.13.

4 years agoAdd release note.
Bo Peng [Wed, 17 Feb 2021 03:56:54 +0000 (12:56 +0900)]
Add release note.

4 years agoDoc: fix example in pgpool_adm pcp_node_info().
Tatsuo Ishii [Sun, 14 Feb 2021 01:17:08 +0000 (10:17 +0900)]
Doc: fix example in pgpool_adm pcp_node_info().

Per commit: https://git.postgresql.org/gitweb/?p=pgpool2.git;a=commit;h=caf5215479ee7a5b55c1dcdeb00a2fccf0ed7133

4 years agoFix pcp_node_info() in pgpool_adm extension.
Tatsuo Ishii [Sun, 14 Feb 2021 00:28:38 +0000 (09:28 +0900)]
Fix pcp_node_info() in pgpool_adm extension.

The weight info was mistakenly handled by Float8GetDatum although the
function prototype is float4. The oversight made the weight value to 0
or certain insane value. Change it to Float4GetDatum.  It is amazing
that nobody (including me) did not notice it until today.

4 years agoFix watchdog leader sync process to start health check process.
Tatsuo Ishii [Mon, 8 Feb 2021 11:30:18 +0000 (20:30 +0900)]
Fix watchdog leader sync process to start health check process.

When watchdog receives status change request from other watchdog node
and calls sync_backend_from_watchdog() to sync with status of leader
node, it forgot to start health check process. For example,

1) initial pgpool_status file indicates DB node 1 is down.
2) pgpool starts up but only starts health check process for DB node 0
   because node 1 is in down status.
3) pcp_attach_node is issued to other than leader pgpool node.
4) leader node updates the node status for DB node 1 and other node
   syncs the status. Since sync_backend_from_watchdog() does not start
   health check process, only on pgpool leader node starts health
   check process but other nodes do not.

To fix this starts health check process if necessary in
sync_backend_from_watchdog().

4 years agoFix that DB cluster path was not correct in watchdog_setup installation.
Tatsuo Ishii [Thu, 4 Feb 2021 02:28:57 +0000 (11:28 +0900)]
Fix that DB cluster path was not correct in watchdog_setup installation.

In the watchdog_setup installation generated path to DB clusters did
not correctly point to pgpool0/data0 etc. Correct them by using sed
command.

4 years agoFix typos in message emitted by sync_backend_from_watchdog().
Tatsuo Ishii [Wed, 3 Feb 2021 08:01:23 +0000 (17:01 +0900)]
Fix typos in message emitted by sync_backend_from_watchdog().

4 years agoEnhance pgpool_setup.
Tatsuo Ishii [Tue, 2 Feb 2021 14:12:37 +0000 (23:12 +0900)]
Enhance pgpool_setup.

"shutdownall" script unconditionally waited for the pgpool.pid file is
gone after "pgpool stop".  But if invalid pgpool.pid file exists, it
waits forever. To avoid this check the exit status of "pgpool stop"
and only wait if the exit status is 0.

4 years agoFix messages when health check process starts.
Tatsuo Ishii [Tue, 2 Feb 2021 00:56:23 +0000 (09:56 +0900)]
Fix messages when health check process starts.

Fix when health check process was restarted by reaper(), incorrect
"child process with pid: 14639 exited with success and will not be
restarted" was emitted.

Also enhance worker_fork_a_child() to emit a message that new worker
process started.

4 years agoDoc: Fix some variable names in follow_master.sh.sample.
Bo Peng [Mon, 1 Feb 2021 16:26:17 +0000 (01:26 +0900)]
Doc: Fix some variable names in follow_sh.sample.

Fix some variable names of "master" to "primary" which should be used in streaming replication mode.

Conflicts:
src/sample/scripts/follow_master.sh.sample