pgpool2.git
3 years agoTest: print Pgpool-II version in the regression test.
Tatsuo Ishii [Sun, 10 Jul 2022 07:04:49 +0000 (16:04 +0900)]
Test: print Pgpool-II version in the regression test.

3 years agoTest: Fix regression test script to look for pgpool.conf in the proper install directory.
Tatsuo Ishii [Sat, 9 Jul 2022 09:41:18 +0000 (18:41 +0900)]
Test: Fix regression test script to look for pgpool.conf in the proper install directory.

regress.sh did set PGPOOLDIR environment variable despite that
pgpool_setup look for pgpool.conf sample files at $PGPOOLDIR/etc. As a
result, pgpool_setup looked for pgpool.conf.sample at default install
directory (usually /usr/local/etc) even if "-m noinstall" is not
set. If inappropriate pgpool.conf sample files are in
/usr/local/etc., regression test fails.

3 years agoFix query cache to not cache timestamptz and timetz cast.
Tatsuo Ishii [Tue, 5 Jul 2022 05:06:10 +0000 (14:06 +0900)]
Fix query cache to not cache timestamptz and timetz cast.

Even if query is constant + cast (like '2022-07-05
14:07:00'::timestamptz), the result can be changed by SET TIME ZONE
command etc. and the result should not be cached.
Also regression test data added.

Discussion: https://www.pgpool.net/pipermail/pgpool-general/2022-July/008353.html

3 years agoFix bug in query cache.
Tatsuo Ishii [Mon, 4 Jul 2022 05:23:48 +0000 (14:23 +0900)]
Fix bug in query cache.

[pgpool-general: 8285] Timestamp cast not cached

reported that query like "Select '2022-02-18
07:00:00.006547’::timestamp" is not cached.

The function non_immutable_function_call_walker() which judges whether
the query contains non immutable functions mistakenly assumes that any
query including cast to timestamp etc. should not to be cached. These
codes were originally added to detect CURRENT_TIMESTAMP etc. as they
are transformed to type cast in raw parser. Unfortunately this is
overkill since "'2022-02-18 07:00:00.006547’::timestamp" is also
transformed to a type cast.

Fortunately Pgpool-II 3.7 and after imported PostgreSQL 10 or newer
parser, which transforms CURRENT_TIMESTAMP etc. to SQLValueFunction.

As a result, the type cast handling code in
non_immutable_function_call_walker() is not necessary anymore. So this
commit removed the code.

Note: an interested thing in the report is, "Select '2022-02-18
07:00:00.006547’::timestamp" is not cached while "Select '2022-02-18
07:00:00.006547’::date" is cached. Why? Well
non_immutable_function_call_walker() (wrongly) assumes that the type
cache is always created by SystemTypeName (a parser's function), which
always adds pg_catalog schema. This only happens when the type name is
a reserved keyword. TIMESTAMP is a reserved keyword (and TIME too). So
non_immutable_function_call_walker() catches TIMESTAMP cast as
expected, but DATE is not a reserved keyword and it is transformed to
type name without "pg_catalog" schema. So
non_immutable_function_call_walker() misses it, and it is cached.

3 years agoDoc: fix description about using PCP password file when connect to Unix domain socket
Masaya Kawamoto [Thu, 30 Jun 2022 03:58:37 +0000 (03:58 +0000)]
Doc: fix description about using PCP password file when connect to Unix domain socket

The localhost entry in pcppass matches only for the default PCP socket
directory path, not all Unix socket connections. This behavior is the
same as pgpass.

3 years agoAdd pool_config.c to src/tools/pgmd5/.gitignore.
Tatsuo Ishii [Mon, 13 Jun 2022 07:09:46 +0000 (16:09 +0900)]
Add pool_config.c to src/tools/pgmd5/.gitignore.

This should avoid the error:
error: The following untracked working tree files would be overwritten by checkout:
src/tools/pgmd5/pool_config.c

3 years agoDoc: fix wrong explanation on memqcache_maxcache, memqcache_expire.
Tatsuo Ishii [Thu, 2 Jun 2022 01:03:12 +0000 (10:03 +0900)]
Doc: fix wrong explanation on memqcache_maxcache, memqcache_expire.

Those parameters cannot be changed by reloading config file. Restarting
pgpool is required.

Discussion: https://www.pgpool.net/pipermail/pgpool-general/2022-June/008254.html

3 years agoAdd volatile modifier to a variable used in the query cache module.
Tatsuo Ishii [Fri, 20 May 2022 04:55:20 +0000 (13:55 +0900)]
Add volatile modifier to a variable used in the query cache module.

"sts" variable used in pool_fetch_memory_cache() did not have volatile
modifier although it is used in PG_TRY() block. If an exception arises
the value set to variable will be lost in the PG_CATCH block. The bad
effect of this will not be triggered unless error occurs and I think
the bad effect has rarely been observed in the wild (as for as I know,
I have never heard such a report). Anyway, bug is bug.

3 years agoPrepare 3.7.24 V3_7_24 V3_7_24_RPM
Bo Peng [Wed, 18 May 2022 02:45:40 +0000 (11:45 +0900)]
Prepare 3.7.24

3 years agoDoc: update doc version.
Bo Peng [Wed, 18 May 2022 02:21:55 +0000 (11:21 +0900)]
Doc: update doc version.

3 years agoDoc: add release notes.
Bo Peng [Wed, 18 May 2022 02:13:54 +0000 (11:13 +0900)]
Doc: add release notes.

3 years agoEnhance in stopping pgpool main process.
Tatsuo Ishii [Sat, 14 May 2022 00:44:21 +0000 (09:44 +0900)]
Enhance in stopping pgpool main process.

If "pgpool stop" couldn't terminate the main process within certain
period (currently 5 seconds), send the signal again. The reason why
pgpool does not accept the stopping signal is not clear at the moment,
I expect this reduces errors of buildfarm timeout. See if this works.

3 years agoFix comment.
Tatsuo Ishii [Tue, 10 May 2022 05:20:26 +0000 (14:20 +0900)]
Fix comment.

3 years agoChange the PID length of pcp_proc_count command to 7 characters long.
Bo Peng [Mon, 2 May 2022 05:15:32 +0000 (14:15 +0900)]
Change the PID length of pcp_proc_count command to 7 characters long.

3 years agoDoc: update the example output of pcp_watchdog_info.
Bo Peng [Thu, 28 Apr 2022 09:17:17 +0000 (18:17 +0900)]
Doc: update the example output of pcp_watchdog_info.

3 years agoFix for [pgpool-general: 7896] Possible race condition..
Muhammad Usama [Wed, 27 Apr 2022 10:30:58 +0000 (15:30 +0500)]
Fix for [pgpool-general: 7896] Possible race condition..

Watchdog does not allow the remote nodes reported lost by life-check to rejoin
the cluster until the life-check process confirms the existence of life in the
previously lost nodes. This is good enough except for the case when the
(lost by life-check) node tries to rejoin the cluster after it was restarted
(Pgpool-II service restarted).
What happens is the cluster keeps rejecting the restarted node because
the cluster's life-check doesn't agree while the restarted node's life-check
waits to be added to cluster before it can start sending the heart-beats.

The fix is to allow the previously lost remote node become the part of the
cluster after restart, no matter the lost-reason.

Issue report:
https://www.pgpool.net/pipermail/pgpool-general/2021-November/007954.html

3 years agoImprove regression test to detect segmentation fault.
Bo Peng [Mon, 18 Apr 2022 15:36:54 +0000 (00:36 +0900)]
Improve regression test to detect segmentation fault.

3 years agoFix possible null pointer dereference per Coverity.
Tatsuo Ishii [Wed, 6 Apr 2022 05:50:56 +0000 (14:50 +0900)]
Fix possible null pointer dereference per Coverity.

3 years agoRevert "Prevent hang in terminate_all_childrens()."
Tatsuo Ishii [Mon, 4 Apr 2022 07:26:30 +0000 (16:26 +0900)]
Revert "Prevent hang in terminate_all_childrens()."

This reverts commit e1b9b17a7a94356fb1fc9d0f7182b1d347ca4584.

3 years agoPrevent hang in terminate_all_childrens().
Tatsuo Ishii [Fri, 1 Apr 2022 12:13:12 +0000 (21:13 +0900)]
Prevent hang in terminate_all_childrens().

waitpid() was used in the function without WNOHANG was being set.
This could cause hang in waitpic().  Also fix typo. Rename
terminate_all_childrens to terminate_all_children.

3 years agoEnhance error message while processing parse message.
Tatsuo Ishii [Sat, 12 Mar 2022 04:33:42 +0000 (13:33 +0900)]
Enhance error message while processing parse message.

In non-streaming replication mode, a sync message is sent to backend
after a parse message is sent to backend, expecting to get a ready for
query message.  If different message is returned, pgpool will complain
that. This commit adds more information: the message kind returned and
the backend node id.

3 years agoDowngrade log level of ParameterStatus message.
Tatsuo Ishii [Fri, 11 Mar 2022 01:38:08 +0000 (10:38 +0900)]
Downgrade log level of ParameterStatus message.

In commit 4bcba5258130c3cd9f855157a4359aad2fa7acfc the log level when
ParameterStatus message arrives from backend was changed from DEBUG5
to LOG. There are multiple complains about the change because chances
of the event is more frequent than I thought. So revert back the log
level to DEBUG5.

Discussion: https://www.pgpool.net/pipermail/pgpool-general/2022-March/008101.html

3 years agoFix main process exiting while performing finding primary node.
Tatsuo Ishii [Fri, 4 Mar 2022 11:00:41 +0000 (20:00 +0900)]
Fix main process exiting while performing finding primary node.

Pgpool-II main process tries to find primary node whenever the cluster
status is changed by failover/failback. While doing it, if a backend
is failing or shutting down, socket write to the backend could
fail. Unfortunately in the case do_query() throws FATAL error, which
makes the Pgpool-II main process die like this.

2022-03-04 18:13:12.711: main pid 795826: WARNING:  write on backend 1 failed with error :"Broken pipe"
2022-03-04 18:13:12.711: main pid 795826: DETAIL:  while trying to write data from offset: 0 wlen: 32
2022-03-04 18:13:12.711: main pid 795826: LOG:  notice_backend_error: called from pgpool main. ignored.
2022-03-04 18:13:12.711: main pid 795826: LOG:  unable to flush data to backend
2022-03-04 18:13:12.711: main pid 795826: DETAIL:  do not failover because I am the main process
2022-03-04 18:13:12.711: main pid 795826: FATAL:  Backend throw an error message
2022-03-04 18:13:12.711: main pid 795826: DETAIL:  Exiting current session because of an error from backend
2022-03-04 18:13:12.711: main pid 795826: HINT:  BACKEND Error: "terminating connection due to administrator command"
2022-03-04 18:13:12.715: main pid 795826: LOG:  shutting down

To prevent it, change ereport(FATAL) to ereport(ERROR) in do_query().

3 years agoFix: [pgpool-general: 8030] ... segfaults on CentOS 8
Muhammad Usama [Thu, 3 Mar 2022 10:03:40 +0000 (15:03 +0500)]
Fix: [pgpool-general: 8030] ... segfaults on CentOS 8

Event names array used by debug messages had a missing
entry for WD_EVENT_I_AM_APPEARING_FOUND

3 years agoChange the default value of pcp_listen_addresses from '*' to 'localhost'.
Tatsuo Ishii [Mon, 28 Feb 2022 07:30:58 +0000 (16:30 +0900)]
Change the default value of pcp_listen_addresses from '*' to 'localhost'.

Sync with compiled default.

3 years agoChange the default value of pcp_listen_addresses from '*' to 'localhost'.
Tatsuo Ishii [Mon, 28 Feb 2022 06:52:11 +0000 (15:52 +0900)]
Change the default value of pcp_listen_addresses from '*' to 'localhost'.

'*' was not very secure. Also the default value of listen_address in
Pgpool-II and PostgreSQL are 'localhost'.

3 years agoDoc: update copyright year.
Bo Peng [Sun, 27 Feb 2022 03:36:16 +0000 (12:36 +0900)]
Doc: update copyright year.

3 years agoAdjusting the field name in pcp_watchdog_info.
Muhammad Usama [Tue, 1 Feb 2022 13:57:13 +0000 (18:57 +0500)]
Adjusting the field name in pcp_watchdog_info.

Details in: https://www.pgpool.net/pipermail/pgpool-hackers/2021-December/004070.html

3 years agoPrepare 3.7.23 V3_7_23 V3_7_23_RPM
Masaya Kawamoto [Thu, 17 Feb 2022 01:32:09 +0000 (01:32 +0000)]
Prepare 3.7.23

3 years agoAdd release notes.
Masaya Kawamoto [Thu, 17 Feb 2022 01:21:50 +0000 (01:21 +0000)]
Add release notes.

3 years agoMerge branch 'V3_7_STABLE' of ssh://git.postgresql.org/pgpool2 into V3_7_STABLE
Tatsuo Ishii [Sun, 13 Feb 2022 04:27:56 +0000 (13:27 +0900)]
Merge branch 'V3_7_STABLE' of ssh://git.postgresql.org/pgpool2 into V3_7_STABLE

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:36:50 +0000 (11:36 +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:57:14 +0000 (19:57 +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: fix release notes.
Masaya Kawamoto [Thu, 23 Dec 2021 07:17:23 +0000 (07:17 +0000)]
Doc: fix release notes.

3 years agoPrepare 3.7.22 V3_7_22 V3_7_22_RPM
Masaya Kawamoto [Wed, 22 Dec 2021 09:11:34 +0000 (09:11 +0000)]
Prepare 3.7.22

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

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 agoFix release note version. V3_7_21 V3_7_21_RPM
Masaya Kawamoto [Thu, 18 Nov 2021 02:53:57 +0000 (02:53 +0000)]
Fix release note version.

3 years agoPrepare 3.7.21
Masaya Kawamoto [Thu, 18 Nov 2021 02:49:29 +0000 (02:49 +0000)]
Prepare 3.7.21

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

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 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 agoFix documentation typos.
Bo Peng [Mon, 4 Oct 2021 11:29:38 +0000 (20:29 +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:09:48 +0000 (21:09 +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:39:25 +0000 (01:39 +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 agoFix pcp_unix_domain_path.patch error. V3_7_20 V3_7_20_RPM
Masaya Kawamoto [Wed, 4 Aug 2021 02:29:42 +0000 (02:29 +0000)]
Fix pcp_unix_domain_path.patch error.

4 years agoPrepare 3.7.20
Masaya Kawamoto [Tue, 3 Aug 2021 02:42:12 +0000 (02:42 +0000)]
Prepare 3.7.20

4 years agoAdd release notes.
Masaya Kawamoto [Tue, 3 Aug 2021 02:15:44 +0000 (02:15 +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 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 indent.
Bo Peng [Tue, 22 Jun 2021 02:10:28 +0000 (11:10 +0900)]
Fix indent.

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 agoPrepare 3.7.19. V3_7_19 V3_7_19_RPM
Bo Peng [Wed, 19 May 2021 13:11:46 +0000 (22:11 +0900)]
Prepare 3.7.19.

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 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 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 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 agoRevert "Fix regression test 074."
Tatsuo Ishii [Wed, 14 Apr 2021 09:42:09 +0000 (18:42 +0900)]
Revert "Fix regression test 074."

This reverts commit 4c6d044b912e4a5bf459fda9b6154921fc67f59c.

Revert "Add new regression test 074.bug700_memqcache_bug_segfault_at_close_complete which was missed in the previous commit."

This reverts commit 2ad3b9286d9e7f0c9fae3f86b92a26a0f16b880e.

Since V3_7_STABLE does not have pgproto, test 074 which uses pgproto
should not be added.