pgpool2.git
6 years agoFix typo in fork_watchdog_child().
Tatsuo Ishii [Tue, 10 Sep 2019 06:42:10 +0000 (15:42 +0900)]
Fix typo in fork_watchdog_child().

6 years agoAdd more debug info out.
Tatsuo Ishii [Mon, 9 Sep 2019 08:17:58 +0000 (17:17 +0900)]
Add more debug info out.

6 years agoDoc: clarify that certificate authentication works between only client and Pgpool-II.
Tatsuo Ishii [Mon, 9 Sep 2019 02:37:24 +0000 (11:37 +0900)]
Doc: clarify that certificate authentication works between only client and Pgpool-II.

Per complaint from: https://www.pgpool.net/pipermail/pgpool-general-jp/2019-September/001611.html

6 years agoAdd start message of PCP process.
Tatsuo Ishii [Fri, 6 Sep 2019 08:22:52 +0000 (17:22 +0900)]
Add start message of PCP process.

6 years agoFix memory leak.
Tatsuo Ishii [Fri, 6 Sep 2019 07:31:07 +0000 (16:31 +0900)]
Fix memory leak.

Per Coverity.

6 years agoFix failure of statement_level_load_balance extra test.
Tatsuo Ishii [Fri, 6 Sep 2019 07:02:40 +0000 (16:02 +0900)]
Fix failure of statement_level_load_balance extra test.

Now pgpool issues SELECT version() internaly, the count of SELECT
queries needed to be adjusted.

6 years agoFix memory leak.
Tatsuo Ishii [Fri, 6 Sep 2019 06:54:39 +0000 (15:54 +0900)]
Fix memory leak.

Per Coverity.

6 years agoFix uninitialized variable.
Tatsuo Ishii [Fri, 6 Sep 2019 06:24:09 +0000 (15:24 +0900)]
Fix uninitialized variable.

Probably harmless but bug is bug...
Per Coverity.

6 years agoUpdate Makefile to include pgpool_adm--1.2.sql and pgpool_adm--1.1--1.2.sql.
Bo Peng [Fri, 6 Sep 2019 01:58:58 +0000 (10:58 +0900)]
Update Makefile to include pgpool_adm--1.2.sql and pgpool_adm--1.1--1.2.sql.

6 years agoChange regression test file name.
Bo Peng [Fri, 6 Sep 2019 00:55:48 +0000 (09:55 +0900)]
Change regression test file name.

6 years agoDoc: mention that auto re-attaching quarantined node is available in v4.1 or later.
Tatsuo Ishii [Thu, 5 Sep 2019 23:21:28 +0000 (08:21 +0900)]
Doc: mention that auto re-attaching quarantined node is available in v4.1 or later.

6 years agoDoc: make "quarantine" to be indexed.
Tatsuo Ishii [Thu, 5 Sep 2019 22:45:34 +0000 (07:45 +0900)]
Doc: make "quarantine" to be indexed.

It should have been indexed because the term is important for failover
behavior.

6 years agoFix outfuncs.c to support PostgreSQL 12 CTE [NOT] MATERIALIZED.
Bo Peng [Thu, 5 Sep 2019 12:00:46 +0000 (21:00 +0900)]
Fix outfuncs.c to support PostgreSQL 12 CTE [NOT] MATERIALIZED.

6 years agoDoc: add patch author name to check_temp_table.
Tatsuo Ishii [Thu, 5 Sep 2019 11:46:10 +0000 (20:46 +0900)]
Doc: add patch author name to check_temp_table.

6 years agoUpdate SPEC file.
Bo Peng [Thu, 5 Sep 2019 07:46:33 +0000 (16:46 +0900)]
Update SPEC file.

6 years agoEnable master branch AM_MAINTAINER_MODE.
Bo Peng [Thu, 5 Sep 2019 07:38:18 +0000 (16:38 +0900)]
Enable master branch AM_MAINTAINER_MODE.

6 years agoDisable AM_MAINTAINER_MODE.
Bo Peng [Thu, 5 Sep 2019 07:33:34 +0000 (16:33 +0900)]
Disable AM_MAINTAINER_MODE.

6 years agoDoc: update example documentation.
Bo Peng [Thu, 5 Sep 2019 06:44:46 +0000 (15:44 +0900)]
Doc: update example documentation.

6 years agoAllow failover.sh.sample, follow_master.sh.sample, recovery_1st_stage.sample, recover...
Bo Peng [Thu, 5 Sep 2019 06:28:49 +0000 (15:28 +0900)]
Allow failover.sh.sample, follow_sh.sample, recovery_1st_stage.sample, recovery_2nd_stage.sample,
pgpool_remote_start.sample sample scripts to be included in distributions.

6 years agoAllow failover.sh, follow_master.sh, recovery_1st_stage, recovery_2nd_stage,
Bo Peng [Thu, 5 Sep 2019 06:26:51 +0000 (15:26 +0900)]
Allow failover.sh, follow_sh, recovery_1st_stage, recovery_2nd_stage,
pgpool_remote_start scripts to be included in distributions.

6 years agoFix regression test 028.watchdog_enable_consensus_with_half_of_the_votes to not fail.
Tatsuo Ishii [Thu, 5 Sep 2019 04:40:02 +0000 (13:40 +0900)]
Fix regression test 028.watchdog_enable_consensus_with_half_of_the_votes to not fail.

It seems pcp_watchdog_info fails because:
ERROR: connection to socket "/tmp/.s.PGSQL.50001" failed with error "No such file or directory"

Fix could be trying to wait for pcp_watchdog_info available. See if this fixes the issue.

6 years agoDoc: add a missing release item in Japanese release 4.1 note.
Tatsuo Ishii [Thu, 5 Sep 2019 03:58:19 +0000 (12:58 +0900)]
Doc: add a missing release item in Japanese release 4.1 note.

Also tweak SGML tag in English 4.1 release note.

6 years agoAdd various sample scripts:
Bo Peng [Wed, 4 Sep 2019 08:37:06 +0000 (17:37 +0900)]
Add various sample scripts:
- failover.sh
- follow_master.sh
- recovery_1st_stage
- recovery_2nd_stage
- pgpool_remote_start

6 years agoDoc: Update 4.1 release-note.
Bo Peng [Wed, 4 Sep 2019 08:35:20 +0000 (17:35 +0900)]
Doc: Update 4.1 release-note.

6 years agoAllow to specify absolute path in "pool_passwd".
Bo Peng [Wed, 4 Sep 2019 08:04:01 +0000 (17:04 +0900)]
Allow to specify absolute path in "pool_passwd".

Patch is provided by Danylo Hlynskyi.

6 years agoDoc: add release note entry for enable_consensus_with_half_votes.
Tatsuo Ishii [Wed, 4 Sep 2019 05:53:07 +0000 (14:53 +0900)]
Doc: add release note entry for enable_consensus_with_half_votes.

Also add description of enable_consensus_with_half_votes to Japanese
watchdog doc.

6 years agoDoc: mention that VIP will not be brougt up if quorum does not exist.
Tatsuo Ishii [Tue, 3 Sep 2019 22:45:17 +0000 (07:45 +0900)]
Doc: mention that VIP will not be brougt up if quorum does not exist.

6 years agoFix 028.watchdog_enable_consensus_with_half_of_the_votes test failed.
Tatsuo Ishii [Tue, 3 Sep 2019 04:14:47 +0000 (13:14 +0900)]
Fix 028.watchdog_enable_consensus_with_half_of_the_votes test failed.

Path to pcp_watchdog_info used in the test script was not set.
Also set the path to pcp.conf.

6 years agoAdd regression test for enable_consensus_with_half_votes.
Tatsuo Ishii [Sun, 1 Sep 2019 03:20:33 +0000 (12:20 +0900)]
Add regression test for enable_consensus_with_half_votes.

This is a test for 2, 3, 4 watchdog nodes, with
enable_consensus_with_half_votes is on/off cases.  In each test, half
of watchdog nodes are shut down and check to see if quorum exists (or
on the edge for even number nodes).

6 years agoFix pgpool_setup to reflect the -p (baseport) to ORIGBASEPORT variable.
Tatsuo Ishii [Sun, 1 Sep 2019 02:38:35 +0000 (11:38 +0900)]
Fix pgpool_setup to reflect the -p (baseport) to ORIGBASEPORT variable.

Otherwise, shutdown generated script by pgpool_setup does not use
proper port number for netstat command.

6 years ago Add parameter enable_consensus_with_half_votes to configure majority rule calculations
Muhammad Usama [Thu, 29 Aug 2019 15:34:13 +0000 (20:34 +0500)]
 Add parameter enable_consensus_with_half_votes to configure majority rule calculations

 Pgpool-II takes the decision of quorum existence and failover consensus after
 receiving the exact 50% of votes when the watchdog cluster is configured with
 an even number of nodes. With enable_consensus_with_half_votes parameter,
 users can tell Pgpool-II, whether the distributed consensus in an even number
 of nodes cluster requires (n/2) or ((n/2) +1) votes to decide the majority.

 The patch is drafted by "Tatsuo Ishii <ishii@sraoss.co.jp>" and I have made
 few modifications on top of that.

6 years agoFix pgpool_setup to deal with PostgreSQL 9.1.
Tatsuo Ishii [Wed, 28 Aug 2019 05:48:11 +0000 (14:48 +0900)]
Fix pgpool_setup to deal with PostgreSQL 9.1.

"---data-checksums" was unconditionally added to initdb's arg but
PostgreSQL 9.1's initdb does not have the option. To solve the issue,
internal variable $PGVERSION now represents "major version" * 100:
e.g. 120 for PostgreSQL 12.x (including 12beta), 91 for PostgreSQL
9.1.x, so that pgpool_setup can check if the option can be added to
initdb options.

6 years agoDoc: fix indentation in scripts.
Tatsuo Ishii [Sun, 25 Aug 2019 01:54:33 +0000 (10:54 +0900)]
Doc: fix indentation in scripts.

Auto indentation by commit 2cb0bd3f8f236aeacfba37cd4d604893561bad52
broke indentation of scripts in <programlisting> tag.

6 years agoDoc: fix typo in "What is Pgpool-II?" section.
Tatsuo Ishii [Sun, 25 Aug 2019 01:15:37 +0000 (10:15 +0900)]
Doc: fix typo in "What is Pgpool-II?" section.

Author: Alejandro Roman
Discussion: https://www.pgpool.net/pipermail/pgpool-hackers/2019-August/003392.html

6 years agoDoc: Add Pgpool-II 4.1 japanese release note.
Takuma Hoshiai [Mon, 19 Aug 2019 09:58:02 +0000 (18:58 +0900)]
Doc: Add Pgpool-II 4.1 japanese release note.

6 years agoFix for password authentication does not work in certain cases
Muhammad Usama [Sun, 18 Aug 2019 11:29:39 +0000 (16:29 +0500)]
Fix for password authentication does not work in certain cases

Pgpool-II was only trying to get the password from the pool_passwd file when
backends were configured to use password authentication.  And when the password
is not present in the pool_passwd file it was failing without trying to get the
password from the user even when clear text authentication was allowed on
frontend connections.

The fix is to use clear text password authentication with frontend to get the
user password (If it is allowed by the configuration) when the password for the
connecting user is not found in the pool_passwd file.

The issue was reported by "Tatsuo Ishii<ishii@sraoss.co.jp>"

6 years agoDoc: mention about relcache_query_target in the performance chapter.
Tatsuo Ishii [Fri, 16 Aug 2019 07:07:03 +0000 (16:07 +0900)]
Doc: mention about relcache_query_target in the performance chapter.

6 years agoUpdate copyright year.
Tatsuo Ishii [Fri, 16 Aug 2019 06:17:43 +0000 (15:17 +0900)]
Update copyright year.

6 years agoFix watchdog_setup to not accept number of Pgpool-II being lower than 1.
Tatsuo Ishii [Thu, 15 Aug 2019 07:50:17 +0000 (16:50 +0900)]
Fix watchdog_setup to not accept number of Pgpool-II being lower than 1.

Pgpool-II won't start up if other watchdog is not present.

6 years agoAdd "-I" option to "arping_cmd" command default setting.
Bo Peng [Fri, 16 Aug 2019 02:51:36 +0000 (11:51 +0900)]
Add "-I" option to "arping_cmd" command default setting.

6 years agoDoc: add 4.0.6-3.4.25 release-note.
Bo Peng [Fri, 16 Aug 2019 00:11:40 +0000 (09:11 +0900)]
Doc: add 4.0.6-3.4.25 release-note.

6 years agoFix temp table trace modules.
Tatsuo Ishii [Thu, 15 Aug 2019 00:32:17 +0000 (09:32 +0900)]
Fix temp table trace modules.

CLOBBER_FREED_MEMORY revealed bug with usage of list package.

6 years agoDoc: fix tag mistake in sr_check_user note.
Tatsuo Ishii [Wed, 14 Aug 2019 02:45:54 +0000 (11:45 +0900)]
Doc: fix tag mistake in sr_check_user note.

6 years agoFix memory leak.
Tatsuo Ishii [Wed, 14 Aug 2019 00:14:36 +0000 (09:14 +0900)]
Fix memory leak.

Pointed out by Coverity.

6 years agoFix test failure of extended-query-test/disable-load-balance-while-function.data.
Tatsuo Ishii [Tue, 13 Aug 2019 00:42:34 +0000 (09:42 +0900)]
Fix test failure of extended-query-test/disable-load-balance-while-function.data.

The test failed because CREATE function propagation to standby took a while.
To fix this, add "SELECT pg_sleep(5)" to wait for standby synced with primary.
Also expected file is updated to reflect this.
2) CREATE function propagation to standby took a while

6 years agoFix extra test failure of extended-query-test/disable-load-balance-off.
Tatsuo Ishii [Sun, 11 Aug 2019 10:19:02 +0000 (19:19 +0900)]
Fix extra test failure of extended-query-test/disable-load-balance-off.

There were two reasons why the test fails.

1) when disable_load_balance_on_write = off, parse_before_bind should
   have not be called at all. So fix this.

2) the test data tests/disable-load-balance-off.data did not set
disable_load_balance_on_write = off.

6 years agoFix extra test failure of extended-query-test/disable-load-balance-default.
Tatsuo Ishii [Sun, 11 Aug 2019 09:58:51 +0000 (18:58 +0900)]
Fix extra test failure of extended-query-test/disable-load-balance-default.

It expected the first BIND/EXECUTE was sent to load balance node. This
is not correct since previous parse message was sent to primary node
because of parse_before_bind treatment. Fix is, just adjust the test
script. Also fix comment in tests/disable-load-balance-default.data.

6 years agoFix test failure of extended-query-test/disable-load-balance-always.
Tatsuo Ishii [Sun, 11 Aug 2019 02:27:58 +0000 (11:27 +0900)]
Fix test failure of extended-query-test/disable-load-balance-always.

It expected the first SELECT to be sent to load balance node but a
preceding write query (DROP/CREATE TABLE) prevented it because it set
the writing_transaction flag. Fix is, instead of issuing DROP/CREATE
TABLE before the SELECT, issue harmless SET command after the SELECT
in extended query mode.

6 years agoFix extra test scripts to not fail.
Tatsuo Ishii [Sat, 10 Aug 2019 23:34:33 +0000 (08:34 +0900)]
Fix extra test scripts to not fail.

Now SELECT version() is always issued, this makes the script confused
because they extra lines in question by using "grep SELECT".  To avoid
the confusion, add "grep -v version" into the command pipe line.

6 years agoFix "unable to bind. cannot get parse message" error.
Tatsuo Ishii [Fri, 9 Aug 2019 08:04:28 +0000 (17:04 +0900)]
Fix "unable to bind. cannot get parse message" error.

This was caused by too-eager memory free in parse_before_bind. It
called
pool_remove_sent_message/pool_create_sent_message/pool_add_sent_message
combo to replace the query context in the sent message. Unfortunately
pool_remove_sent_message free memory such as statement name, which was
being passed by caller. As a result, the new sent message created by
pool_create_sent_message pointed to freed statement name, which may
make a search by statement name fail because now the statement name in
the sent message points to freed memory area, which might be
overwritten by later memory allocation. Fix is, instead of calling
pool_remove_sent_message etc., just replace the query context in the
sent message.

Per bug 531.

6 years agoCreate PostgreSQL version cache as early as possible.
Tatsuo Ishii [Fri, 9 Aug 2019 05:50:56 +0000 (14:50 +0900)]
Create PostgreSQL version cache as early as possible.

Since once error query is issued, the query to create version cache
(SELECT version()) is ignored and it leads to failure in creating
version cache. Fix is, to create version cache after query context is
created and before user query is sent in SimpleQuery() and Parse().

6 years agoDoc: update 4.1 release note.
Tatsuo Ishii [Fri, 9 Aug 2019 01:20:53 +0000 (10:20 +0900)]
Doc: update 4.1 release note.

For these commits:  2019-05-27 [33df0d33], 2019-08-08 [3922c12c].

6 years agoFix for 0000483: online-recovery is blocked after a child process exits ...
Muhammad Usama [Thu, 8 Aug 2019 13:50:51 +0000 (18:50 +0500)]
Fix for 0000483: online-recovery is blocked after a child process exits ...

The problem is if some child process exits abnormally during the second stage
of online recovery, then the connection counter that keeps the track of exiting
processes does not get decremented and Pgpool-II keeps waiting for the exit of
the already exited process. Eventually, the recovery fails after
client_idle_limit_in_recovery expires.

The fix for this issue is to set the connection counter to zero when
client_idle_limit_in_recovery is enabled and it has less value than
recovery_timeout, Since all clients must have been kicked out by the time
when client_idle_limit_in_recovery expires.

A similar fix is already committed as part of bug 431 by Tatsuo Ishii, So this
commit basically imports the same logic in the watchdog function that processes
the remote online recovery requests.

Apart from the above-mentioned change,  Hoshiai San identified that the watchdog
IPC command timeout for the online recovery start functions executed through
watchdog is set exactly to the same as recovery_timeout which needs to be
increased to make the solution work correctly.

6 years agoDoc: run auto indent using emacs.
Tatsuo Ishii [Thu, 8 Aug 2019 07:35:22 +0000 (16:35 +0900)]
Doc: run auto indent using emacs.

Here is the emacs script F.Y.I.

;; must be run by emacs
(load "/home/t-ishii/.emacs.d/init.el")
(find-file (nth 0 command-line-args-left));
(indent-region (point-min) (point-max));
(save-buffer)

6 years agoDoc: Update "Pgpool-II + Watchdog Setup Example" configuration example.
Bo Peng [Thu, 8 Aug 2019 06:35:36 +0000 (15:35 +0900)]
Doc: Update "Pgpool-II + Watchdog Setup Example" configuration example.

6 years agoFix for no primary on standby pgpool when primary is quarantined on master
Muhammad Usama [Wed, 7 Aug 2019 15:22:01 +0000 (20:22 +0500)]
Fix for no primary on standby pgpool when primary is quarantined on master

Master watchdog Pgpool sends primary_node_id = -1 in the backend status sync
message if the primary node is quarantined on it. So standby watchdog Pgpool
must not update its primary_node_id if the primary backend node id in sync
message is invalid_node_id (-1) while the same sync message reports the
backend status of the current primary node as "NOT DOWN".

The issue was reported by  "Tatsuo Ishii <ishii@sraoss.co.jp>" and fixed by me

6 years agoDoc; mention quorum faiover introduced in 3.7
Tatsuo Ishii [Thu, 8 Aug 2019 05:55:53 +0000 (14:55 +0900)]
Doc; mention quorum faiover introduced in 3.7

Also fix indentation.

6 years agoDoc: fix indentation.
Tatsuo Ishii [Thu, 8 Aug 2019 05:44:11 +0000 (14:44 +0900)]
Doc: fix indentation.

Also remove unnecessary xref label of sect2.

6 years agoMake waiting for TIME_WAIT in pgpool_setup optional.
Tatsuo Ishii [Thu, 8 Aug 2019 02:38:02 +0000 (11:38 +0900)]
Make waiting for TIME_WAIT in pgpool_setup optional.

Since commit 3b32bc4e583da700cc8df7c5777e90341655ad3b the shutdownall
script generated by pgpool_setup waits for Pgpool-II socket in
TIME_WAIT state disappeared. However in most cases this takes long
time and it makes uncomfortable for developer's testing works.

This commit makes the wait to be optional: unless environment variable
"CHECK_TIME_WAIT" is set to other than "false", it never waits for the
TIME_WAIT state.

6 years agoImport some of memory manager debug facilities from PostgreSQL.
Tatsuo Ishii [Thu, 8 Aug 2019 02:02:50 +0000 (11:02 +0900)]
Import some of memory manager debug facilities from PostgreSQL.

Now we can use CLOBBER_FREED_MEMORY, which is useful to detect
accesses to already pfreed memory.

6 years agoEnhance extended query test driver.
Tatsuo Ishii [Thu, 8 Aug 2019 02:00:35 +0000 (11:00 +0900)]
Enhance extended query test driver.

- Change diff format using context diff.
- Suppress diffs related to message line number changes.
- Fix indentation.

6 years agoRemove some code that was forgotten to be deleted in a previous commit.
Bo Peng [Thu, 8 Aug 2019 00:48:43 +0000 (09:48 +0900)]
Remove some code that was forgotten to be deleted in a previous commit.

6 years agoAdd new arguments in pgpool_recovery function and failover_command/failback_command...
Bo Peng [Thu, 8 Aug 2019 00:45:00 +0000 (09:45 +0900)]
Add new arguments in pgpool_recovery function and failover_command/failback_command/follow_master_command.

Now able to use "recovery node port number" in pgpool_recovery function.
Also the following options is added in failover_command/failback_command/follow_master_command.

- %N = old primary node hostname
- %S = old primary node port number

6 years agoRevert "Add new arguments in pgpool_recovery function and failover_command/failback_c...
Bo Peng [Thu, 8 Aug 2019 00:43:51 +0000 (09:43 +0900)]
Revert "Add new arguments in pgpool_recovery function and failover_command/failback_command/follow_master_command."

This reverts commit 25a4237c9bc8db33f6710df8e43b285f36751038.

6 years agoAdd new arguments in pgpool_recovery function and failover_command/failback_command...
Bo Peng [Thu, 8 Aug 2019 00:26:36 +0000 (09:26 +0900)]
Add new arguments in pgpool_recovery function and failover_command/failback_command/follow_master_command.

Now able to use "recovery node port number" in pgpool_recovery function.
Also the following options is added in failover_command/failback_command/follow_master_command.

- %N = old primary node hostname
- %S = old primary node port number

6 years agoDoc: move watchdog chapter from "Tutorial" to "Server Administration".
Tatsuo Ishii [Wed, 7 Aug 2019 07:55:38 +0000 (16:55 +0900)]
Doc: move watchdog chapter from "Tutorial" to "Server Administration".

The chapter was not best suited for tutorials.

6 years agoFix extended test driver to not ignore given arguments.
Tatsuo Ishii [Wed, 7 Aug 2019 02:24:27 +0000 (11:24 +0900)]
Fix extended test driver to not ignore given arguments.

src/test/extended-query-tests/test.sh did not consider given arguments
while executing 3 node tests because "$1" is lost because of other
processing.  To fix the issue "$1" is saved and used in subsequent
processing.

6 years agoFix global static variable to local static variable.
Takuma Hoshiai [Tue, 6 Aug 2019 08:25:58 +0000 (17:25 +0900)]
Fix global static variable to local static variable.

The variable of auto_failback_interval is called only by establish_persistent_connection().
So changed global static variable to local static variable.

6 years agoOverhaul health check debug facility.
Tatsuo Ishii [Tue, 6 Aug 2019 02:27:30 +0000 (11:27 +0900)]
Overhaul health check debug facility.

check_backend_down_request() in health_check.c is intended to simulate
the situation where communication failure between health check and
PostgreSQL backend node by creating a file containing lines:

1 down

where the first numeric is the node id starting from 0, tab, and
"down". When health check process finds the file, let health check
fails on node 1.

After health check brings the node into down status,
check_backend_down_request() change "down" to "already_down" to
prevent repeating node failure.

However, questions is, this is necessary at all. I think
check_backend_down_request() should keep on reporting the down status
and it should be called inside establish_persistent_connection() to
prevent repeating node failure because it could be better simulated
the failing situation in this way. For example, currently the health
check retry is not simulated but the new way can do it.

Moreover, in current watchdog implementation, to bring a node into
quarantine state requires *two" times of node communication error
detection. Since check_backend_down_request() only allows to raise
node down even *once" (after the down state is changed to already_down
state), it's impossible to test the watchdog quarantine using
check_backend_down_request(). I changed check_backend_down_request()
so that it continues to raise "down" event as long as the down request
file exists.

This commit enhances check_backend_down_request() as described above.

1) caller of check_backend_down_request() is
   establish_persistent_connection(), rather than
   do_health_check_child().

2) check_backend_down_request() does not change "down" to
   "already_down" anymore. This means that the second argument of
   check_backend_down_request() is not useful anymore. Probably I
   should remove the argument later on.

6 years agoFix segfaut in streaming replication check process.
Tatsuo Ishii [Fri, 2 Aug 2019 04:03:13 +0000 (13:03 +0900)]
Fix segfaut in streaming replication check process.

In case of failure of pg_stat_replication() call, the streaming
replication check process unconditionally tried to free the allocated
memory.  This should only be done when the call succeeds.

6 years agoDoc: mention the separate parser patch.
Tatsuo Ishii [Fri, 2 Aug 2019 00:05:49 +0000 (09:05 +0900)]
Doc: mention the separate parser patch.

6 years agoMultiple performance enhancements especially for of the large
Muhammad Usama [Thu, 1 Aug 2019 20:23:25 +0000 (01:23 +0500)]
Multiple performance enhancements especially for of the large
INSERT and UPDATE statements

Pgpool-II only needs very little information, especially for the INSERT and
UPDATE statements to decide where it needs to send the query.
For example: In master-slave mode, for the INSERT statements Pgpool-II only
requires the relation name referenced in the statement while it doesn't care
much about the column values and other parameters. But since the parser we use
in Pgpool-II is taken from PostgreSQL source which parses the complete query
including the value lists which seems harmless for smaller statements but in
case of INSERT and UPDATE with lots of column values and large data in value
items, consumes significant time.

So the idea here is to short circuit the INSERT and UPDATE statement parsing as
soon as we have the required information. For that purpose, the commit adds the
second minimal parser that gets invoked in master-slave mode and tries to
extract the performance for large INSERT and UPDATE statements.

Apart from the second parser addition, following changes aiming towards the
performance enhancements are also part of the commit.

1-Some of the if statements in pool_where_to_send() function are re-arranged to
make sure the more expensive functions calls, pattern_compare()
and pool_has_function_call() should only be made when they are
absolutely necessary.

2- Eliminates the raw_parser() calls in case of un-recognized queries. Instead
of invoking the parser on "dummy read" and "dummy write" statements, the commit
adds the functions to return the pre-built parse_trees for these dummy queries.

3-- strlen() call is removed from scanner_init() function and is passed to it
as an argument. The reason being we already have the query length in most cases
before invoking the parser so why waste CPU cycles on it. Again this becomes
significant in case of large query strings.

4- Removes some of the unnecessary calls of pool_is_likely_select() function.

6 years agoUpdate 4.1 release note.
Tatsuo Ishii [Thu, 1 Aug 2019 06:45:21 +0000 (15:45 +0900)]
Update 4.1 release note.

6 years agoAdd Pgpool-II 4.1 release note.
Tatsuo Ishii [Thu, 1 Aug 2019 06:14:37 +0000 (15:14 +0900)]
Add Pgpool-II 4.1 release note.

6 years agoFix check_replication_lag to not break auto_failback.
Tatsuo Ishii [Mon, 29 Jul 2019 07:29:13 +0000 (16:29 +0900)]
Fix check_replication_lag to not break auto_failback.

Commit bbfe3adb broke auto_failback because it doesn't collect info
from pg_stat_replication for down node. This commit fix the breakage
and eliminate thinko:

- Do not count the number of active nodes since it is useful to show
  streaming replication status in "show pool_nodes" for all nodes which
  are actually active and running even if Pgpool-II thinks they are
  down regardless auto_failback is on or off.

- Call pg_stat_replication once, rather than call for each node.

6 years agoFix watchdog_setup command option
Takuma Hoshiai [Mon, 29 Jul 2019 06:07:21 +0000 (15:07 +0900)]
Fix watchdog_setup command option

The mode option is incorrectly. when pgpool_setup command  is called by
watchdog_setup command, mode option forget to set.

6 years agoFix typo and copyright.
Takuma Hoshiai [Mon, 29 Jul 2019 05:28:02 +0000 (14:28 +0900)]
Fix typo and copyright.

6 years agoFix pgpool_setup to produce correct follow master command.
Tatsuo Ishii [Sun, 28 Jul 2019 02:11:07 +0000 (11:11 +0900)]
Fix pgpool_setup to produce correct follow master command.

The produced script incorrectly checked whether PostgreSQL is running
or not, which resulted in that it mistakenly thought PostgreSQL is
always running.

6 years agoAdjust WHERE clause of pg_stat_replication to not issue against down node.
Tatsuo Ishii [Sun, 28 Jul 2019 02:05:51 +0000 (11:05 +0900)]
Adjust WHERE clause of pg_stat_replication to not issue against down node.

Previously the query to get replication status was unconditionally
issued to down node, which produced annoying "no row returned" log.

6 years agoDoc: add index to "quorum".
Tatsuo Ishii [Sat, 27 Jul 2019 00:34:39 +0000 (09:34 +0900)]
Doc: add index to "quorum".

6 years agoDoc: update chapter of 'Examples'
Takuma Hoshiai [Thu, 25 Jul 2019 05:17:15 +0000 (14:17 +0900)]
Doc: update chapter of 'Examples'

Update 'Examples' chapter, and fix typo in other chapters.
Reviewed by Tatsuo Ishii and Bo Peng.

6 years agoDoc: mention that quorum state can be shown by using pcp_watchdog_info.
Tatsuo Ishii [Thu, 25 Jul 2019 04:59:12 +0000 (13:59 +0900)]
Doc: mention that quorum state can be shown by using pcp_watchdog_info.

6 years agoFeature: Import PostgreSQL 12 beta2 new parser.
Bo Peng [Wed, 24 Jul 2019 12:11:33 +0000 (21:11 +0900)]
Feature: Import PostgreSQL 12 beta2 new parser.

The attached patch imports PostgreSQL12 beta2 parser to Pgpool-II 4.1.

Major chanegs of PostgreSQL 12 parser include:

- Add new VACUUM options:
  -- SKIP_LOCKED
  -- INDEX_CLEANUP
  -- TRUNCATE
- Add COMMIT AND CHAIN and ROLLBACK AND CHAIN commands
- Add a WHERE clause to COPY FROM
- Allow to use CREATE OR REPLACE AGGREGATE command
- Allow to use mcv (most-common-value) in CREATE STATISTICS
- ADD REINDEX option CONCURRENTLY
- Add EXPLAIN option SETTINGS
- etc.

6 years agoAdd regression test for auto_failback
Takuma Hoshiai [Mon, 22 Jul 2019 08:05:41 +0000 (17:05 +0900)]
Add regression test for auto_failback

6 years agoFeature: auto failback
Takuma Hoshiai [Mon, 22 Jul 2019 00:42:18 +0000 (09:42 +0900)]
Feature: auto failback

In Pgpool-II 4.1 or later, you can reattach backend nodethat is status DOWN automatically if auto_failback set on, this future is enabled.

The Feature of auto_failback require that backend node of PostgreSQL are 9.1 or later with streaming-replication mode, and sr_check process and health_check is enabled.

It do health check for standby node, when status of standby Node is down but status of streaming replication between primary and standby is 'stream'. If health check is success, execute process of fail_back automatically. This featurel is usefull for health check is failed bacause of tempolary network error is happened for example.

6 years agoRemove useless lines.
Tatsuo Ishii [Wed, 17 Jul 2019 08:24:09 +0000 (17:24 +0900)]
Remove useless lines.

Since "contents" is never NULL, those lines are never executed.
Per Coverity.

6 years agoFix the failover() so that it does not access out of array.
Tatsuo Ishii [Wed, 17 Jul 2019 07:51:31 +0000 (16:51 +0900)]
Fix the failover() so that it does not access out of array.

Per Coverity.

6 years agoEnhance shutdown script of pgpool_setup.
Tatsuo Ishii [Wed, 17 Jul 2019 07:48:37 +0000 (16:48 +0900)]
Enhance shutdown script of pgpool_setup.

I observe occasional regression test failure caused by bind error to
the TCP/IP port.  This fix tries to confirm usage of the TCP/IP port
while executing shutdown script using netstat command.

6 years agoDoc: enhance client authentication docs.
Tatsuo Ishii [Tue, 16 Jul 2019 05:12:30 +0000 (14:12 +0900)]
Doc: enhance client authentication docs.

6 years agoFix Pgpool-II rewriting query error when the queries include "GROUPS" and "EXCLUDE...
Bo Peng [Wed, 10 Jul 2019 07:30:32 +0000 (16:30 +0900)]
Fix Pgpool-II rewriting query error when the queries include "GROUPS" and "EXCLUDE" in frame clauses.
This occurs only in native replication mode.

Thanks to Yugo Nagata for the bug reporting.

6 years agoUse foreach macro in pool_temp_tables module.
Tatsuo Ishii [Wed, 10 Jul 2019 00:03:16 +0000 (09:03 +0900)]
Use foreach macro in pool_temp_tables module.

It used to use plain for(), but there's no reason to not use the
convenient macro.

6 years agoFix logically dead code pointed out by Coverity.
Tatsuo Ishii [Tue, 9 Jul 2019 22:38:21 +0000 (07:38 +0900)]
Fix logically dead code pointed out by Coverity.

Whether pwd is NULL or not was already checked, and there's no point
to check it again.

6 years agoDoc: enhance watchdog documents regarding quorum failover.
Tatsuo Ishii [Tue, 9 Jul 2019 04:31:52 +0000 (13:31 +0900)]
Doc: enhance watchdog documents regarding quorum failover.

6 years agoFix memory leak pointed out by Coverity.
Tatsuo Ishii [Mon, 8 Jul 2019 04:20:08 +0000 (13:20 +0900)]
Fix memory leak pointed out by Coverity.

When failed to create a connection to backend, new_connection() failed
to free memory.

6 years agoFix possible out of array index access.
Tatsuo Ishii [Sun, 7 Jul 2019 13:58:35 +0000 (22:58 +0900)]
Fix possible out of array index access.

It was pointed out by Coverity that node_id could be -1.

6 years agoFix query cache module so that it checks oid array's bound.
Tatsuo Ishii [Sun, 7 Jul 2019 01:09:25 +0000 (10:09 +0900)]
Fix query cache module so that it checks oid array's bound.

6 years agoFix to check the return value of strchr() in Pgversion().
Tatsuo Ishii [Sat, 6 Jul 2019 23:24:16 +0000 (08:24 +0900)]
Fix to check the return value of strchr() in Pgversion().

Pointed out by Coverity.

6 years agoFix off-by-one error in query cache module.
Tatsuo Ishii [Sat, 6 Jul 2019 23:08:25 +0000 (08:08 +0900)]
Fix off-by-one error in query cache module.

When debug print is enabled, it might had tried to access out of bound
of oid array.

6 years agoFix buffer overrun in Pgversion().
Tatsuo Ishii [Sat, 6 Jul 2019 23:03:02 +0000 (08:03 +0900)]
Fix buffer overrun in Pgversion().

Also enhance comments.

6 years agoAllow health check process to reload pgpool.conf.
Tatsuo Ishii [Fri, 5 Jul 2019 05:32:43 +0000 (14:32 +0900)]
Allow health check process to reload pgpool.conf.

When separate health check process was introduced, we forgot to send
signal to the health check process when pgpool.conf reload is
requested.