pgpool2.git
7 years agoadding the support for using and storing the encrypted passwords in pool_passwd
Muhammad Usama [Fri, 20 Jul 2018 22:36:53 +0000 (03:36 +0500)]
adding the support for using and storing the encrypted passwords in pool_passwd
file to be used for SCRAM and other auth methods.
new utility pg_enc is also added for creating the encrypted passwords.
openssl is used for encryption and decryption, so Pgpool-II must be built with
ssl (--with-openssl) support to use the encrypted password feature.

7 years agoadding scram and md5 auth test cases
Muhammad Usama [Thu, 10 May 2018 20:17:53 +0000 (01:17 +0500)]
adding scram and md5 auth test cases

7 years agosome misc code cleanups
Muhammad Usama [Thu, 10 May 2018 19:51:38 +0000 (00:51 +0500)]
some misc code cleanups

7 years agoAdd new Pgpool-II config parameter allow_clear_text_frontend_auth
Muhammad Usama [Wed, 2 May 2018 08:57:36 +0000 (13:57 +0500)]
Add new Pgpool-II config parameter allow_clear_text_frontend_auth

allow_clear_text_frontend_auth allows Pgpool-II to use clear text password
authentication with front-end clients, when pool_passwd file does not
contain the password for connecting user while the backend asks for
MD5 or SCRAM type authentication.
allow_clear_text_frontend_auth only works when pool_hba is not enabled

7 years agoDo not throw the FATAL error when the ssl server side context creation fails.
Muhammad Usama [Thu, 26 Apr 2018 20:23:07 +0000 (01:23 +0500)]
Do not throw the FATAL error when the ssl server side context creation fails.

The SSL server side context creation has been moved to the pgpool startup in
hope of achieving a little performance boost by cert auth commit, previously it
was in done in child process at session startup. And throwing a FATAL error at
startup prevents the pgpool from starting up which we do not want.

7 years agoMore for SCRAM authentication support, This commit also adds the support for
Muhammad Usama [Wed, 25 Apr 2018 20:24:16 +0000 (01:24 +0500)]
More for SCRAM authentication support, This commit also adds the support for
CERT authentication between client and Pgpool-II.
The authentication infrastructure of Pgpool-II is also enhanced by this commit
and now it is possible to use different authentication methods between client
to Pgpool-II and Pgpool-II to backend.

7 years agoThe initial commit for SCRAM authentication support, The code is compilable and
Muhammad Usama [Thu, 1 Mar 2018 15:21:40 +0000 (20:21 +0500)]
The initial commit for SCRAM authentication support, The code is compilable and
is in working state. But it is still not the production quality and needs lots
of cleanup, commenting, testing and documentation updates.

7 years agoFix segfault when node 0 is in down status.
Tatsuo Ishii [Sun, 5 Aug 2018 01:54:18 +0000 (10:54 +0900)]
Fix segfault when node 0 is in down status.

MASTER_CONNECTION refers to the connection to "master"
node. "Master" means the first live backend appearing in
pgpool.conf. The master node is determined at the time of fail over.
Unfortunately with both health check and fail_over_on_backend_error
are disabled, there's no chance of failover, which means the master
node id is remained the default value 0. So the MASTER_CONNECTION
refers to the node 0, and the connection is NULL.

Fix is as follows.

If attempt to connection to backend fails, check the master node id in
the shared memory.  If the master node id is the failed node, then
look for new master node using get_next_master_node (this was a static
function, but now it's made to public) and set the node id to the
master node id in the shared memory area.

Problem reported by Muhammad Usama in [pgpool-hackers: 2905].

7 years agoFix typos in documents and scripts.
Tatsuo Ishii [Fri, 3 Aug 2018 02:09:30 +0000 (11:09 +0900)]
Fix typos in documents and scripts.

Patch contributed by Jesper Pedersen.

7 years agoFix redundant messages in log_client_messages.
Tatsuo Ishii [Thu, 2 Aug 2018 00:39:33 +0000 (09:39 +0900)]
Fix redundant messages in log_client_messages.

Patch contributed by Takuma Hoshiai.

7 years agoFix redundant messages when log_client_messages is enabled.
Tatsuo Ishii [Wed, 1 Aug 2018 07:42:46 +0000 (16:42 +0900)]
Fix redundant messages when log_client_messages is enabled.

Also add missing test files in the previous commit.
Patch contributed by Takuma Hoshiai.

7 years agoFix compiler error if HAVE_ASPRINTF is not defined.
Tatsuo Ishii [Tue, 31 Jul 2018 01:16:10 +0000 (10:16 +0900)]
Fix compiler error if HAVE_ASPRINTF is not defined.

7 years agoFix badly formatted comment out line.
Tatsuo Ishii [Tue, 31 Jul 2018 01:13:53 +0000 (10:13 +0900)]
Fix badly formatted comment out line.

7 years agoFix configure.ac to remove generating src/sql/pgpool_adm/Makefile.in.
Tatsuo Ishii [Tue, 31 Jul 2018 01:10:26 +0000 (10:10 +0900)]
Fix configure.ac to remove generating src/sql/pgpool_adm/Makefile.in.

Along with newer autoconf generated files.

7 years agoRemove unnecessary files.
Tatsuo Ishii [Tue, 31 Jul 2018 00:49:37 +0000 (09:49 +0900)]
Remove unnecessary files.

7 years agoAdd missing last newline.
Tatsuo Ishii [Tue, 31 Jul 2018 00:38:37 +0000 (09:38 +0900)]
Add missing last newline.

I have found this while playing with pgindent. It is smart enough to
find out such problems.

7 years agoAdd release-notes 3.3.22-3.7.5.
Bo Peng [Tue, 31 Jul 2018 00:02:15 +0000 (09:02 +0900)]
Add release-notes 3.3.22-3.7.5.

7 years agoAdd new log_client_messages directive.
Tatsuo Ishii [Fri, 27 Jul 2018 08:35:41 +0000 (17:35 +0900)]
Add new log_client_messages directive.

This allows to log messages from frontend.

Note that the regression test for this (019.log_client_messages)
requires pgproto command.  We will eventually import pgproto in the
future but for now we just check the existence of pgproto in
019.log_client_messages/test.sh. If pgproto does not exist in the
command search pass, just skip the test with "ok" status.

Patch contributed by Takuma Hoshiai.

7 years agoFix document typos.
Bo Peng [Tue, 24 Jul 2018 04:45:11 +0000 (13:45 +0900)]
Fix document typos.
Patch provided by Takuma Hoshiai.

7 years agoFix document typo.
Bo Peng [Tue, 24 Jul 2018 00:05:53 +0000 (09:05 +0900)]
Fix document typo.

7 years agoFix accessing already freed data in extended query.
Tatsuo Ishii [Fri, 13 Jul 2018 08:36:00 +0000 (17:36 +0900)]
Fix accessing already freed data in extended query.

When previous_message was set and accessed later on, it looked into
already freed data. This is because read_kind_from_backend() set the
pointer to the previous message in session context, and then released
the memory at the end of the function. No report from fields so far. I
just found this while testing Pgpool-II.

To fix this, store the previous message in the session context, rather
than storing the pointer. Also have a flag in the session context to
indicate whether a previous message is actually stored or not.

All the API for previous message has not been changed.

7 years agoTry to reduce the chance of regression 006.memcache failure.
Tatsuo Ishii [Wed, 11 Jul 2018 01:16:07 +0000 (10:16 +0900)]
Try to reduce the chance of regression 006.memcache failure.

It seems the occasional failure of the test is caused by replication
lag.  The script tries to read tables from standby but it returns a
table not existing error.  So insert pg_sleep() after creation of
tables.

7 years agoAllow not to use pool_passwd in raw mode.
Tatsuo Ishii [Tue, 10 Jul 2018 02:25:00 +0000 (11:25 +0900)]
Allow not to use pool_passwd in raw mode.

Since in raw there's only 1 backend is actually involved, there's no
need to use pool_passwd with md5 authentication.
Per bug 411.

7 years agoFix broken markup of client-auth.sgml.
Tatsuo Ishii [Tue, 10 Jul 2018 02:12:04 +0000 (11:12 +0900)]
Fix broken markup of client-auth.sgml.

Also run auto-indentation using Emacs.

7 years agoAllow to display Pgpool-II child process id and PostgreSQL backend id in pcp_proc_info.
Tatsuo Ishii [Mon, 9 Jul 2018 08:14:37 +0000 (17:14 +0900)]
Allow to display Pgpool-II child process id and PostgreSQL backend id in pcp_proc_info.

If --all option was not specified, Pgpool-II child process id was not
displayed. This is not reasonable since if Pgpool-II child process id
is not given, multiple entries of Pgpool-II child process are
displayed without no information to distinguish them.

So fix the command so that it always display Pgpool-II child process
id. Also there's no reason not to display PostgreSQL backend id, so
displays it.

7 years agoFix compile error when build with PostgreSQL 9.6 or 9.5.
Tatsuo Ishii [Mon, 9 Jul 2018 05:59:19 +0000 (14:59 +0900)]
Fix compile error when build with PostgreSQL 9.6 or 9.5.

This prevents buildfarm from building with those PostgreSQL versions
(PostgreSQL 10 is ok).

7 years agoAdd role, replication_delay and last_status_change columns to pgpool_adm's pcp_node_info.
Tatsuo Ishii [Wed, 4 Jul 2018 22:57:28 +0000 (07:57 +0900)]
Add role, replication_delay and last_status_change columns to pgpool_adm's pcp_node_info.

Now the function is sync with show pool_nodes SQL and pcp_node_info
command.  Due to parameter change, I also add upgrade scripts so that
users can migrate from 1.0 to 1.1 using ALTER extension pgpool_adm.

7 years agoFix "write on backend 0 failed with error :"Success"" error.
Tatsuo Ishii [Wed, 4 Jul 2018 06:15:23 +0000 (15:15 +0900)]
Fix "write on backend 0 failed with error :"Success"" error.

While writing to a socket, sometimes write() returns 0. Before we
treated this as an error, but it seems this could happen in the field
and is better to be treated as normal. So if write() returns 0, then
retry write() instead of raise an error.

Per bug #403.

7 years agoFix for 0000409: worker process is not restarted after failover on standby..
Muhammad Usama [Tue, 3 Jul 2018 12:21:36 +0000 (17:21 +0500)]
Fix for 0000409: worker process is not restarted after failover on standby..

restart Worker process after syncing the backend status from master Pgpool-II
Patch contributed by nagata

7 years agoSync pcp_node_info with pgpool show command.
Tatsuo Ishii [Tue, 3 Jul 2018 00:44:56 +0000 (09:44 +0900)]
Sync pcp_node_info with pgpool show command.

Add "Replication Delay" and "Last Status Change" to pcp_node_info.

7 years agoFix for 0000406: failover called with old-primary = -1
Muhammad Usama [Thu, 28 Jun 2018 12:37:23 +0000 (17:37 +0500)]
Fix for 0000406: failover called with old-primary = -1

The problem is when the primary node is quarantined the current primary node id
is set to -1 (Invalid), and once after consensus is made the failover never see
the original values for and old-primary.
The fix is to restore the primary node and master node status to the older
states (before the primary node was quarantined) while processing the failover
and failback on quarantined nodes.

7 years agoFix find_primary_node() return value in commit f0631a6.
Tatsuo Ishii [Thu, 28 Jun 2018 02:30:01 +0000 (11:30 +0900)]
Fix find_primary_node() return value in commit f0631a6.

In this commit find_primary_node() returns 0, rather than -1 if no
primary node exists. This is not correct and should be set to -1.
Also fix some thinko in this commit.

Problem pointed out by Muhammad Usama.

7 years agoFix memory leak.
Tatsuo Ishii [Sun, 24 Jun 2018 00:59:06 +0000 (09:59 +0900)]
Fix memory leak.

Per Coverity.

7 years agoStart health check process at failback.
Tatsuo Ishii [Fri, 22 Jun 2018 08:27:16 +0000 (17:27 +0900)]
Start health check process at failback.

Health check process will not start if a backend node is in down
status when Pgpool-II starts.  However when the node fails back,
health check should start so that it can detects the failure of the
node.

Per bug 407.

7 years agoAdd nap time after failover.
Tatsuo Ishii [Fri, 22 Jun 2018 05:37:25 +0000 (14:37 +0900)]
Add nap time after failover.

This should make the test failure less frequent.

7 years agoFix comments and coding style.
Tatsuo Ishii [Wed, 20 Jun 2018 04:57:40 +0000 (13:57 +0900)]
Fix comments and coding style.

7 years agoFix 006.memqcache test.
Tatsuo Ishii [Wed, 20 Jun 2018 02:49:45 +0000 (11:49 +0900)]
Fix 006.memqcache test.

It forgot to execute shutdownall if some of tests failed. This lead to
hang up of subsequent tests.

7 years agoFix memory leaks related to pool_extract_error_message().
Tatsuo Ishii [Wed, 20 Jun 2018 01:25:23 +0000 (10:25 +0900)]
Fix memory leaks related to pool_extract_error_message().

After 3.4, the function starts to return palloc'ed memory, and the
caller should had been modified so that they pfree the memory returned
by it but actually they had not.

7 years agoFix oversight in pool_extract_error_message().
Tatsuo Ishii [Tue, 19 Jun 2018 02:31:29 +0000 (11:31 +0900)]
Fix oversight in pool_extract_error_message().

A variable used for storing the return value was mistakenly declared
as bool, rather than int.  This led to a segfault issue mentioned in
75b27e7 on certain platform.

7 years agoFix segfault in per_node_error_log() on armhf architecture.
Tatsuo Ishii [Tue, 19 Jun 2018 01:10:33 +0000 (10:10 +0900)]
Fix segfault in per_node_error_log() on armhf architecture.

pool_extract_error_message() incorrectly returns 255 (in decimal) on
the architecture when previous message was not an error or a notice
message. In this case per_node_error_log() happily calls ereport since
the return value from pool_extract_error_message() is greater than
0. Unfortunately the message string returned by
pool_extract_error_message() points to garbage memory in this case, a
segfault occurs.

The fix gives per_node_error_log() a guard against the bug of
pool_extract_error_message(). Moreover, the change is more consistent
with other places where pool_extract_error_message() is called.

Fix for pool_extract_error_message() will come later on.

See:
https://github.com/pgpool/pgpool2/issues/14
for more detailed discussion.

Problem reported and patch by Christian Ehrhardt.

7 years agoAdd missed src/config/pool_config.c by commit 83906d1d5024e5f68ef9dd9dff9fda7f5720be4e.
Bo Peng [Mon, 18 Jun 2018 09:33:19 +0000 (18:33 +0900)]
Add missed src/config/pool_config.c by commit 83906d1d5024e5f68ef9dd9dff9fda7f5720be4e.

7 years agoFix memory leak pointed out by Coverity.
Bo Peng [Mon, 18 Jun 2018 08:54:21 +0000 (17:54 +0900)]
Fix memory leak pointed out by Coverity.

7 years agoFix memory leaks and null dereference pointed out by Coverity.
Tatsuo Ishii [Sat, 16 Jun 2018 11:44:47 +0000 (20:44 +0900)]
Fix memory leaks and null dereference pointed out by Coverity.

7 years agoAdd missing docs and samples for disable_load_balance_on_write.
Tatsuo Ishii [Fri, 15 Jun 2018 06:53:57 +0000 (15:53 +0900)]
Add missing docs and samples for disable_load_balance_on_write.

7 years agoFix for wrong backend roles on standby after the failover
Muhammad Usama [Thu, 14 Jun 2018 08:59:53 +0000 (13:59 +0500)]
Fix for wrong backend roles on standby after the failover

Pgpool standby nodes were getting the "require_backend_sync" signal before the
active/master Pgpool had finish the failover. As a results the standby was
getting the wrong backend node statuses. The cause was a simple coding mistake
where failover indication function was passed with the wrong argument.

Problem reported by Bo Peng <pengbo@sraoss.co.jp>

7 years agoAdd new feature to enable specifying SQL patterns lists that should not be load-balanced.
Bo Peng [Thu, 14 Jun 2018 05:27:53 +0000 (14:27 +0900)]
Add new feature to enable specifying SQL patterns lists that should not be load-balanced.

Even though currently we can do this by adding the
/*NO LOAD BALANCE*/ comment to queries, this requires
modifying application codes and this is not always
possible.

This feature enables specifying SQL patterns lists
that should not be load-balanced.

-------------
New parameter
-------------
black_query_pattern_list = ''

You can specify a semicolon separated list of SQL patterns
that should be sent to primary node only.

SQL that matched patterns specified in this list are not load balanced.
Only Maste Slave mode is supported.

You can use regular expression to match SQL patterns,
to which ^ and $ are automatically added.
When using characters such as "'", ";" or "*" in SQL patterns,
you need to escape them using "\".

7 years agoAdd "last_status_change" column to "show pool_nodes" command.
Tatsuo Ishii [Tue, 12 Jun 2018 12:53:04 +0000 (21:53 +0900)]
Add "last_status_change" column to "show pool_nodes" command.

The new column indicates the time when "status" or "role" has been
changed. See [pgpool-hackers: 2822] for the reasoning to add the
column.

Probably "last_status_change" should be added to pcp_node_info command
and pgpool_adm functions as well but they are not included in this
commit.

7 years agoRevert "Fix 055.backend_all_down test failure."
Tatsuo Ishii [Tue, 12 Jun 2018 06:51:00 +0000 (15:51 +0900)]
Revert "Fix 055.backend_all_down test failure."

This reverts commit 65d48c483889d5e1f91898c33b40bc34abc7f0f6.

7 years agoFix 055.backend_all_down test failure.
Tatsuo Ishii [Tue, 12 Jun 2018 06:21:52 +0000 (15:21 +0900)]
Fix 055.backend_all_down test failure.

The test fails because pgpool zombie child process remains. Actually
the failover process is properly performed but when the shutdown
script is executed in background, output to stdout/stderr was blocked,
and this could cause the zombie process syndrome. Soltution is,
redirecting stdout/stderr to /dev/null when sponing the shutdown
script in background.

7 years agoAdd release-notes 3.7.4 - 3.4.18.
Bo Peng [Mon, 11 Jun 2018 13:55:25 +0000 (22:55 +0900)]
Add release-notes 3.7.4 - 3.4.18.

7 years agoFix pgpool hung when query cache enabled in extended query mode.
Tatsuo Ishii [Thu, 31 May 2018 02:39:09 +0000 (11:39 +0900)]
Fix pgpool hung when query cache enabled in extended query mode.

If replication delay is too much, load balancing is
disabled. Unfortunately query cache module tried to access the backend
even if the target node was already changed to primary even if load
balancing was disabled. To fix this, the target backend is identified
by using pending message data which reflects the fact that load
balancing is disabled.

Bug reported in [pgpool-general-jp: 1534].

To reproduce the bug, following steps are required.

1) create a 2 node streaming replication setting (just running
   pgpool_setup will do this),

2) set backend weight 0 to 0 to force the load balance node to node 1.

3) break recovery.conf on node 1 (for example modify conninfo)

4) start the whole cluster.

5) run massive DDL. pgbench -i is convenient for this.

6) make sure that replication delay is too much by using "show
   pool_nodes".

7) run following data using pgproto. (you need to adjust lines
including "#" so that # starts beginning of the line)

 # Test for disable_load_balance_on_write feature.
 #

 # Force load balance node to 1.
 ##backend_weight0 = 0
 ##backend_weight1 = 1

 # Start a transaction
'P' "" "BEGIN" 0
'B' "" "" 0 0 0
'E' "" 0

 # Issue SELECT.
'P' "" "SELECT 1"
'B' "" "" 0 0 0
'E' "" 0

 # Issue COMMIT
'P' "" "COMMIT" 0
'B' "" "" 0 0 0
'E' "" 0
'S'
'Y'

 # Issue same SELECT.
'P' "" "SELECT 1"
'B' "" "" 0 0 0
'E' "" 0
'S'
'Y'

'X'

8) next "SELECT 1" will be hung.

7 years agoFix document typo of PCP commands option "-U".
Bo Peng [Wed, 30 May 2018 05:33:03 +0000 (14:33 +0900)]
Fix document typo of PCP commands option "-U".

7 years agoFix comment typo.
Tatsuo Ishii [Mon, 28 May 2018 05:19:04 +0000 (14:19 +0900)]
Fix comment typo.

7 years agoDelete some debug code.
Bo Peng [Thu, 24 May 2018 08:37:43 +0000 (17:37 +0900)]
Delete some debug code.

7 years agoFix pgpool main process segfault when PostgreSQL 9.5. is used.
Tatsuo Ishii [Thu, 24 May 2018 04:31:04 +0000 (13:31 +0900)]
Fix pgpool main process segfault when PostgreSQL 9.5. is used.

pgpool_setup -n 3 (or greater) triggers the bug. While recovering node
2, pgpool main process tried to retrieve version info from backend #2
even if it's not running. This causes the sefault because connection
was not established yet. The reason why PostgreSQL 9.6 or later was not
suffered from the bug was, PostgreSQL exited the loop as soon as the
server version is higher than 9.5. To fix this, call to VALID_BACKEND
macro was added.

7 years agoDo not set writing tx flag with SET TRANSACTION READ ONLY.
Tatsuo Ishii [Thu, 24 May 2018 02:07:35 +0000 (11:07 +0900)]
Do not set writing tx flag with SET TRANSACTION READ ONLY.

In extended query mode, execute() sets the flag upon completion of
writing queries.  However the flag was set even when SET TRANSACTION
READ ONLY is issued.  Fix this by using
pool_is_transaction_read_only(). This has been already done in simple
query case.

7 years agoFix wrong parameter passed to failover script.
Tatsuo Ishii [Wed, 23 May 2018 08:18:42 +0000 (17:18 +0900)]
Fix wrong parameter passed to failover script.

From 3.7.2, one of the failover script parameters, namely old primary
node was not passed correctly. PRIMARY_NODE_ID macro was used for the
parameter value. Unfortunately it checks the node status since 3.7.2
and gives value 0 if the node is in down status.  The node status
could be down if former primary node was going down. To fix this, use
REAL_PRIMARY_NODE_ID macro which returns the current primary node id
regardless the node status.

Problem reported by Pierre Timmermans in [pgpool-general: 6092].

7 years agoFix regression test error.
Bo Peng [Mon, 21 May 2018 14:32:35 +0000 (23:32 +0900)]
Fix regression test error.

7 years agoRevert "Improve failover.sh of pgpool_setup to avoid test error."
Tatsuo Ishii [Fri, 18 May 2018 00:20:27 +0000 (09:20 +0900)]
Revert "Improve failover.sh of pgpool_setup to avoid test error."

This reverts commit 22cc8ef69a071a698437a45bbd8336922a639d6c.

7 years agoClarify that failover_require_consensus requires that health check is enabled.
Tatsuo Ishii [Thu, 17 May 2018 06:37:58 +0000 (15:37 +0900)]
Clarify that failover_require_consensus requires that health check is enabled.

7 years agoImprove failover.sh of pgpool_setup to avoid test error.
Bo Peng [Thu, 17 May 2018 00:12:59 +0000 (09:12 +0900)]
Improve failover.sh of pgpool_setup to avoid test error.

7 years agoFix fail to handle replication slot environment variable.
Tatsuo Ishii [Tue, 15 May 2018 08:27:13 +0000 (17:27 +0900)]
Fix fail to handle replication slot environment variable.

This causes script errors.

7 years agoFix pgpool_setup when -r option is used.
Tatsuo Ishii [Thu, 10 May 2018 02:53:34 +0000 (11:53 +0900)]
Fix pgpool_setup when -r option is used.

It failed to recognize that pg_rewind succeeded and fell back to rsync
mode.

7 years agoAdd -r option to pgpool_setup to allow use of pg_rewind.
Tatsuo Ishii [Wed, 9 May 2018 08:39:06 +0000 (17:39 +0900)]
Add -r option to pgpool_setup to allow use of pg_rewind.

With this option, pgpool_setup creates basebackup.sh which tries
pg_rewind first.  If it fails, falls back to rsync.

7 years agoUpdate outdated pcp_proc_info manual.
Tatsuo Ishii [Wed, 9 May 2018 02:22:32 +0000 (11:22 +0900)]
Update outdated pcp_proc_info manual.

Especially fix for time stamp (which was UNIX epoch, that was changed
long time ago).

7 years agoFix test.sh in extended_query_test.
Tatsuo Ishii [Tue, 8 May 2018 06:51:04 +0000 (15:51 +0900)]
Fix test.sh in extended_query_test.

It did not respect $PGPOOL_SETUP variable, which points to
pgpool_setup in this source tree.

Also fix error message normalize more complete so that unbale_bind
test does not fail.

7 years agoDowngrade most of DEBUG1 messages to DEBUG5.
Tatsuo Ishii [Mon, 7 May 2018 03:57:45 +0000 (12:57 +0900)]
Downgrade most of DEBUG1 messages to DEBUG5.

This significantly reduces the size of pgpool log when pgpool starts
with -d option (this is equivalent to setting client_min_messages to
debug1).

Per discussion [pgpool-hackers: 2794].

7 years agoFix pgpool_setup to make replication slots properly.
Tatsuo Ishii [Fri, 4 May 2018 22:20:14 +0000 (07:20 +0900)]
Fix pgpool_setup to make replication slots properly.

It only created pgpool_setup_slot1. It should create
pgpool_setup_slot0, pgpool_setup_slot1... pgpool_setup_slotN, where N
= number of nodes -1.

7 years agoAdd missing health_check_timeout in pgpool_setup.
Tatsuo Ishii [Fri, 4 May 2018 08:35:31 +0000 (17:35 +0900)]
Add missing health_check_timeout in pgpool_setup.

Per node health_check_timeout was missing and this should had been
there since the per node health check parameter support was added.

7 years agoUpdate 1st/2nd stage online recovery doc.
Tatsuo Ishii [Fri, 4 May 2018 03:00:48 +0000 (12:00 +0900)]
Update 1st/2nd stage online recovery doc.

Now 1st/2nd stage online recovery commands accept 5 parameters.

7 years agoEnhance online recovery document.
Tatsuo Ishii [Fri, 4 May 2018 02:35:26 +0000 (11:35 +0900)]
Enhance online recovery document.

Clarify that 2nd stage command is only required in native replication
mode.

7 years agoSet max_replication_slots when -s option is specified.
Tatsuo Ishii [Thu, 26 Apr 2018 08:27:40 +0000 (17:27 +0900)]
Set max_replication_slots when -s option is specified.

Older version of PostgreSQL sets max_replication_slots to 0, which
prevents PostgreSQL from starting up if replication slots are used.
So set max_replication_slots to "number of database clusters + 10".
This should be enough.

7 years agoFix variable substitution bug.
Tatsuo Ishii [Thu, 26 Apr 2018 06:59:59 +0000 (15:59 +0900)]
Fix variable substitution bug.

7 years agoRevert "Install Pgpool-II extension by using latest source code."
Bo Peng [Wed, 25 Apr 2018 08:04:16 +0000 (17:04 +0900)]
Revert "Install Pgpool-II extension by using latest source code."

This reverts commit ef2832b4b61cb2f1b1e01a650a178f6eddd05e02.

7 years agoInstall Pgpool-II extension by using latest source code.
Bo Peng [Wed, 25 Apr 2018 06:34:03 +0000 (15:34 +0900)]
Install Pgpool-II extension by using latest source code.

7 years agoAdd pgpool_recovery--1.2.sql.
Tatsuo Ishii [Wed, 25 Apr 2018 01:50:01 +0000 (10:50 +0900)]
Add pgpool_recovery--1.2.sql.

Forgot in the previous commit.

7 years agoUpdate copyright year.
Tatsuo Ishii [Wed, 25 Apr 2018 01:05:33 +0000 (10:05 +0900)]
Update copyright year.

7 years agoFix compile error.
Tatsuo Ishii [Wed, 25 Apr 2018 01:02:02 +0000 (10:02 +0900)]
Fix compile error.

7 years agoFully implement "disable_load_balance_on_write".
Tatsuo Ishii [Mon, 23 Apr 2018 04:12:47 +0000 (13:12 +0900)]
Fully implement "disable_load_balance_on_write".

This feature allows to specify the behavior when a write query issued.
Except Japanese documents, all done.

7 years agoFist cut of disable load balance feature.
Tatsuo Ishii [Thu, 19 Apr 2018 05:22:20 +0000 (14:22 +0900)]
Fist cut of disable load balance feature.

If write query is issued in an explicit transaction and
disable_load_balance is set to 'trans_transaction', then subsequent
read queries will be redirected to primary node even if the
transaction is closed.

TODO:

- Implement 'always' case. In addition to 'trans_transaction', the
  effect persists even outside of explicit transactions until the
  session ends.

- Documentation

7 years agoFix bug when USE_REPLICATION_SLOT is not used.
Tatsuo Ishii [Thu, 19 Apr 2018 05:17:37 +0000 (14:17 +0900)]
Fix bug when USE_REPLICATION_SLOT is not used.

7 years agoFix false primary node detection code.
Tatsuo Ishii [Wed, 18 Apr 2018 14:42:52 +0000 (23:42 +0900)]
Fix false primary node detection code.

The previous commit was wrong.

7 years agoEnhance figures explaining detach_false_primary.
Tatsuo Ishii [Wed, 18 Apr 2018 12:45:07 +0000 (21:45 +0900)]
Enhance figures explaining detach_false_primary.

7 years agoAdd Japanese doc for detach_false_primary parameter.
Tatsuo Ishii [Wed, 18 Apr 2018 06:56:00 +0000 (15:56 +0900)]
Add Japanese doc for detach_false_primary parameter.

Also add figures for the parameter.

7 years agoFix detach_false_primary bug.
Tatsuo Ishii [Wed, 18 Apr 2018 05:54:17 +0000 (14:54 +0900)]
Fix detach_false_primary bug.

Let regard any socket file staring with '/' is a UNIX domain socket
directory.

7 years agoUse replication slot if possible.
Tatsuo Ishii [Wed, 18 Apr 2018 02:40:18 +0000 (11:40 +0900)]
Use replication slot if possible.

By setting USE_REPLICATION_SLOT environment variable, now pgpool_setup
in all tests uses replication slots. This reduces disk space under
src/test/regression from 6.3GB to 5,1GB (1.2GB savings).

7 years agoLet pgpool_setup recognize an environment varible to turn on "-s" option.
Tatsuo Ishii [Wed, 18 Apr 2018 02:33:10 +0000 (11:33 +0900)]
Let pgpool_setup recognize an environment varible to turn on "-s" option.

For this purpose new environment variable "USE_REPLICATION_SLOT".

7 years agoPrevent pcp_recovery_node from recovering "unused" status node.
Tatsuo Ishii [Wed, 18 Apr 2018 01:03:37 +0000 (10:03 +0900)]
Prevent pcp_recovery_node from recovering "unused" status node.

This allowed to try to recover a node without configuration data,
which leads to variety of problems. See discussion:
https://www.pgpool.net/pipermail/pgpool-general/2018-March/006021.html
for more details.

Also I fixed pgpool_recovery function so that it quotes an empty
string argument with double quotes. Without this, the argument is
treated as if it does not exist, which was the source of the complain
from the user.

7 years agoUpdate version to 4.0 devel.
Tatsuo Ishii [Tue, 17 Apr 2018 08:56:53 +0000 (17:56 +0900)]
Update version to 4.0 devel.

7 years agoAdd release notes 3.7.3 - 3.3.21.
Bo Peng [Tue, 17 Apr 2018 08:33:52 +0000 (17:33 +0900)]
Add release notes 3.7.3 - 3.3.21.

7 years agoComplete detach_false_primary feature.
Tatsuo Ishii [Tue, 17 Apr 2018 06:10:32 +0000 (15:10 +0900)]
Complete detach_false_primary feature.

In addition to the previous commit:

- Add new config variable detach_false_primary
- Allow to run test along with streaming replication delay checking
- English docs added (Japanese docs needed to be added later)
- Regression test (018.detach_primary) is added
- Sample configuration files are added
- Process reporting is added

7 years agoDisable health check per node parameters by default.
Bo Peng [Tue, 17 Apr 2018 05:32:26 +0000 (14:32 +0900)]
Disable health check per node parameters by default.

7 years agoAllow to use more than 1 standby in pgpool_setup using replication slot.
Tatsuo Ishii [Mon, 16 Apr 2018 02:47:20 +0000 (11:47 +0900)]
Allow to use more than 1 standby in pgpool_setup using replication slot.

For this purpose, add recovery target node argument to pgpool_recovery
extension.  So extension version is incremented to 1.2.

7 years agoAdd support for replication slot to pgpool_setup.
Tatsuo Ishii [Sun, 15 Apr 2018 11:32:32 +0000 (20:32 +0900)]
Add support for replication slot to pgpool_setup.

This eliminates the problem when standby is promoted. When a standby
is promoted, it changes the time line in PITR archive, which will stop
other standby if any because of shared archive directory.

7 years agoFix pcp_detach_node hung when -g option is specified.
Tatsuo Ishii [Thu, 12 Apr 2018 23:00:24 +0000 (08:00 +0900)]
Fix pcp_detach_node hung when -g option is specified.

"pcp_detach_node -g" had been broken since 3.7. The cause was a misuse
of degenerate_backend_set_ex(). Because of this, actual failover
request was not sent to the pgpool main process. As a result,
pcp_worker process waited vainly for a signal arriving from the
process.

Per bug 391. Problem reported by Tomoyuki Sato, fix by me.

7 years agoFirst cut of primary server checking.
Tatsuo Ishii [Mon, 9 Apr 2018 08:44:21 +0000 (17:44 +0900)]
First cut of primary server checking.

For now followings are implemented:

- Check all backend nodes starting node 0.

- If primary nodes appear twice or more, the second one or after are
  assumed invalid.

- Such invalid node will be degenerated at the next convenient
  time. Currently such timing is at the start up of Pgpool-II. This is
  apparently insufficient and should be improved later.

TODO:
- Verify primary nodes using pg_stat_wal_receiver.

- More chances to verify node status. Maybe in the same timing as
  streaming replication delay checking?

- Add new GUCs to control of this feature.

7 years agoAdd new regression test for node 0 is down.
Tatsuo Ishii [Mon, 9 Apr 2018 05:45:37 +0000 (14:45 +0900)]
Add new regression test for node 0 is down.

test case 1: node 0 is already down before pgpool starts.
test case 2: node 0 goes down after pgpool starts.
test case 3: node 0 goes down and DISALLOW_TO_FAILOVER flag is set after pgpool starts.

7 years agoMake calls to to_regclass fully schema qualified.
Tatsuo Ishii [Sun, 8 Apr 2018 10:18:36 +0000 (19:18 +0900)]
Make calls to to_regclass fully schema qualified.

This is always recommended way.

7 years agoFix pgpool child process segfault when ALWAYS_MASTER is on.
Tatsuo Ishii [Thu, 5 Apr 2018 08:11:36 +0000 (17:11 +0900)]
Fix pgpool child process segfault when ALWAYS_MASTER is on.

If following conditions are all met pgpool child segfaults:

1) Streaming replication mode.

2) fail_over_on_backend_error is off.

3) ALWAYS_MASTER flag is set to the master (writer) node.

4) pgpool_status file indicates that the node mentioned in #3 is in
   down status.

What happens here is,

1) find_primary_node() returns node id 0 without checking the status
   of node 0 since ALWAYS_MASTER is set. It's remembered as the
   primary node id. The node id is stored in Req_info->primary_node_id.

2) The connection to backend 0 is not created since pgpool_status says
   it's in down status.

3) upon starting of session, select_load_balancing_node () is called
   and it tries to determine the database name from client's start up
   packet.

4) Since MASTER_CONNECTION macro points to the PRIMARY_NODE,
   MASTER_CONNECTION(ses->backend) is NULL and it results in a segfault.

The fix is, to change PRIMARY_NODE_ID macro so that it returns
REAL_MASTER_NODE_ID (that is the youngest node id which is alive) if
the node id in Req_info->primary_node_id is in down status. This can
be checked using VALID_BACKEND_RAW macro.

VALID_BACKEND macro cannot be used here because it calls
pool_is_node_to_be_sent_in_current_query() inside. Problem is, when a
query is about to processed, pool_is_query_in_progress() is already
set but pool_is_node_to_be_sent() could return false because
where_to_send member in the query context may not be is set yet
(that's the cause of the enbug in Pgpool-II 3.7.2).

So we have the "true" primary node id in Req_info->primary_node_id,
and "fake" primary node id returned by PRIMARY_NODE_ID macro.

See [pgpool-hackers: 2687] and [pgpool-general: 5881] Pgpool-3.7.1
segmentation fault for more details.

Since ALWAYS_MASTER flag was introduced in 3.7, back pached to 3.7
only.
Per bug report from Philip Champon.

7 years agoImprove watchdog documents.
Tatsuo Ishii [Wed, 4 Apr 2018 02:17:02 +0000 (11:17 +0900)]
Improve watchdog documents.