pgpool2.git
3 years agoTest: stabilize 018.detach_primary.
Tatsuo Ishii [Sun, 17 Apr 2022 12:48:51 +0000 (21:48 +0900)]
Test: stabilize 018.detach_primary.

The test occasionally failed with timeout. The cause seems the test
proceeds before watchdog are ready.  So wait till watchdog is ready
using pcp_watchdog_info.

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 agoTest: enhance 074.bug700_memqcache_segfault
Tatsuo Ishii [Sun, 17 Apr 2022 04:52:14 +0000 (13:52 +0900)]
Test: enhance 074.bug700_memqcache_segfault

Set statement_timeout at the beginning of the test to avoid the time
out error because it takes long time before failure.

3 years agoFix exit_handler in pgpool main process.
Tatsuo Ishii [Thu, 14 Apr 2022 11:01:56 +0000 (20:01 +0900)]
Fix exit_handler in pgpool main process.

It was allowed to be interrupted by signals (SIGTERM, SIGINT and
SOGQUIT) while the exit_handler. As a resit, exit_handler is executed
while executing exit_handler. This could cause infinite wait in
terminate_childrens() which is called from exit_handler.  To prevent
this, protect variable "exiting" using semaphore to make sure that
only one instance of exit_handler runs at the same time.

Discussion: https://www.pgpool.net/pipermail/pgpool-hackers/2022-April/004149.html

3 years agoFix memory leak pointed out by Coverity.
Masaya Kawamoto [Mon, 11 Apr 2022 07:30:54 +0000 (07:30 +0000)]
Fix memory leak pointed out by Coverity.

3 years agoFix shared memory allocation function.
Tatsuo Ishii [Wed, 6 Apr 2022 07:30:35 +0000 (16:30 +0900)]
Fix shared memory allocation function.

pool_shared_memory_segment_get_chunk() which is responsible for shared
memory allocation, failed to consider request size alignment. If
requeste size is not in MAXALIGN (typically 8) bytes, it could overrun
the shared memory area. Probably harmless in the wild but better to
fix.

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:24:58 +0000 (16:24 +0900)]
Revert "Prevent hang in terminate_all_childrens()."

This reverts commit 33e0ff2d1628d5a382ffbc4378074b4d5a5c5ac4.

3 years agoPrevent hang in terminate_all_childrens().
Tatsuo Ishii [Fri, 1 Apr 2022 11:02:54 +0000 (20:02 +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 agoFix bug with pg_enc and pg_md5.
Tatsuo Ishii [Fri, 18 Mar 2022 11:52:07 +0000 (20:52 +0900)]
Fix bug with pg_enc and pg_md5.

When these commands are invoked with "-i" option (read username/password
pairs from a file), it did not create proper entries in pool_passwd.
This bug was introduced by the commit:
https://git.postgresql.org/gitweb/?p=pgpool2.git;a=commit;h=441bde41767fe3bccad513735f946dd2dec5059b

Bug reported in https://www.pgpool.net/mantisbt/view.php?id=747

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:24:38 +0000 (16:24 +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 agoFixed follow_primary.sh.sample script to check the status of PostgreSQL using pg_isready.
Bo Peng [Fri, 25 Feb 2022 05:29:02 +0000 (14:29 +0900)]
Fixed follow_primary.sh.sample script to check the status of PostgreSQL using pg_isready.

3 years agoAdd patch to enable parameters related to logging_collector.
Bo Peng [Tue, 22 Feb 2022 04:38:51 +0000 (13:38 +0900)]
Add patch to enable parameters related to logging_collector.

3 years agoPrepare 4.2.8 V4_2_8 V4_2_8_RPM
Masaya Kawamoto [Thu, 17 Feb 2022 01:39:03 +0000 (01:39 +0000)]
Prepare 4.2.8

3 years agoAdd release notes.
Masaya Kawamoto [Thu, 17 Feb 2022 00:26:47 +0000 (00:26 +0000)]
Add release notes.

3 years agoEnhance parameter status handling.
Tatsuo Ishii [Mon, 31 Jan 2022 08:11:02 +0000 (17:11 +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 agoAdd validations of wd_lifecheck_password and recovery_password format
Masaya Kawamoto [Thu, 10 Feb 2022 01:50:44 +0000 (01:50 +0000)]
Add validations of wd_lifecheck_password and recovery_password format

This feature was reverted once due to regression
test failure by e5989302d7a1c007d88a7b24bc86877c39c50d62.

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

The static declaration of fork_follow_child() was missing. Also fix
typo in a comment.

3 years agoFixed mistakes introduced in the previous commit.
Bo Peng [Mon, 7 Feb 2022 03:19:01 +0000 (12:19 +0900)]
Fixed mistakes introduced in the previous commit.

3 years agoFixed sample failover script.
Bo Peng [Mon, 7 Feb 2022 03:06:45 +0000 (12:06 +0900)]
Fixed sample failover script.

This script did not consider the case when the old primary node id is "-1".

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:55:18 +0000 (19:55 +0900)]
Update Makefile.in

3 years agoFix regression test 075.
Tatsuo Ishii [Wed, 12 Jan 2022 10:42:01 +0000 (19:42 +0900)]
Fix regression test 075.

The test reported success even if pgpool does not start up.
Problem reported and patch provided by Qiang Lingjie.
Discussion: https://www.pgpool.net/pipermail/pgpool-hackers/2022-January/004086.html

3 years agoFix compiler warning.
Tatsuo Ishii [Sat, 8 Jan 2022 03:59:49 +0000 (12:59 +0900)]
Fix compiler warning.

In the commit "Suppress message length log for in_hot_standby." I
forgot to push a modification to
src/include/protocol/pool_proto_modules.h which caused a compiler
warning.

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 [Wed, 5 Jan 2022 04:50:59 +0000 (13:50 +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:29:24 +0000 (07:29 +0000)]
Doc: fix release notes.

3 years agoPrepare 4.2.7 V4_2_7 V4_2_7_RPM
Masaya Kawamoto [Wed, 22 Dec 2021 09:04:49 +0000 (09:04 +0000)]
Prepare 4.2.7

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

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

This reverts commit e9cd3c230a7f4cce5879da5565eca16e2cd049ea.

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:26:45 +0000 (04:26 +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 agoDoc: fix typos
Bo Peng [Mon, 6 Dec 2021 12:00:24 +0000 (21:00 +0900)]
Doc: fix typos

Patch is created by Lu Chenyang.

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 agoDoc: fix release note typo V4_2_6 V4_2_6_RPM
Masaya Kawamoto [Thu, 18 Nov 2021 03:23:36 +0000 (03:23 +0000)]
Doc: fix release note typo

3 years agoPrepare 4.2.6
Masaya Kawamoto [Thu, 18 Nov 2021 03:07:58 +0000 (03:07 +0000)]
Prepare 4.2.6

3 years agoFix doc version.
Masaya Kawamoto [Thu, 18 Nov 2021 03:05:45 +0000 (03:05 +0000)]
Fix doc version.

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

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 agoFix application_name array lacking an entry for logger process.
Tatsuo Ishii [Mon, 25 Oct 2021 00:40:36 +0000 (09:40 +0900)]
Fix application_name array lacking an entry for logger process.

Add logger process entry to the process name array. This was missed
since the logger process was added.
Per coverity.

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 connection counter issue when reserved_connections is 0.
Tatsuo Ishii [Sun, 24 Oct 2021 02:30:25 +0000 (11:30 +0900)]
Fix connection counter issue when reserved_connections is 0.

If reserved_connections is 0, we don't need to manage the connection
counter to check if the count is larger than
(pool_config->num_init_children - pool_config->reserved_connections).
So remove the check.  This will prevent unwanted "Sorry, too many
clients already" error" by accidental counter leak.

For reserved_connections > 0 case, we need to fix the counter leak but
it's another story.

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 documentation typos.
Bo Peng [Wed, 6 Oct 2021 01:30:24 +0000 (10:30 +0900)]
Doc: fix documentation typos.

3 years agoFix typos in documentation and sample scripts.
Bo Peng [Mon, 4 Oct 2021 10:56:49 +0000 (19:56 +0900)]
Fix typos in documentation and sample scripts.

Patch is created by Kazufumi Noto.

3 years agoDoc: fix yum install command typo in configuration example.
Bo Peng [Wed, 29 Sep 2021 14:47:17 +0000 (23:47 +0900)]
Doc: fix yum install command typo in configuration example.

4 years agoFix for bug-732: Segmentation fault at failover ...
Muhammad Usama [Mon, 27 Sep 2021 17:07:48 +0000 (22:07 +0500)]
Fix for bug-732: Segmentation fault at failover ...

trigger_failover_command() had an assumption that old primary can never be NULL,
which of course is not the case.

4 years agoFix pg_config command path to avoid test failure.
Bo Peng [Thu, 23 Sep 2021 12:54:00 +0000 (21:54 +0900)]
Fix pg_config command path to avoid test failure.

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 06:44:51 +0000 (15:44 +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 agoDoc: fix incorrect file name in "Pgpool-II on Kubernetes". V4_2_5 V4_2_5_RPM
Bo Peng [Mon, 13 Sep 2021 08:12:56 +0000 (17:12 +0900)]
Doc: fix incorrect file name in "Pgpool-II on Kubernetes".

4 years agoPrepare 4.2.5
Bo Peng [Mon, 13 Sep 2021 07:45:23 +0000 (16:45 +0900)]
Prepare 4.2.5

4 years agoDoc: add release notes for Pgpool-II 4.2.5.
Bo Peng [Mon, 13 Sep 2021 05:57:59 +0000 (14:57 +0900)]
Doc: add release notes for Pgpool-II 4.2.5.

4 years agoFix for bug-731: Fails to execute follow_primary_command..
Muhammad Usama [Fri, 10 Sep 2021 10:49:46 +0000 (15:49 +0500)]
Fix for bug-731: Fails to execute follow_primary_command..

It was a segmentation fault happening because of a silly coding mistake in
parse_wd_exec_cluster_command_json() function.
The problem was the WDExecCommandArg** arg for returning the argument list
was not getting populated properly.
As part of the fix, to get rid of complexity and confusion, I have changed
the function signature to accept List* type argument for returning the
parsed command args instead of an array and its length.

Thanks to Bo Peng, Emond Papegaaij and Tatsuo Ishi for reviewing
and testing the fix

4 years agoDoc: fixed "PGPOOL SHOW" documentaion that was missing in the previous commit 151e8f5...
Bo Peng [Mon, 6 Sep 2021 08:45:07 +0000 (17:45 +0900)]
Doc: fixed "PGPOOL SHOW" documentaion that was missing in the previous commit 151e8f54961b1a0394cfc86c2f4ddf715b41ceea.

4 years agoFix incorrect PGPOOL SHOW option.
Bo Peng [Fri, 3 Sep 2021 05:16:01 +0000 (14:16 +0900)]
Fix incorrect PGPOOL SHOW option.

Since 4.2 other_pgpool is removed, "PGPOOL SHOW other_pgpool" command should be changed to "PGPOOL SHOW watchdog".

4 years agoFix bug of "PGPOOL SHOW heartbeat" and "PGPOOL SHOW ALL" command.
Bo Peng [Fri, 3 Sep 2021 04:58:46 +0000 (13:58 +0900)]
Fix bug of "PGPOOL SHOW heartbeat" and "PGPOOL SHOW ALL" command.

The last member in heartbeat_* array was not displayed in the command result.

4 years agoFix to allow log_rotation_age to be set to 0.
Tatsuo Ishii [Thu, 2 Sep 2021 00:07:15 +0000 (09:07 +0900)]
Fix to allow log_rotation_age to be set to 0.

According to the docs, it is possible to set 0 to log_rotation_age so
that the log rotation feature is disabled. But the allowed minimum
value for it was mistakenly set to 10, which made it impossible to set
log_rotation_age to 0.

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 agoFix pgpool logger process eats 100% cpu.
Tatsuo Ishii [Thu, 12 Aug 2021 07:37:26 +0000 (16:37 +0900)]
Fix pgpool logger process eats 100% cpu.

The select(2) loop in the logger process did not initialize
timeout.tv_usec, which could cause error in select(2) because of too
big tv_usec. In this select(2) immediately returned and iterate the
for loop.

Problem reported and patch provided by Fang Jun.
Discussion: https://www.pgpool.net/pipermail/pgpool-hackers/2021-August/003993.html

4 years agoFix typo in SI related functions.
Tatsuo Ishii [Wed, 11 Aug 2021 00:16:34 +0000 (09:16 +0900)]
Fix typo in SI related functions.

The typo pattern was "aquire" (wrong), which should have been "acquire".
This fix has been already applied to master branch.

4 years agoFix compiler warning.
Tatsuo Ishii [Wed, 11 Aug 2021 00:07:58 +0000 (09:07 +0900)]
Fix compiler warning.

4 years agoUpdate Makefile.in and configure.
Bo Peng [Tue, 10 Aug 2021 12:04:43 +0000 (21:04 +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 agoUpdate configure and src/config/pool_config.c due to the previous commit.
Bo Peng [Tue, 10 Aug 2021 07:54:04 +0000 (16:54 +0900)]
Update configure and src/config/pool_config.c due to the previous commit.

4 years agoFix compiler warnings generated by newer version of gcc.
Tatsuo Ishii [Tue, 10 Aug 2021 07:12:55 +0000 (16:12 +0900)]
Fix compiler warnings generated by newer version of gcc.

gcc on Ubuntu 20 (9.3.0) generates tons of compiler warnings something like:

In file included from /usr/include/string.h:495,
>                  from pg_md5.c:31:
> In function 。strncpy「,
>     inlined from 。update_pool_passwd_from_file「 at pg_md5.c:276:3,
>     inlined from 。main「 at pg_md5.c:136:3:
> /usr/include/x86_64-linux-gnu/bits/string_fortified.h:106:10: warning: 。__builtin___strncpy_chk「 output may be truncated copying between 0 and 128 bytes from a string of length 257 [-Wstringop-truncation]
>   106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
>       |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>

I have found a message in PostgreSQL hackers mailing list regarding similar issue:
https://www.postgresql.org/message-id/flat/21789.1529170195%40sss.pgh.pa.us#525c384d13505fa6f1f25c50b00d7a08

To fix these warnings:

1) fix misuse of strncpy() and friends

2) add -Wno-stringop-truncation to CLFAG

This commit implelents #1 and #2.

Discussion: https://www.pgpool.net/pipermail/pgpool-hackers/2021-August/003990.html

4 years agoFix SI mode to acquire a snapshot with an internal transaction.
Tatsuo Ishii [Tue, 10 Aug 2021 04:59:32 +0000 (13:59 +0900)]
Fix SI mode to acquire a snapshot with an internal transaction.

In SI mode a data modifying statement needs to start internal
transaction.  However it forgot to acquire a snapshot. This commit
fixes that in both simple query protocol and extended query protocol.

4 years agoDoc: fix typo in Japanese release note.
Masaya Kawamoto [Tue, 10 Aug 2021 01:31:40 +0000 (01:31 +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.2.4 V4_2_4 V4_2_4_RPM
Masaya Kawamoto [Tue, 3 Aug 2021 02:31:28 +0000 (02:31 +0000)]
Prepare 4.2.4

4 years agoFix: typo in release note.
Masaya Kawamoto [Tue, 3 Aug 2021 02:07:50 +0000 (02:07 +0000)]
Fix: typo in release note.

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

4 years agoDoc: Update configuration example "Pgpool-II on Kubernetes".
Bo Peng [Mon, 2 Aug 2021 16:58:31 +0000 (01:58 +0900)]
Doc: Update configuration example "Pgpool-II on Kubernetes".

4 years agoDoc: add more explanation about backend_application_name.
Tatsuo Ishii [Tue, 20 Jul 2021 07:01:08 +0000 (16:01 +0900)]
Doc: add more explanation about backend_application_name.

4 years agoFix: Typo in a function name
Muhammad Usama [Fri, 16 Jul 2021 10:43:12 +0000 (15:43 +0500)]
Fix: Typo in a function name

4 years agoImplementing the follow_primary command-locking over the watchdog channel.
Muhammad Usama [Fri, 16 Jul 2021 07:17:27 +0000 (12:17 +0500)]
Implementing the follow_primary command-locking over the watchdog channel.

Supplementary fix for [pgpool-hackers: 3892] Problem with detach_false_primary..

commit:455f00dd5f5b7b94bd91aa0b6b40aab21dceabb9 fixed a race condition between
detach_false_primary and follow_primary commands. Part of the fix was to make
sure that the detach_false_primary should only be executed on the
leader watchdog node.

The mentioned commit ensures the execution of detach_false_primary on the
watchdog leader by getting the watchdog status from within the main process.
The design is good enough for most cases, but has the potential to fail if
the cluster goes into the election process just after the main process
has read the status.

To fix that, this commit implements the synchronization of follow_primary_command
execution using the distributed locks over the watchdog channel.

The idea is, just before executing the follow_primary during the failover process
we instruct all standby watchdog nodes to acquire a lock on their respective
nodes to block the false primary detection during the period when the
follow_primary is being executed on the leader watchdog node.

Moreover to keep the watchdog process blocked on waiting for the lock the commit
introduced the pending remote lock mechanism, so that remote locks can get
acquired in the background after the completion of the inflight replication checks.

Finally, REQ_DETAIL_CONFIRMED flag is removed from degenerate_backend_set()
request that gets issued to detach the false primary, That means all quorum
and consensus rules must be satisfied for the detach to happen.