pgpool2.git
7 years agoDowngrade warning to debug5 when AES/PLAIN password not found in pool_passwd.
Tatsuo Ishii [Thu, 13 Sep 2018 06:02:03 +0000 (15:02 +0900)]
Downgrade warning to debug5 when AES/PLAIN password not found in pool_passwd.

When health_check_password etc. is an empty string, Pgpool-II tries to
fetch AES/PLAIN password in pool_passwd. If other type of password
entry (actually it must be MD5), it warned it. However this is normal
setting till 3.7. Moreover, every time health check or streaming
replication delay check run, it emits the waring and the log file was
filled up with the message.

Solution is, downgrade the message to DEBUG5. Also add password type to
the message.

7 years agoAdd missing src/parser/scan.c file.
Bo Peng [Mon, 10 Sep 2018 02:56:18 +0000 (11:56 +0900)]
Add missing src/parser/scan.c file.

7 years agoFix buildfarm error of 023.ssl_connection.
Tatsuo Ishii [Mon, 10 Sep 2018 02:06:15 +0000 (11:06 +0900)]
Fix buildfarm error of 023.ssl_connection.

It seems CentOS6/7 recognizes "localhost" as IPv6 ::1.

2018-09-08 17:04:06: pid 21508: DETAIL:  no pg_hba.conf entry for host "::1", user "postgres", database "postgres", SSL on

So add following line to pg_hba.conf.

host    all             all             ::1/128                 trust

Let's see if buildfarm still complains.

7 years agoPrepare 4.0alpha2. V4_0_0_ALPHA2
Bo Peng [Thu, 6 Sep 2018 09:00:49 +0000 (18:00 +0900)]
Prepare 4.0alpha2.

7 years agoAdd some changes to 4.0 english release note.
Bo Peng [Thu, 6 Sep 2018 08:57:32 +0000 (17:57 +0900)]
Add some changes to 4.0 english release note.

7 years agoAdd japanese docs for changes about client authentication, and fix some doc typos.
Bo Peng [Thu, 6 Sep 2018 08:12:37 +0000 (17:12 +0900)]
Add japanese docs for changes about client authentication, and fix some doc typos.

Patch provided by Takuma Hoshiai.

7 years agoFix for 0000428: Secure TCP/IP Connections with SSL...
Muhammad Usama [Wed, 5 Sep 2018 06:55:00 +0000 (11:55 +0500)]
Fix for 0000428: Secure TCP/IP Connections with SSL...

check for empty string in pool_config->ssl_ca_cert before
trying to load root certificates

7 years agoAdd "Migration to Version 4.0" section to releasenote.
Bo Peng [Wed, 5 Sep 2018 05:19:57 +0000 (14:19 +0900)]
Add "Migration to Version 4.0" section to releasenote.

7 years agoMiscellaneous fixes in the area of SCRAM authentication.
Muhammad Usama [Tue, 4 Sep 2018 16:01:26 +0000 (21:01 +0500)]
Miscellaneous fixes in the area of SCRAM authentication.

The commit takes care of resource leak warnings reported by coverity
in the authentication module of Pgpool-II, Apart from doing the individual
resource leak fixes I have made the authentication system to use the temporary
memory context which gets deleted after the authentication is done.

In addition to the memory related fixes the commit also contains the following.

-- TEXT prefix support for specifying plain text passwords in configuration
and pool_passwd file.
-- Documentation updates to use plain text passwords with TEXT prefix.
-- Fix for 0000427: pg_enc emits wrong warnings
-- Fix for 0000426: Pgpool-II contines to emit warning messages

7 years agoAdd missing gram.c by previous commit.
Bo Peng [Thu, 30 Aug 2018 00:41:31 +0000 (09:41 +0900)]
Add missing gram.c by previous commit.

7 years agoAdd regression test for SSL connection.
Tatsuo Ishii [Wed, 29 Aug 2018 02:58:36 +0000 (11:58 +0900)]
Add regression test for SSL connection.

This tests SSL connection between frontend <--> Pgpool-II and
Pgpool-II <--> backend.

7 years agoImport PostgreSQL 11 beta3 parser.
Bo Peng [Tue, 28 Aug 2018 09:20:07 +0000 (18:20 +0900)]
Import PostgreSQL 11 beta3 parser.

7 years agoUnbreak pgpool_setup and regression tests against pre-10 PostgreSQL.
Tatsuo Ishii [Thu, 23 Aug 2018 12:12:29 +0000 (21:12 +0900)]
Unbreak pgpool_setup and regression tests against pre-10 PostgreSQL.

Commit 26446126f36dcd34ea9032ac934aafe63acc0eee broke pgpool_setup and
regression tests against pre-10 PostgreSQL because they unconditionally
use feature introduced in PostgreSQL 10, i.e. SCRAM authentication. To
fix this, check PostgreSQL version using initdb -v and not use
PostgreSQL 10 specific feature if PostgreSQL 9.6 or earlier is used.
In this case regression tests 020, 021 and 022 always success.

7 years agoUpdate copyright year.
Tatsuo Ishii [Wed, 22 Aug 2018 07:09:19 +0000 (16:09 +0900)]
Update copyright year.

7 years agoAdd notes regarding failover script.
Tatsuo Ishii [Wed, 22 Aug 2018 07:01:21 +0000 (16:01 +0900)]
Add notes regarding failover script.

It's not recommended to access against Pgpool-II itself from
failover/failback scripts.

7 years agoFix memory leak and typo in comments.
Tatsuo Ishii [Wed, 22 Aug 2018 04:24:08 +0000 (13:24 +0900)]
Fix memory leak and typo in comments.

7 years agoFix memory leak pointed out by Coverity.
Tatsuo Ishii [Tue, 21 Aug 2018 08:33:52 +0000 (17:33 +0900)]
Fix memory leak pointed out by Coverity.

7 years agoAdd missing new file to previous commit. V4_0_0_ALPHA1
Bo Peng [Mon, 20 Aug 2018 08:06:35 +0000 (17:06 +0900)]
Add missing new file to previous commit.

7 years agoMove pgproto header files to "include/pgproto".
Bo Peng [Mon, 20 Aug 2018 08:04:45 +0000 (17:04 +0900)]
Move pgproto header files to "include/pgproto".

7 years agoChange test file name to avoid make dist error due to too long file name.
Bo Peng [Mon, 20 Aug 2018 08:00:55 +0000 (17:00 +0900)]
Change test file name to avoid make dist error due to too long file name.

7 years agoChange distdir to include new files.
Bo Peng [Mon, 20 Aug 2018 07:25:20 +0000 (16:25 +0900)]
Change distdir to include new files.

7 years agoPrepare 4.0alpha1.
Bo Peng [Mon, 20 Aug 2018 05:36:43 +0000 (14:36 +0900)]
Prepare 4.0alpha1.

7 years agoChange follow_master_command description new master -> new primary.
Bo Peng [Mon, 20 Aug 2018 05:13:29 +0000 (14:13 +0900)]
Change follow_master_command description new master -> new primary.

7 years agoImprove 4.0 release note.
Bo Peng [Mon, 20 Aug 2018 05:07:08 +0000 (14:07 +0900)]
Improve 4.0 release note.

7 years agoAdd .gitignore to doc and doc.ja.
Bo Peng [Mon, 20 Aug 2018 04:49:44 +0000 (13:49 +0900)]
Add .gitignore to doc and doc.ja.

7 years agoAdd .gitignore to pgenc and pgproto.
Bo Peng [Mon, 20 Aug 2018 04:43:06 +0000 (13:43 +0900)]
Add .gitignore to pgenc and pgproto.
Patch provided by Jesper Pedersen.

7 years agoSome document updates for SCRAM authentication feature
Muhammad Usama [Sun, 19 Aug 2018 10:18:23 +0000 (15:18 +0500)]
Some document updates for SCRAM authentication feature

Patch contributed by Jesper Pedersen <jesper.pedersen@redhat.com>
against SCRAM branch and updated by me against master

7 years agoUse failover instead of fail-over pr fail_over
Muhammad Usama [Sun, 19 Aug 2018 09:46:49 +0000 (14:46 +0500)]
Use failover instead of fail-over pr fail_over

Fix mistakes where "fail_over" and "fail-over" were used instead of the
"failover". And that also includes a wrongly spelled configuration parameter
"fail_over_on_backend_error",
Now we throw a warning message when old config name fail_over_on_backend_error
is used instead of failover_on_backend_error,
Using the old config variable name will have no effect.

7 years agoRun pgindent.
Tatsuo Ishii [Fri, 17 Aug 2018 08:23:14 +0000 (17:23 +0900)]
Run pgindent.

Fix and unify indentation by using PostgreSQL 11's pgindent command.

7 years agoDeal with pgindent.
Tatsuo Ishii [Fri, 17 Aug 2018 04:29:54 +0000 (13:29 +0900)]
Deal with pgindent.

7 years agoAdd Pgpool-II 4.0 release note.
Bo Peng [Fri, 17 Aug 2018 05:44:05 +0000 (14:44 +0900)]
Add Pgpool-II 4.0 release note.

7 years agoFix test directory name typos.
Bo Peng [Fri, 17 Aug 2018 03:06:38 +0000 (12:06 +0900)]
Fix test directory name typos.

7 years agoAdd pgproto to Pgpool-II.
Bo Peng [Fri, 17 Aug 2018 02:56:52 +0000 (11:56 +0900)]
Add pgproto to Pgpool-II.

Now by installing pgpool, pgproto will also be installed.
Patch provided by Takuma Hoshiai.

7 years agoFeature: Add SCRAM and Certificate authentication support
Muhammad Usama [Thu, 16 Aug 2018 16:34:32 +0000 (21:34 +0500)]
Feature: Add SCRAM and Certificate authentication support

New feature to add scram and cert authentication method support in Pgpool-II.
Apart from supporting the new authentication methods the commit also includes
the following enhancements and changes in the authentication framework
of Pgpool-II

Different auth methods for frontend and backend for user session
================================================================
Now it possible to use different authentication method for client
application and backend PostgreSQL servers.
For example, a client application can use scram-sha-256 to connect to Pgpool-II
which in turn can use trust or md5 authentication to connect to
PostgreSQL backend for the same session.

Use MD5 and SCRAM without pool_passwd
=====================================
New configuration parameter allow_clear_text_frontend_auth, enables the Pgpool-II
to use clear-text-password authentication with frontend clients when pool_passwd
file does not contains the password for the connecting user.
For example: suppose PostgreSQL servers has a user named "some_user" which can
connect to database using SCRAM authentication, Now for this "some_user" to
connect to PostgreSQL using SCRAM through Pgpool-II we must have the some_user's
password stored in the pool_passwd file, but if in some case when pool_passwd does
not have the entry of "some_user" and allow_clear_text_frontend_auth is enabled
in the pgpool.conf then Pgpool-II will ask the connecting frontend to use
clear-text-password auth method for authentication, and after receiving the
password from the client, Pgpool-II will use that password to authenticate with
backend using the required SCRAM auth.

Note: allow_clear_text_frontend_auth only works when pool_hba.conf is not enabled.

Encrypted passwords in pool_passwd file
=======================================
Since the SCRAM authentication method explicitly guards against the
man-in-middle type attacks, so to use such authentication methods Pgpool-II
requires the PostgreSQL user password to authenticate with the backend.
But as storing the clear text password in the "pool_passwd" file is never a good
idea, so now you can store the AES256-CBC encrypted password in the "pool_passwd".
To store the AES encrypted password in the "pool_passwd" the password is first
encrypted using the AES256 encryption with the user provided key and then the
encrypted password is base64 encoded and AES prefix is added to
the encoded string.

New pg_enc utility to create encrypted passwords
================================================
A new utility pg_enc is added to create AES encrypted passwords. The utility
works similar in most ways as pg_md5 utility, with a some small differences,
pg_enc also requires the key for encrypting the password entries. later that
same key is required by Pgpool-II to decrypt the passwords to be used for
authentication.

Note: Pgpool-II must be build with ssl (--with-openssl) support to use
this encrypted password feature.

Providing encryption key to Pgpool-II
=====================================
If you have AES encrypted passwords stored in the pool_passwd file, then
Pgpool-II will require the decryption key to decrypt the passwords before
using them, Pgpool-II tries to read the decryption key at startup from
the pgpoolkey file.
By default the Pgpool-II will look for the pgpoolkey file in user's home
directory or the file referenced by environment variable PGPOOLKEYFILE.
You can also specify the key file using the (-k, --key-file=KEY_FILE)
command line argument to the Pgpool-II binary.

Encrypted Passwords in pgpool.conf
==================================
The commit also allows to specify the AES encrypted password in the pgpool.conf
file for healh_check_user, sr_check_user, wd_lifecheck_user and recovery_user
users, Additionally if the password field for any of these users is left blank
in pgpool conf then Pgpool-II will first try to get the password for that user
from pool_passwd file before using the empty password for the connection.
So now pgpool.conf can be made password free and single pool_passwd file can be
used to store all passwords for internal and external user connection

Documentation updates and regression test cases for the
feature are also part of the commit.
Thanks to jesperpedersen <jesper.pedersen@redhat.com> for helping
in documentation and testing for the feature

7 years agoFix too small buffer size in some configuration file process.
Tatsuo Ishii [Thu, 16 Aug 2018 06:38:33 +0000 (15:38 +0900)]
Fix too small buffer size in some configuration file process.

This was found by newer version of gcc warnings.

pool_config_variables.c: In function ‘BackendFlagsShowFunc’:
pool_config_variables.c:3809:57: warning: ‘__builtin_snprintf’ output truncated before the last format character [-Wformat-truncation=]
   snprintf(buffer, sizeof(buffer), "DISALLOW_TO_FAILOVER");
                                                         ^
In file included from /usr/include/stdio.h:862:0,
                 from pool_config_variables.c:1:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:64:10: note: ‘__builtin_snprintf’ output 21 bytes into a destination of size 20
   return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        __bos (__s), __fmt, __va_arg_pack ());
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

7 years agoImprove documetation about "black_query_pattern_list".
Bo Peng [Wed, 15 Aug 2018 00:13:11 +0000 (09:13 +0900)]
Improve documetation about "black_query_pattern_list".

7 years agoImprove pg_md5 docs and error message.
Bo Peng [Tue, 14 Aug 2018 13:43:49 +0000 (22:43 +0900)]
Improve pg_md5 docs and error message.

Patch provided by Jesper Pedersen and modified by me.

7 years agoFix that if the last character of black_query_pattern_list is not ";",
Bo Peng [Fri, 10 Aug 2018 09:12:45 +0000 (18:12 +0900)]
Fix that if the last character of black_query_pattern_list is not ";",
the last SQL pattern was ignored.

Now wether or not the last character ";" exists, the SQL patterns
will be correctly handled.

7 years agoFix document example errors about "black_query_pattern_list".
Bo Peng [Fri, 10 Aug 2018 06:22:49 +0000 (15:22 +0900)]
Fix document example errors about "black_query_pattern_list".

7 years agoAdd some comments about performance to "black_query_pattern_list" docs.
Bo Peng [Fri, 10 Aug 2018 05:02:21 +0000 (14:02 +0900)]
Add some comments about performance to "black_query_pattern_list" docs.

7 years agoAdd definition of PGLIB in regress.sh.
Bo Peng [Fri, 10 Aug 2018 04:16:02 +0000 (13:16 +0900)]
Add definition of PGLIB in regress.sh.
Patch provided by Jesper Pedersen.

7 years agoUpdate clean.sh which clean up regression test results.
Bo Peng [Fri, 10 Aug 2018 03:40:10 +0000 (12:40 +0900)]
Update clean.sh which clean up regression test results.

Patch provided by Jesper Pedersen.

7 years agoAdd .gitignore files.
Bo Peng [Fri, 10 Aug 2018 03:34:32 +0000 (12:34 +0900)]
Add .gitignore files.

Patch provided by Jesper Pedersen.

7 years agoUpdate expected data to adopt the lastest version of pgproto.
Tatsuo Ishii [Thu, 9 Aug 2018 05:01:35 +0000 (14:01 +0900)]
Update expected data to adopt the lastest version of pgproto.

7 years agoFix regression test 008.dbredirect error.
Bo Peng [Wed, 8 Aug 2018 03:42:13 +0000 (12:42 +0900)]
Fix regression test 008.dbredirect error.

7 years agoFeature: allow to specify load balance weight ratio for load balance parameters.
Bo Peng [Tue, 7 Aug 2018 01:07:24 +0000 (10:07 +0900)]
Feature: allow to specify load balance weight ratio for load balance parameters.

Add a new feature to allow to specify load balance weight ratio for
"database_redirect_preference_list" and "app_name_redirect_preference_list"
parameters.

You can specify the list of "database-name:node id(ratio)" pairs to
send SELECT queries to a particular backend node for a particular
database connection at a specified load balance ratio.
Also you can specify list of "application-name:node id(ratio)" pairs to
send SELECT queries to a particular backend node for a particular client
application connection at a specified load balance ratio.

This load balance ratio specifies a value between 0 and 1,
and the default is 1.0.

For example, by specifying "database_redirect_preference_list = 'test:1(0.5)'",
Pgpool-II will redirect 50% SELECT queries to the backend node of ID 1
for the connection to "test" database. And the other 50% SELECT queries
will be sent to other backend nodes.

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.