pgpool2.git
5 years agoDoc: add note about auto_failback
Takuma Hoshiai [Tue, 23 Jun 2020 05:46:38 +0000 (14:46 +0900)]
Doc: add note about auto_failback

If user uses replication_slot, replication slot is may deleted by
failover_command when standby node is down. In this case, pgpool
can't get replication status, so the feature of auto failback is
may not worked.

5 years agoAllow to SELECT load balance in snapshot isolation mode.
Tatsuo Ishii [Mon, 22 Jun 2020 10:59:01 +0000 (19:59 +0900)]
Allow to SELECT load balance in snapshot isolation mode.

- In an read only explicit transaction
- If outside transaction, transaction mode is read only
- In other case, check if the query is really read only SELECT.

Also modify 001.load_balance test to check snapshot isolation mode.

5 years agoFix miscount of connection_count
Takuma Hoshiai [Mon, 22 Jun 2020 02:45:47 +0000 (11:45 +0900)]
Fix miscount of connection_count

There is a possibility that  pgpool duplicate the count down of conections
when query cancel such as pg_terminate_backend() commmand.

5 years agoAdd regression test for snapshot isolation mode.
Tatsuo Ishii [Sat, 20 Jun 2020 00:36:40 +0000 (09:36 +0900)]
Add regression test for snapshot isolation mode.

To test the mode, we use two concurrent transactions generated by 2
pgbench instances. Tx A updates a row of table t1. Tx B retrieves the
row in t1 and INSERT INTO log table. If atomic visibilty is kept,
after Tx A and B finishes rows of log on node 0 and node 1 should be
identical. In fact in the snapshot isolation mode, they are
identical. On the other hand, in the existing native replication mode,
they are not identical.

Also add missing sample configuration file for the snapshot isolation
mode.

5 years agoFix bugs in snapshot isolation mode.
Tatsuo Ishii [Fri, 19 Jun 2020 23:59:57 +0000 (08:59 +0900)]
Fix bugs in snapshot isolation mode.

- Did not call si_commit_request() when starting an internal
  transaction. This led to incorrect commit counter in
  si_commit_done().

- Fix incorrect preprocessor symbol for DEBUGGING SI module.

5 years agoAllow units to be specified with configuration settings.
Muhammad Usama [Fri, 19 Jun 2020 21:44:50 +0000 (02:44 +0500)]
Allow units to be specified with configuration settings.

The bulk of the code for this feature is stolen from PostgreSQL source
so making the pgpool configuration file syntax more inline with that of PG's

Similarly, PGPOOL SHOW command now outputs units along with value

postgres=# pgpool show search_primary_node_timeout;
search_primary_node_timeout
-----------------------------
5min
(1 row)

5 years agoAdd new clustering mode "snapshot isolation mode".
Tatsuo Ishii [Fri, 19 Jun 2020 04:41:59 +0000 (13:41 +0900)]
Add new clustering mode "snapshot isolation mode".

Here's the first cut to introduce the Pangea algorythm [1].  I deicded
to add new clustering mode called "snapshot isolation mode" for
this.

[1] http://www.vldb.org/pvldb/vol2/vldb09-694.pdf

What I have done in this commit are:

- Implement Pangea algorythm for r/w transactions.
- Create docs for the new clustering mode.

Please note that to use the new clustering mode, PostgreSQL's default
transaction isolation mode must be "REPEATABLE READ" (not READ
COMMITTED nor SERIALIZABLE). At this point I tend to think that the
new feature should be marked as "experimental" since I am not
convinced that the new mode does not have any defect at the when 4.2
is released.

BTW, I have added new section "Bibliography" to give a credit to
Pangea. However it seems the rendering of it is different from what
PostgreSQL has. Can someone please help?

"Takeshi Mishima and Hiroshi Nakamura, "Pangea: An Eager Database
Replication Middleware guaranteeing Snapshot Isolation without
modification of Database Servers", Proc. VLDB Conference, Aug. 2009."

I was expecting something like this:

"[mishima2009] Pangea: An Eager Database Replication Middleware
guaranteeing Snapshot Isolation without modification of Database
Servers", "Takeshi Mishima and Hiroshi Nakamura, Proc. VLDB
Conference, Aug. 2009."

What I have not done are:

(1) Check if the transaction is read only and if so, then load balance
    it.

(2) regression test

(3) How to deal with SERIAL/sequence.

(4) Deal with extended query protocol

For (1), maybe we could have following rules:

- If it's a read only SELECT and it's not inside an explicit
  transaction, we can load balance it.

- If it's a read only SELECT and it's inside an explicit transaction,
  we can not load balance it.

The latter is different from native replication mode.

For (2) maybe we need new testing framework to give a control the
timing to give queries to backend. If you have an idea, please let me
know.

For (3) I have no idea. Please help.

Discussion: https://www.pgpool.net/pipermail/pgpool-hackers/2020-April/003580.html

5 years agoDoc: add an untranslated sentence in auto_failback.
Tatsuo Ishii [Fri, 5 Jun 2020 00:12:09 +0000 (09:12 +0900)]
Doc: add an untranslated sentence in auto_failback.

5 years agoDoc: Japanese documentation for new pcp_reload_config utility.
Tatsuo Ishii [Thu, 4 Jun 2020 03:47:01 +0000 (12:47 +0900)]
Doc: Japanese documentation for new pcp_reload_config utility.

Patch contributed by "Jianshen Zhou <zhoujianshen@highgo.com>".
Translated into Japanese by me.

5 years agoEnglish Documentation for pcp_reload_config utility
Muhammad Usama [Wed, 3 Jun 2020 16:28:50 +0000 (21:28 +0500)]
English Documentation for pcp_reload_config utility

Patch contributed by "Jianshen Zhou <zhoujianshen@highgo.com>"
and enhanced by me.

Also, contains a small update for pcp_stop_utility English doc

5 years agoFix incorrect execution of failover process
Takuma Hoshiai [Tue, 2 Jun 2020 08:04:30 +0000 (17:04 +0900)]
Fix incorrect execution of failover process

This problem happen by executing pg_terminate_backend command with native replication.
In addition, add regression test for pg_terminate_backend command.

5 years agoDoc: fix typo.
Bo Peng [Mon, 1 Jun 2020 00:04:07 +0000 (09:04 +0900)]
Doc: fix typo.

5 years agoDoc: fix typo in failover document.
Tatsuo Ishii [Sat, 30 May 2020 05:27:59 +0000 (14:27 +0900)]
Doc: fix typo in failover document.

Also fix inappropriate xref.

5 years agoFix 004.watchdog test crash on IBM Z hardware.
Tatsuo Ishii [Wed, 27 May 2020 06:24:07 +0000 (15:24 +0900)]
Fix 004.watchdog test crash on IBM Z hardware.

When watchdog copies primary node id on the master watchdog node, it
did not consider the case that primary node id on the shared memory
(Req_info->primary_node_id) is remaining in the initial value (-2),
which causes out of range subscript access to backend info
array. Interestingly accessing array[-2] does not crash on intel
architecture but does crash IBM Z hardware. Anyway the reason why the
value remains in -2 is that the regression test is performed in raw
mode. I think the code block handling the primary node id should only
be executed in streaming or logical replication mode.

Bug report and patch provided by gregn123, slightly modified by me.
Mantis bug report: https://www.pgpool.net/mantisbt/view.php?id=614

5 years agoFix 021.pool_passwd_auth test failure.
Tatsuo Ishii [Sun, 24 May 2020 02:35:52 +0000 (11:35 +0900)]
Fix 021.pool_passwd_auth test failure.

In the previous commit, path to pg_enc command was not set.

5 years agoDoc: mention about environment variable PGPOOLKEYFILE in pg_enc command.
Tatsuo Ishii [Sat, 23 May 2020 07:42:06 +0000 (16:42 +0900)]
Doc: mention about environment variable PGPOOLKEYFILE in pg_enc command.

pg_enc command actually recognizes the environment variable.  The
implementation has been doing so.

5 years agoEnhance scram/md5 auth regression test to use AES256 encrypted password.
Tatsuo Ishii [Sat, 23 May 2020 03:59:47 +0000 (12:59 +0900)]
Enhance scram/md5 auth regression test to use AES256 encrypted password.

021.pool_passwd_auth used plain text password in pool_passwd. AES256
encrypted password is more appropriate for the real world use case.

5 years agoDoc: add explanation about .pgpoolkey.
Tatsuo Ishii [Sat, 23 May 2020 03:17:05 +0000 (12:17 +0900)]
Doc: add explanation about .pgpoolkey.

Also add indexes for .pgpoolkey and PGPOOLKEYFILE.

5 years agoDoc: Improve the description of wd_priority.
Bo Peng [Fri, 22 May 2020 07:32:27 +0000 (16:32 +0900)]
Doc: Improve the description of wd_priority.

Patch is provided by Kenichiro Tanaka.

5 years agoAdd mention about hostssl/hostnossl to pool_hba.conf sample file.
Tatsuo Ishii [Fri, 22 May 2020 01:58:48 +0000 (10:58 +0900)]
Add mention about hostssl/hostnossl to pool_hba.conf sample file.

Although hostssl/hostnossl are supported, pool_hba.conf comment did
not mention about it.

5 years agoNew PCP utility 'pcp_reload_pgpool' for reloading the pgpool configuration
Muhammad Usama [Thu, 21 May 2020 16:32:38 +0000 (21:32 +0500)]
New PCP utility 'pcp_reload_pgpool' for reloading the pgpool configuration

The utility also supports the newly added cluster scope for reloading the
configurations on all Pgpool-II nodes part of the watchdog cluster.

Documentation updates for the utility are still remaining.

Patch contributed by "Jianshen Zhou <zhoujianshen@highgo.com>"
and enhanced by me.

5 years agoDoc: Add release-note.
Bo Peng [Mon, 18 May 2020 20:16:27 +0000 (05:16 +0900)]
Doc: Add release-note.

5 years agoChange relative path of SSL files to configuration directory.
Bo Peng [Mon, 18 May 2020 12:12:25 +0000 (21:12 +0900)]
Change relative path of SSL files to configuration directory.

Patch is created by Umar Hayat and Japanese documentation is added by me.

5 years agoDoc: Add note about if_up_cmd and if_down_cmd command.
Bo Peng [Sun, 10 May 2020 00:27:48 +0000 (09:27 +0900)]
Doc: Add note about if_up_cmd and if_down_cmd command.

5 years agoDoc: add --scope option to Japanese pcp_stop_pgpool manual.
Tatsuo Ishii [Wed, 6 May 2020 06:48:32 +0000 (15:48 +0900)]
Doc: add --scope option to Japanese pcp_stop_pgpool manual.

Also add mention about the default value of --mode and --scope.

5 years agoFix: 0000608: pgpool ssl front end accept all ciphers. not working as expected.
Muhammad Usama [Tue, 5 May 2020 19:30:33 +0000 (00:30 +0500)]
Fix: 0000608: pgpool ssl front end accept all ciphers. not working as expected.

SSL  cipher_list needed to be set for server-side SSL context
instead for the client-side context.

5 years agoNew feature: cluster scope for pcp_stop_pgpool utility command
Muhammad Usama [Mon, 4 May 2020 11:38:39 +0000 (16:38 +0500)]
New feature: cluster scope for pcp_stop_pgpool utility command

Make pcp_stop_pgpool utility to terminate (optional) all the pgpool nodes in the
watchdog cluster
For that purpose added  "--scope=cluster/local" option in the pcp_stop_pgpool
utility to set the scope of the command. The scope could be either
'local' or 'cluster'

Along with that, the commit adds the infrastructure in watchdog for broadcasting
the custom commands over the watchdog network. This will make it easier to
implement the --scope=cluster for other PCP utilities.

5 years agoSome code reorganization
Muhammad Usama [Mon, 4 May 2020 11:35:35 +0000 (16:35 +0500)]
Some code reorganization

While working on the pcp_stop_pgpool command to implement cluster mode,
I realized that we have a lot of clutter in a few source files. Especially
pool.h header file. So I also did some code reorganization and added a
bunch of new includefiles in the hope to reduce the size of pool.h and
also get rid of too many global functions.

Along the way, I found out there are few other files that need a little
shredding as well, src/main/pgpool_main.c and src/protocol/child.c are at
the top of this wanted to be trimmed list. So as part of this commit.

I have taken a few things related to internal commands
(interface between the child processes can and Pgpool-II main process)
from pgpool_main.c file and moved them into new "src/main/pool_internal_comms.c"

Similarly, src/protocol/child.c had and still has so many functions that do
not fit with the personality of child.c file. So I have moved some of the
stuff related to DB functions info src/protocol/pool_pg_utils.c file.

Having done that I think this is still not enough and we may require another
round ( if someoneis willing to work on it) of a source file reorganization.

5 years agoFix extended query tests.
Tatsuo Ishii [Mon, 4 May 2020 03:46:53 +0000 (12:46 +0900)]
Fix extended query tests.

Commit https://git.postgresql.org/gitweb/?p=pgpool2.git;a=commit;h=eee4c86c03546abe4e33396c808c8425c23a443c
broke extra scripts because it added Bind message log if log_per_node_statement is enabled.
Discussion: https://www.pgpool.net/pipermail/pgpool-hackers/2020-May/003611.html

5 years agoImprove process status of extend query
Takuma Hoshiai [Tue, 28 Apr 2020 08:50:19 +0000 (17:50 +0900)]
Improve process status of extend query

Previously, pgpool status is incorrect with extend query.
For example, when query is executing, but process status
is idle. This fix can display process status correctly.
If 'Execute' message is received, pgpool display process
status the same as Simple query.

For example:
  user databse SELECT

In addition, fix log_statement bug. Previously, statement
using extend query is not logged by log_statement parameter.
It was improved in this commit.

Other, log_per_node_statement can log query with BIND message.

5 years agoDowngrade too verbose authentication logs.
Tatsuo Ishii [Sun, 26 Apr 2020 02:20:06 +0000 (11:20 +0900)]
Downgrade too verbose authentication logs.

When frontend authentication succeeds with clear text password and md5
authentication, message is out with log priority LOG. This floods
Pgpool-II log on busy systems. To fix this, downgrade the LOG message
to DEBUG1. Note that CERT auth related log level is still
LOG. Downgrading it causes regression 024 and 029 failure.

Discussion:
https://www.pgpool.net/mantisbt/view.php?id=606
https://www.pgpool.net/pipermail/pgpool-general/2020-April/007064.html

5 years agoRemove duplicate global data.
Tatsuo Ishii [Sun, 26 Apr 2020 00:58:50 +0000 (09:58 +0900)]
Remove duplicate global data.

This causes a link error on some system (Fedra 32).

Discussion: https://www.pgpool.net/pipermail/pgpool-hackers/2020-April/003593.html

5 years agoFix unnecessary checks.
Tatsuo Ishii [Thu, 23 Apr 2020 12:32:28 +0000 (21:32 +0900)]
Fix unnecessary checks.

Patch contributed by sherlockcpp.
Discussion: https://www.pgpool.net/pipermail/pgpool-general/2020-April/007062.html

5 years agoDoc: fix typo.
Tatsuo Ishii [Thu, 23 Apr 2020 05:32:28 +0000 (14:32 +0900)]
Doc: fix typo.

Patch contributed by Umar Hayat.
Discussion: https://www.pgpool.net/pipermail/pgpool-hackers/2020-April/003587.html

5 years agoForgot to push file in previous commit.
Tatsuo Ishii [Mon, 20 Apr 2020 05:25:09 +0000 (14:25 +0900)]
Forgot to push file in previous commit.

Previous commit: https://git.postgresql.org/gitweb?p=pgpool2.git;a=commitdiff;h=589a81960939102fb620b395b8cd45434d6aa4bc

5 years agoFix unnecessary free pointed out by Coverity.
Tatsuo Ishii [Sat, 18 Apr 2020 04:03:44 +0000 (13:03 +0900)]
Fix unnecessary free pointed out by Coverity.

Since buf is already checked whether it is NULL or not, it is not
necessary to check the variable before freeing it.

5 years agoFix array access overrun pointed out by Coverity.
Tatsuo Ishii [Sat, 18 Apr 2020 03:50:47 +0000 (12:50 +0900)]
Fix array access overrun pointed out by Coverity.

5 years agoFix for segmentation fault in PCP processor: Bug 598
Muhammad Usama [Thu, 16 Apr 2020 10:01:30 +0000 (15:01 +0500)]
Fix for segmentation fault in PCP processor: Bug 598

The crash was caused by an unconditionally pfree on buf without verifyingif it
was actually allocated or not. And freeing the but was not actually required at
the first places since the associated MemoryContext always gets resets anyway
after each loop iteration.

reference: https://www.pgpool.net/mantisbt/view.php?id=598

5 years agoDoc: fix doc mistakes.
Bo Peng [Wed, 15 Apr 2020 05:37:54 +0000 (14:37 +0900)]
Doc: fix doc mistakes.

5 years ago Fix a warning message is never output in watchdog.
Tatsuo Ishii [Wed, 15 Apr 2020 04:27:18 +0000 (13:27 +0900)]
 Fix a warning message is never output in watchdog.

Patch provided by sherlockcpp.
Discussion: https://www.pgpool.net/pipermail/pgpool-general/2020-April/007014.html

5 years agoFix for Coverity scan defect: 1424125 Resource leak
Muhammad Usama [Tue, 14 Apr 2020 12:19:16 +0000 (17:19 +0500)]
Fix for Coverity scan defect: 1424125 Resource leak

5 years agoDoc: fix typo in failover.sgml.
Tatsuo Ishii [Sun, 12 Apr 2020 09:15:05 +0000 (18:15 +0900)]
Doc: fix typo in failover.sgml.

Patch provided by sherlockcpp.

5 years agoFix pool show command code.
Tatsuo Ishii [Sat, 11 Apr 2020 05:34:40 +0000 (14:34 +0900)]
Fix pool show command code.

Enhance common function send_complete_and_ready() so that it uses
local variable in more sane way.

Also fix unnecessary limitation of number of rows affected by the
command.

Patch provided by sherlockcpp and Tatsuo Ishii.

5 years agoFix compile warning.
Bo Peng [Tue, 7 Apr 2020 11:10:39 +0000 (20:10 +0900)]
Fix compile warning.

5 years agoDoc: fix typo.
Tatsuo Ishii [Tue, 7 Apr 2020 23:43:54 +0000 (08:43 +0900)]
Doc: fix typo.

5 years agoMinor improvement in configure script
Muhammad Usama [Tue, 7 Apr 2020 16:01:16 +0000 (21:01 +0500)]
Minor improvement in configure script

While checking for libpq the configure script was not honoring the LDFLAGS
settings.This sometimes breaks the configure when libraries are not present at
the defaultlocations# Please enter the commit message for your changes

5 years agoAllow to set application name parameter of log_line_prefix in more cases.
Tatsuo Ishii [Tue, 7 Apr 2020 05:08:21 +0000 (14:08 +0900)]
Allow to set application name parameter of log_line_prefix in more cases.

%a in log_line_prefix was only be set if application_name is specified
 in startup message. Now it is possible to set application_name if it
 is set in the connection parameter or SET command.

Also set hard coded application_name in various internal process so
that admins can easily recognize each log line belonging to which
process.

Discussion: https://www.pgpool.net/pipermail/pgpool-hackers/2020-April/003572.html

5 years agoFeature: Add support for an user/password input file to pg_md5.
Bo Peng [Sun, 5 Apr 2020 18:28:15 +0000 (03:28 +0900)]
Feature: Add support for an user/password input file to pg_md5.

Allow to use an input file containing multiple username/password pairs.

Patch created by Umar Hayat, and Japanese document added by Bo Peng.
Discussion: https://www.pgpool.net/pipermail/pgpool-hackers/2020-March/003527.html

5 years agoDoc: fix document typos.
Bo Peng [Sun, 5 Apr 2020 16:10:37 +0000 (01:10 +0900)]
Doc: fix document typos.

Patch is provided by sherlockcpp@foxmail.com.

5 years agoFix for [pgpool-general: 6951] Fix-condition-tok-is-always-true
Muhammad Usama [Mon, 6 Apr 2020 09:12:00 +0000 (14:12 +0500)]
Fix for [pgpool-general: 6951] Fix-condition-tok-is-always-true

Fix contributed by: sherlockcpp <sherlockcpp@foxmail.com>

5 years agoAdd support for SSL passphrase.
Tatsuo Ishii [Wed, 1 Apr 2020 05:52:32 +0000 (14:52 +0900)]
Add support for SSL passphrase.

Add more regression test file missed in previous commit.

5 years agoAdd regression test for previous commit.
Tatsuo Ishii [Tue, 31 Mar 2020 07:59:57 +0000 (16:59 +0900)]
Add regression test for previous commit.

5 years agoFix bug with query cache.
Tatsuo Ishii [Tue, 31 Mar 2020 07:58:01 +0000 (16:58 +0900)]
Fix bug with query cache.

If an execute message is issued right after Sync message and query
cache hits, Pgpool-II hangs in inject_cached_message() because there's
no data to be read from backend. Fix is, change the code block which
checks the data availability in backend to the beginning of the loop
from the end of the loop. Also teach is_cache_empty() to call
pool_is_suspend_reading_from_frontend() so that if we suspend reading
from frontend. If so, return that cache is empty even if there's data
in frontend cache to receive a ready for query message from backend.

5 years agoAdd support for SSL passpharse.
Tatsuo Ishii [Mon, 30 Mar 2020 03:32:53 +0000 (12:32 +0900)]
Add support for SSL passpharse.

Add regression test file missed in the previous commit.

5 years agoAdd support for SSL passphrase.
Tatsuo Ishii [Mon, 30 Mar 2020 03:23:37 +0000 (12:23 +0900)]
Add support for SSL passphrase.

Authors: Umar Hayat. Small modification and Japanese document by Tatsuo Ishii.
Dicussion: https://www.pgpool.net/pipermail/pgpool-hackers/2020-March/003548.html

5 years agoMore attempt to fix 024.cert_auth failure.
Tatsuo Ishii [Mon, 23 Mar 2020 22:27:18 +0000 (07:27 +0900)]
More attempt to fix 024.cert_auth failure.

Author: Umar Hayat
Discussion: https://www.pgpool.net/pipermail/pgpool-hackers/2020-March/003562.html

5 years agoFix 024.cert_auth regression failure on CentOS6.
Tatsuo Ishii [Thu, 19 Mar 2020 14:20:48 +0000 (23:20 +0900)]
Fix 024.cert_auth regression failure on CentOS6.

Recent addition of CRL support causes regression failure of
024.cert_auth only on CentOS6, because of the default key length
difference in different OpenSSL versions. Fix is, explicitly specify
key length.

Author: Umar Hayat
Discussion: https://www.pgpool.net/pipermail/pgpool-hackers/2020-March/003560.html

5 years agoAdd support for an user/password input file to pg_enc.
Tatsuo Ishii [Wed, 18 Mar 2020 05:31:11 +0000 (14:31 +0900)]
Add support for an user/password input file to pg_enc.

Allow to use an input file containing multiple username/password pairs.

Patch created by Umar Hayat, along with Japanese document by Tatsuo Ishii.
Discussion: https://www.pgpool.net/pipermail/pgpool-hackers/2020-March/003543.html

5 years agoFix long standing bug in backend flag configuration processing module.
Tatsuo Ishii [Mon, 16 Mar 2020 02:19:15 +0000 (11:19 +0900)]
Fix long standing bug in backend flag configuration processing module.

Recent commit revealed bugs in backend flag (backend_flag0 etc.)
configuration processing module. This leads to massive build farm
failure.

1) The default value for backend flag is ALWAYS_MASTER. This should be
"" (empty string).

2) The final value of the backend flag is the last default for the
flag. This is plain wrong (see BackendFlagsAssignFunc()). The result
value should be OR'ed value of each default value since backend_flag
is a bit data.

Probably we should back port the fix to the other stable branches but
I would like to confirm that the fix does not add bugs or side
effects before doing that.

Discussion:
https://www.pgpool.net/pipermail/pgpool-hackers/2020-March/003553.html

5 years agoAdd support for SSL CRL (Certificate Revocation List).
Tatsuo Ishii [Sat, 14 Mar 2020 02:54:38 +0000 (11:54 +0900)]
Add support for SSL CRL (Certificate Revocation List).

Patch created by Umar Hayat, along with Japanese document by Tatsuo
Ishii.
Discussion: https://www.pgpool.net/pipermail/pgpool-hackers/2020-February/003505.html

5 years agoFix problems in watchdog processing json data.
Tatsuo Ishii [Fri, 13 Mar 2020 01:36:17 +0000 (10:36 +0900)]
Fix problems in watchdog processing json data.

Comment on the patch from the author:

In the watchdog source code (src/watchdog/wd_json_data.c), there are some instances of bad handling of values read from json data.
For example:
1) The boolean pool configuration settings "load_balance_mode" and "master_slave_mode" are read using json_get_int_value_for_key(), resulting in 4-bytes being written into their location within the POOL_CONFIG, yet (being bool) they are only 1-byte long. This corrupts the values of the structure members following them.
2) Similarly, when parsing node function json data, "Flags" is read using json_get_int_value_for_key(), resulting in 4-bytes being written into an "unsigned char flags" variable on the stack, overwriting 3-bytes of stack memory following it. On a big-endian system (e.g. Solaris-sparc or Linux for IBM Z), this causes regression test "013.watchdog_failover_require_consensus" to fail, since 0 is written into Flags, rather than the intended value which is in the least significant byte of the int value written.

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

Patch author:
Greg Nancarrow (Fujitsu Australia)

5 years agoFix SCRAM auth handling bug.
Tatsuo Ishii [Thu, 12 Mar 2020 06:49:35 +0000 (15:49 +0900)]
Fix SCRAM auth handling bug.

Comment on the patch from the author:

The code is currently checking if "len <= 8", but len is is
network-byte-order (big-endian).  It is surely meant to be checking
"message_length" instead, which is "len" coverted to host-byte-order
(see previous line of code).  Under (Intel) Linux, which is
little-endian, the value of "len" will be a large number and thus
render the current error condition check ineffective [for example, in
one case that I debugged, an example value of len was 134217728
(0x08000000), meaning that message_length was actually 8].
Additionally, it seems the "<=" check should actually be "<", based on
the length values that I see when debugging this code.

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

Patch author:
Greg Nancarrow (Fujitsu Australia)

5 years agoFix possible data inconsistency in native replication mode.
Tatsuo Ishii [Wed, 11 Mar 2020 04:05:43 +0000 (13:05 +0900)]
Fix possible data inconsistency in native replication mode.

There is a long standing bug with native replication mode. As reported
in pgpool-general, it is possible to lost sync of database if slave
DB's postgres process is killed. This is due to an oversight in
read_packets_and_process().

In replication mode if slave server's postgres is killed, then local
backend status is set to down.

*(my_backend_status[i]) = CON_DOWN;

So next DDL/DML in the same session is only issued to master node (and
other slave if there are multiple slave nodes). Of course this leads
to serious data inconsistency problem because in native replication
mode all DB nodes must receive DDL/DML at the same time.

Fix is triggering failover in thiscase.

Discussions:
https://www.pgpool.net/pipermail/pgpool-general/2020-March/006954.html
https://www.pgpool.net/pipermail/pgpool-hackers/2020-March/003540.html

5 years agoUpdate src/Makefile.in.
Bo Peng [Sat, 7 Mar 2020 11:40:04 +0000 (20:40 +0900)]
Update src/Makefile.in.

5 years agoUnify master_slave_mode, master_slave_sub_mode and replication_mode into backend_clus...
Tatsuo Ishii [Mon, 9 Mar 2020 10:18:08 +0000 (19:18 +0900)]
Unify master_slave_mode, master_slave_sub_mode and replication_mode into backend_clustering_mode.

Previous "running mode" concept was confusing and hard to
understand. For example, each running mode is actually mutually
exclusive but it was possible to use some of modes altogether. Of
course the result was chaos.

Now the "running mode" is renamed to "clustering mode" and the
configuration variable is unified into single
"backend_clustering_mode". It is an enum type and possible values are:
streaming_replication', 'native_replication', 'logical_replication',
'slony' or 'raw'.

Documents are changed accordingly.

Note that old config variables are still remaining in
pool_config_variables.c. So it is possible to read old config
variables and replace them into new config variable
backend_clustering_mode to mitigate the migration pain from the old
configs to new configs, but I am not sure that is worth the problem.

5 years agoUpdate pool_config.c.
Bo Peng [Thu, 5 Mar 2020 23:00:18 +0000 (08:00 +0900)]
Update pool_config.c.

5 years agoFix watchdog ping probes fail with long hostnames due to small buffer.
pengbo@sraoss.co.jp [Thu, 5 Mar 2020 22:45:51 +0000 (07:45 +0900)]
Fix watchdog ping probes fail with long hostnames due to small buffer.

per 516.

5 years agoDoc: enhance installation documents.
Tatsuo Ishii [Mon, 2 Mar 2020 07:12:08 +0000 (16:12 +0900)]
Doc: enhance installation documents.

Add "Planning" section so that uses can grasp a big picture of
installation.

5 years agoDoc: explicitly mention that Pgpool-II needs 3 nodes to avoid split brain.
Tatsuo Ishii [Thu, 27 Feb 2020 05:00:24 +0000 (14:00 +0900)]
Doc: explicitly mention that Pgpool-II needs 3 nodes to avoid split brain.

5 years agoDoc: enghance description of failover.
Tatsuo Ishii [Thu, 27 Feb 2020 00:44:43 +0000 (09:44 +0900)]
Doc: enghance description of failover.

5 years agoFix last status changed timestamp is not set.
Tatsuo Ishii [Wed, 26 Feb 2020 01:31:37 +0000 (10:31 +0900)]
Fix last status changed timestamp is not set.

If there's no status file or -D is specified when starting up
Pgpool-II, the last status changed timestamp was not set and
pcp_node_info command for example did not show the proper timestamp,
rather showed 1970/1/1, which is the Unix timestamp epoch.

Note that correct timestamp is set once clients connect to Pgpool-II
because at that time the status is changed from "waiting" to "up". So
the phenomena is only observed before any client connects to the
server.

5 years agoAdd pgpool_adm's pcp_health_check_stats function.
Tatsuo Ishii [Tue, 25 Feb 2020 08:05:16 +0000 (17:05 +0900)]
Add pgpool_adm's pcp_health_check_stats function.

5 years agoUpdate Makefile.in files.
Bo Peng [Tue, 25 Feb 2020 00:24:51 +0000 (09:24 +0900)]
Update Makefile.in files.

5 years agoAdd pcp_healt_check_stats command.
Tatsuo Ishii [Mon, 24 Feb 2020 13:29:24 +0000 (22:29 +0900)]
Add pcp_healt_check_stats command.

5 years agoUpdate copyright year.
Bo Peng [Sat, 22 Feb 2020 00:59:10 +0000 (09:59 +0900)]
Update copyright year.

5 years agoDoc: add release-notes.
Bo Peng [Wed, 19 Feb 2020 06:19:53 +0000 (15:19 +0900)]
Doc: add release-notes.

5 years agoDoc: update japanese documentation.
Bo Peng [Wed, 19 Feb 2020 06:12:35 +0000 (15:12 +0900)]
Doc: update japanese documentation.

5 years agoDisallowing the quorum aware failover option for the native replication mode.
Muhammad Usama [Tue, 18 Feb 2020 12:23:10 +0000 (17:23 +0500)]
Disallowing the quorum aware failover option for the native replication mode.

In native replication mode, Pgpool-II is responsible for replicating the data
on all backend nodes, and if a node becomes quarantined then Pgpool-II stops
sending the writes to that node and when that quarantined node becomes available
again there is no way to figure out which portion of data was not replicated
during the quarantine period. This is dangerous since it can cause
data inconsistency.

So as per the discussion, we reached the conclusion to disallow failover require
consensus and quorum existence with the native replication mode so that backend
node should never get into quarantine when Pgpool-II is configured in the
replication mode.

5 years agoFix rewriting query errors in native replication mode.
Bo Peng [Tue, 18 Feb 2020 08:43:23 +0000 (17:43 +0900)]
Fix rewriting query errors in native replication mode.

per bug551.

5 years agoDoc: clarify the session disconnection conditions while failover.
Tatsuo Ishii [Tue, 18 Feb 2020 01:28:39 +0000 (10:28 +0900)]
Doc: clarify the session disconnection conditions while failover.

5 years agoUpdate pgpool.spec file.
Bo Peng [Mon, 17 Feb 2020 13:36:42 +0000 (22:36 +0900)]
Update pgpool.spec file.

5 years agoDoc: Fix documentation error regarding delegate_IP.
Bo Peng [Mon, 17 Feb 2020 13:14:53 +0000 (22:14 +0900)]
Doc: Fix documentation error regarding delegate_IP.

5 years agoUpdate pgpool-recovery function definitions.
Tatsuo Ishii [Wed, 12 Feb 2020 04:01:22 +0000 (13:01 +0900)]
Update pgpool-recovery function definitions.

5 years agoDoc: enhance description of enable-shared-relcache parameter.
Tatsuo Ishii [Wed, 12 Feb 2020 02:46:52 +0000 (11:46 +0900)]
Doc: enhance description of enable-shared-relcache parameter.

Discussion: [pgpool-general: 6833] Re: Using standby pgpool instances
https://www.pgpool.net/pipermail/pgpool-general/2020-January/006891.html

5 years agoFix child process segfault after reload if "health_check_database" is empty.
Bo Peng [Wed, 12 Feb 2020 01:03:13 +0000 (10:03 +0900)]
Fix child process segfault after reload if "health_check_database" is empty.

per bug571.

5 years agoSuppress unnecessary error message when there's no standby server.
Tatsuo Ishii [Mon, 10 Feb 2020 10:04:48 +0000 (19:04 +0900)]
Suppress unnecessary error message when there's no standby server.

Even of there's no standby server anymore, worker process keeps on
checking result row from pg_stat_replication(). If
pg_stat_replication() returns no row, the worker process complained it
every sr_check_period and the log was flooded by them. To prevent this
get_query_result() is changed to return -2 if there's no row in the
result. Also the error message in get_query_result() is downgraded
from LOG to DEBUG1. If -2 is returned and number of active standby is
less than 1 the caller does not complain any more.

5 years agoFix oversight to adopt PostgreSQL 12.
Tatsuo Ishii [Sat, 8 Feb 2020 10:39:14 +0000 (19:39 +0900)]
Fix oversight to adopt PostgreSQL 12.

From PostgreSQL 12 WAL dir is renamed to "pg_wal". pgpool_setup should
have dealt with this.

5 years agoFix error messsage typo
Takuma Hoshiai [Tue, 4 Feb 2020 02:47:45 +0000 (11:47 +0900)]
Fix error messsage typo

5 years agoDoc: fix some phrases
Takuma Hoshiai [Tue, 4 Feb 2020 02:34:40 +0000 (11:34 +0900)]
Doc: fix some phrases

5 years agoDoc: fix doc typo.
Bo Peng [Tue, 4 Feb 2020 00:04:05 +0000 (09:04 +0900)]
Doc: fix doc typo.

5 years agoRemove debug lines.
Tatsuo Ishii [Wed, 29 Jan 2020 08:02:24 +0000 (17:02 +0900)]
Remove debug lines.

5 years agoDoc: fix typo in show pool_health_check_stats manual.
Tatsuo Ishii [Wed, 29 Jan 2020 00:31:44 +0000 (09:31 +0900)]
Doc: fix typo in show pool_health_check_stats manual.

5 years agoDoc: fix online-recovery doc errors.
Bo Peng [Tue, 28 Jan 2020 06:49:54 +0000 (15:49 +0900)]
Doc: fix online-recovery doc errors.

5 years agoFeature: Check if socket file exists at startup and remove them if PID file doesn...
Bo Peng [Tue, 28 Jan 2020 06:20:46 +0000 (15:20 +0900)]
Feature: Check if socket file exists at startup and remove them if PID file doesn't exist.

If the previuos socket files exist, pgpool startup fails due to bind() failire.
This commit is to remove socket files at startup if PID file doesn't exist.

Also, I found some messages are effectively ignorede because log system is not yet initialized at start point.
I changed them to standard fprintf(stderr...).

5 years agoChange the sample follow_master.sh scipt %M %H paramater's order.
Bo Peng [Tue, 28 Jan 2020 02:18:00 +0000 (11:18 +0900)]
Change the sample follow_sh scipt %M %H paramater's order.

5 years agoDoc: change the follow_master_command %M %H paramater's order.
Bo Peng [Tue, 28 Jan 2020 01:58:11 +0000 (10:58 +0900)]
Doc: change the follow_master_command %M %H paramater's order.

5 years agoDoc: add pool_health_check_stats.sgml.
Tatsuo Ishii [Mon, 27 Jan 2020 01:26:01 +0000 (10:26 +0900)]
Doc: add pool_health_check_stats.sgml.

Also tweak healthcheck.sgml and pool_health_check_stats.sgml (English).

5 years agoDoc: add show pool_health_check_stats reference manual.
Tatsuo Ishii [Sun, 26 Jan 2020 11:16:43 +0000 (20:16 +0900)]
Doc: add show pool_health_check_stats reference manual.

Forgot in the previous commit.

5 years agoAdd health check statistics collection/display feature.
Tatsuo Ishii [Sun, 26 Jan 2020 11:01:18 +0000 (20:01 +0900)]
Add health check statistics collection/display feature.

The health check process now collects statistics data such as number
of total health check performed, number of health check retry count
and health check duration and so on in the shared memory area. This
commit also adds new "show pool_health_check_stats" SQL
command. Corresponding PCP command and pgpool_adm function will be
added in subsequent commit.

5 years agoFix occasional 008.dbredirect failure.
Tatsuo Ishii [Sun, 19 Jan 2020 11:36:48 +0000 (20:36 +0900)]
Fix occasional 008.dbredirect failure.

It seems "sleep 1" after reload is not enough. Let's sleep 10.