pgpool2.git
5 years agoUse pg_config to get PostgreSQL lib path and add this path to LD_LIBRARY_PATH environ...
Bo Peng [Mon, 17 Aug 2020 04:46:36 +0000 (13:46 +0900)]
Use pg_config to get PostgreSQL lib path and add this path to LD_LIBRARY_PATH environment paramater in regress.sh.

5 years agoFix pgpool_setup to get correct PostgreSQL version.
Bo Peng [Sun, 16 Aug 2020 04:15:56 +0000 (13:15 +0900)]
Fix pgpool_setup to get correct PostgreSQL version.

5 years agoFix pgpool_setup so that native replication mode and SI mode works with PostgreSQL 12.
Tatsuo Ishii [Sat, 15 Aug 2020 09:14:11 +0000 (18:14 +0900)]
Fix pgpool_setup so that native replication mode and SI mode works with PostgreSQL 12.

In these mode, it created recovery.conf which is not allowed in
PostgreSQL 12.

5 years agoFix oversight in connection_life_time fix.
Tatsuo Ishii [Sat, 15 Aug 2020 03:37:39 +0000 (12:37 +0900)]
Fix oversight in connection_life_time fix.

Commit 39eb90fe199d03253b99bec38d85c40f66aa55ab did not consider the case
when node is down connection struct is NULL. As a result, segfault occurred.

5 years agoCheck panic or fatal error by using 'V' token if available.
Tatsuo Ishii [Fri, 14 Aug 2020 05:15:22 +0000 (14:15 +0900)]
Check panic or fatal error by using 'V' token if available.

To identify panic or fatal message in is_panic_or_fatal_error(), 'S'
token was used.  However 'S' could be localized and simply comparing
"PANIC" or "FATAL" with the message may not work. Instead 'V' should be
used if possible because it's not localized.

5 years agoFix 031.connection_life_time regression test failure.
Bo Peng [Fri, 14 Aug 2020 02:18:25 +0000 (11:18 +0900)]
Fix 031.connection_life_time regression test failure.

5 years agoBefore running regression test clean the remaining processes and sockets.
Bo Peng [Thu, 13 Aug 2020 06:35:34 +0000 (15:35 +0900)]
Before running regression test clean the remaining processes and sockets.

5 years agoDoc: mention that ssl_ciphers only affects to TLS 1.2 and lower.
Tatsuo Ishii [Wed, 12 Aug 2020 11:17:44 +0000 (20:17 +0900)]
Doc: mention that ssl_ciphers only affects to TLS 1.2 and lower.

The changes are imported from PostgreSQL manual.

5 years agoAt pgpool startup, if pid file exists, truncate pid file to zero length before writing.
Bo Peng [Wed, 12 Aug 2020 07:07:04 +0000 (16:07 +0900)]
At pgpool startup, if pid file exists, truncate pid file to zero length before writing.

Patch is created by maliangzhu.

5 years agoDoc: fix failback_command documetation error.
Bo Peng [Tue, 11 Aug 2020 14:58:51 +0000 (23:58 +0900)]
Doc: fix failback_command documetation error.

5 years agoMake RPMs to include pcp.conf and pool_hba.conf sample files.
Bo Peng [Tue, 11 Aug 2020 09:40:34 +0000 (18:40 +0900)]
Make RPMs to include pcp.conf and pool_hba.conf sample files.

5 years agoFix connection_life_time does not work.
Tatsuo Ishii [Tue, 11 Aug 2020 01:26:43 +0000 (10:26 +0900)]
Fix connection_life_time does not work.

If master node is not 0 (this could happen in the case when primary
node is not 0 in streaming replication mode for example), pgpool
failed to find connection_life_time timer because the timer was set
only in virtual_master_node, which could be changed after session ends
since query context is not there any more.

To fix this, connection_life_time timer is set to all valid nodes.

Regression test is also added.

Discussion: https://www.pgpool.net/pipermail/pgpool-general/2020-August/007242.html

5 years agoRevert "Fix pgpool_setup problem with -r option and PostgreSQL 12."
Tatsuo Ishii [Fri, 7 Aug 2020 00:43:34 +0000 (09:43 +0900)]
Revert "Fix pgpool_setup problem with -r option and PostgreSQL 12."

This reverts commit 566a48e8c5a1ed8efbcef143322ac1bea54882f9.

Since pg_rewind is supported in Pgpool-II 3.7 or before, the fix is
not necessary.

5 years agoFix query cache bug.
Tatsuo Ishii [Wed, 5 Aug 2020 05:42:18 +0000 (14:42 +0900)]
Fix query cache bug.

If EXPLAIN ANALYZE takes data-modifying SQL, it must invalidate query
cache, but actually it was missed.

Author: Hou, Zhijie
Discussion: https://www.pgpool.net/pipermail/pgpool-hackers/2020-August/003767.html

5 years agoFix pgpool_setup problem with -r option and PostgreSQL 12.
Tatsuo Ishii [Wed, 5 Aug 2020 01:47:06 +0000 (10:47 +0900)]
Fix pgpool_setup problem with -r option and PostgreSQL 12.

pgpool_setup -r uses pg_rewind if it's possible. After rewinding,
pgpool_setup failed to create standby.signal file, which is required in
PostgreSQL 12 or later, on the recovered target node. As a result, the
recovered node booted up as a primary server, rather than a standby
server.

Discussion: https://www.pgpool.net/mantisbt/view.php?id=624

5 years agoChange PCP UNIX_DOMAIN_PATH of RPM package to "/var/run/postgresql".
Bo Peng [Fri, 31 Jul 2020 00:45:39 +0000 (09:45 +0900)]
Change PCP UNIX_DOMAIN_PATH of RPM package to "/var/run/postgresql".

5 years agoDoc: clarify what the command actual does.
Tatsuo Ishii [Tue, 28 Jul 2020 02:36:11 +0000 (11:36 +0900)]
Doc: clarify what the command actual does.

Discussion: https://www.pgpool.net/pipermail/pgpool-hackers/2020-July/003744.html
Reviewed-by: Bo Peng
5 years agoRename src/redhat/pgpool_rhel7.sysconfig to src/redhat/pgpool_rhel.sysconfig to make...
Bo Peng [Mon, 27 Jul 2020 02:40:25 +0000 (11:40 +0900)]
Rename src/redhat/pgpool_rhel7.sysconfig to src/redhat/pgpool_rhel.sysconfig to make this file available on RHEL8/CentOS8.

5 years agoFix typos.
Bo Peng [Wed, 22 Jul 2020 01:23:13 +0000 (10:23 +0900)]
Fix typos.

Patch is created by Lu, Chenyang.

5 years agoDoc: fix typo in memqcache doc.
Tatsuo Ishii [Thu, 16 Jul 2020 10:46:33 +0000 (19:46 +0900)]
Doc: fix typo in memqcache doc.

Patch contributed by Hou, Zhijie.
Discussion: https://www.pgpool.net/pipermail/pgpool-general/2020-July/007204.html

5 years agoPrevent data modifying CTE to be cached.
Tatsuo Ishii [Tue, 14 Jul 2020 13:07:59 +0000 (22:07 +0900)]
Prevent data modifying CTE to be cached.

Data modifying CTE was mistakenly treated as normal read only CTE and
result query was created.  As a result subsequent CTE was not
executed.

Problem reported and patch created by Hou, Zhijie.
Subtle changes to the regression test by me.
Discussion: https://www.pgpool.net/pipermail/pgpool-hackers/2020-July/003705.html

5 years agoFix pgpool hang in a corner case.
Tatsuo Ishii [Thu, 9 Jul 2020 00:11:03 +0000 (09:11 +0900)]
Fix pgpool hang in a corner case.

It is possible that an "out of band" message from backend has been
read into buffer at the time when a ready for query message is
processed. If the messages are from all backends, there should be no
problem because ProcessBackendResponse() will read the messages from
all backends by using read_kind_from_backend(). However there could be
a corner case: 1) If the message is coming from only one of backend
(this could happen when recovery conflict or backend receiving SIGTERM
and so on) and 2) the message is already in the backend read
buffer. In this case pgpool will hang in pool_read() called by
read_kind_from_backend() at either: 1)
read_kind_from_one_backend(frontend, backend, (char *) &kind,
MASTER_NODE_ID) (the message is not coming from master backend) or 2)
pool_read(CONNECTION(backend, i), &kind, 1) (the message is not coming
from other than master).

Note If the message is not in the buffer, there should be no problem
since read_packets_and_process() will take care that "out of band"
messages.

The solution is, read and discard such a message in ReadyforQuery(),
emitting log to make sure that the read buffer is empty after
returning from ReadyForQuery(). (remember that unless the ready for
query message is returned to frontend, the frontend will not issue
next query and there's should be no response from backend except the
out of band messages).

If the message was FATAL, the backend will disconnect to pgpool. So
next time pgpool should notice that the connection is closed anyway.

For the master branch, probably we should treat that kind of FATAL
message in a same way as read_packets_and_process() already does. This
requires some code refactoring and I would like to leave the job
separated from this commit.

5 years agoFix per_node_error_log() so that it respects unread parameter.
Tatsuo Ishii [Wed, 8 Jul 2020 01:25:12 +0000 (10:25 +0900)]
Fix per_node_error_log() so that it respects unread parameter.

per_node_error_log() unconditionally set the "unread" parameter to
true when it should have respected the unread parameter given by user.
It seems all callers to per_node_error_log() set the unread parameter
to true anyway.  The only exception is pool_do_auth. As far as testing
test 03[0-4] regression tests, the change is ok.

In summary this change will not affect to Pgpool-II but bug is bug.

5 years agoFix lazy coding of ereport in pgpool_adm extension.
Tatsuo Ishii [Tue, 7 Jul 2020 03:35:10 +0000 (12:35 +0900)]
Fix lazy coding of ereport in pgpool_adm extension.

Before it was coded that ereport's "domain" parameters were just "0".
This generated lots of compiler warning. To fix this give plausible
error codes to each ereport call.

5 years agoDoc: fix typo in the explanation of pgpool_adm.
Tatsuo Ishii [Mon, 29 Jun 2020 23:07:12 +0000 (08:07 +0900)]
Doc: fix typo in the explanation of pgpool_adm.

Patch provided by sherlockcpp.
Discussion: https://www.pgpool.net/pipermail/pgpool-hackers/2020-June/003679.html

5 years agoFix typo in query cache module.
Tatsuo Ishii [Mon, 29 Jun 2020 00:35:23 +0000 (09:35 +0900)]
Fix typo in query cache module.

5 years agoFix startup packet reading process.
Tatsuo Ishii [Fri, 26 Jun 2020 11:46:33 +0000 (20:46 +0900)]
Fix startup packet reading process.

If there are parameters other than "user", "database" and
"application_name", reading startup packet resulted in failing to
extract user: "no PostgreSQL user name specified in startup
packet". This was found while a frontend was trying to speak
replication protocol by using "replication=database".

Discussion: https://www.pgpool.net/pipermail/pgpool-general/2020-June/007162.html

5 years agoFix miscount of connection_count
Takuma Hoshiai [Mon, 22 Jun 2020 02:41:54 +0000 (11:41 +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 agoMerge branch 'V3_7_STABLE' of ssh://git.postgresql.org/pgpool2 into V3_7_STABLE
Tatsuo Ishii [Thu, 4 Jun 2020 02:32:33 +0000 (11:32 +0900)]
Merge branch 'V3_7_STABLE' of ssh://git.postgresql.org/pgpool2 into V3_7_STABLE

5 years agoFix segmentation fault when application name is included in log_line_prefix.
Tatsuo Ishii [Thu, 4 Jun 2020 02:29:33 +0000 (11:29 +0900)]
Fix segmentation fault when application name is included in log_line_prefix.

In Pgpool-II 4.1 or before log_line_prefix unconditionally tried to
fetch the application name from backend info (slots array).
Unfortunately in certain corner cases this was not possible. When
connection_cache is off, pgpool resets connection slots
(session->backend->slots[]) at the time when clients sends termination
request to pgpool. If log_min_messages is DEBUG5, pgpool wants to emit
this log message:

         DEBUG: RESET ALL CONFIG VARIABLE

which caused a segfault because pgpool tried to refer NULL pointer.
Fix is, if session->backend->slots[] is NULL, do not try to fetch
application name from the variable.

Per bug 615.

5 years agoFix incorrect execution of failover process
Takuma Hoshiai [Tue, 2 Jun 2020 08:08:00 +0000 (17:08 +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 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 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 agoPrepare 3.7.14 V3_7_14 V3_7_14_RPM
Bo Peng [Tue, 19 May 2020 09:38:20 +0000 (18:38 +0900)]
Prepare 3.7.14

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 agoRemove more duplicate global data.
Tatsuo Ishii [Sat, 16 May 2020 00:14:09 +0000 (09:14 +0900)]
Remove more 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 agoRemove duplicate global data.
Tatsuo Ishii [Sun, 26 Apr 2020 01:22:22 +0000 (10:22 +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 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:40:23 +0000 (14:40 +0900)]
Doc: fix typo.

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

5 years agoFix for segmentation fault in PCP processor: Bug 598
Muhammad Usama [Thu, 16 Apr 2020 10:09:14 +0000 (15:09 +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 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 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 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 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 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 agoMerge branch 'V3_7_STABLE' of ssh://git.postgresql.org/pgpool2 into V3_7_STABLE
Tatsuo Ishii [Wed, 11 Mar 2020 04:13:28 +0000 (13:13 +0900)]
Merge branch 'V3_7_STABLE' of ssh://git.postgresql.org/pgpool2 into V3_7_STABLE

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 agoFix watchdog ping probes fail with long hostnames due to small buffer.
pengbo [Thu, 5 Mar 2020 22:39:58 +0000 (07:39 +0900)]
Fix watchdog ping probes fail with long hostnames due to small buffer.

per 516.

5 years agoRevert "Fix last status changed timestamp is not set."
Tatsuo Ishii [Wed, 26 Feb 2020 09:16:18 +0000 (18:16 +0900)]
Revert "Fix last status changed timestamp is not set."

This reverts commit a9f5a9b4e3f081822e454e7dab04a64b0e398e24.

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 agoUpdate copyright year.
Bo Peng [Sat, 22 Feb 2020 00:59:10 +0000 (09:59 +0900)]
Update copyright year.

5 years agoUpdate pgpool.spec file. V3_7_13 V3_7_13_RPM
Bo Peng [Wed, 19 Feb 2020 07:44:16 +0000 (16:44 +0900)]
Update pgpool.spec file.

5 years agoPrepare 3.7.13.
Bo Peng [Wed, 19 Feb 2020 06:38:15 +0000 (15:38 +0900)]
Prepare 3.7.13.

5 years agoDoc: Update doc version.
Bo Peng [Wed, 19 Feb 2020 06:25:42 +0000 (15:25 +0900)]
Doc: Update doc version.

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 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 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 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:51:33 +0000 (11:51 +0900)]
Fix error messsage typo

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 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 agoFix 001.load_balance failure caused by previous commit.
Tatsuo Ishii [Sat, 11 Jan 2020 11:49:29 +0000 (20:49 +0900)]
Fix 001.load_balance failure caused by previous commit.

5 years agoAttempt to fix 001.load_balance test failure.
Tatsuo Ishii [Fri, 10 Jan 2020 05:50:38 +0000 (14:50 +0900)]
Attempt to fix 001.load_balance test failure.

It is likely that sleep time after reload was not enough. Change them
from 1 second to 10 seconds.

5 years agoMore fix for occasional regression test 003.failover failure.
Tatsuo Ishii [Sat, 4 Jan 2020 01:30:22 +0000 (10:30 +0900)]
More fix for occasional regression test 003.failover failure.

Comparison between show pool_node result and expected file failed
because of replication delay (the expected file set 0 to replication
delay column.) Fix is, disabling replication delay.

5 years agoFix occasional regression test 003.failover failure.
Tatsuo Ishii [Tue, 31 Dec 2019 03:06:50 +0000 (12:06 +0900)]
Fix occasional regression test 003.failover failure.

The test compares the result of show pool_nodes against pre-computed
expected text file. After primary node goes down and old standby
promotes to primary, it is possible that streaming replication worker
process stores the replication state (async, streaming) in shared
memory before the failover but fails to update the state after the
failover. Fix is, replace "async", "streaming" with space characters
in the result file to match the expected file.

5 years agoFix occasional regression test failure of 008.dbredirect.
Tatsuo Ishii [Fri, 27 Dec 2019 00:13:59 +0000 (09:13 +0900)]
Fix occasional regression test failure of 008.dbredirect.

In the test several databases are created and subsequent tests expect
that those databases have been already replicated. But it is possible
that the replication has not been done at that point and makes the
test fails. Fix is, add check the existence of database and if it's
not replicated, sleep for a while and retry it (up to 5 times).

5 years agoFix occasional regression test failure of 008.dbredirect.
Tatsuo Ishii [Thu, 26 Dec 2019 05:13:08 +0000 (14:13 +0900)]
Fix occasional regression test failure of 008.dbredirect.

In the test pgbench -i is performed. It is possible that this bring
streaming replication delay, which in turn disturbs app/db
redirecting test. Fix is, disabling delay_threshold.

5 years agoFix replication delay worker segfault when application_name is an empty string.
Tatsuo Ishii [Thu, 12 Dec 2019 07:33:18 +0000 (16:33 +0900)]
Fix replication delay worker segfault when application_name is an empty string.

The process calls do_query() to obtain the query result against
pg_stat_replication_view.  If user sets application_name to an empty
string, the result data row packet length will be 0. However
do_query() did not consider the length == 0 case, which resulted in
giving NULL pointer to strcmp() which is called from the worker
process. That means the bug is not specific to this case (a new
feature added in Pgpool-II 4.1) but it potentially affects many other
places where do_query() gets called, although it had not been reported
in the field. So this fix should be applied to all supported branches.

Per bug 565.

5 years agoFix a display of parameter when using PGPOOL SHOW.
Takuma Hoshiai [Tue, 3 Dec 2019 01:54:07 +0000 (10:54 +0900)]
Fix a display of parameter when using PGPOOL SHOW.

If show backend_flag parameter by PGPOOL SHOW command, 'ALWAYS_MASTER' config
wasn't displayed by it.

5 years agoFix missing syslog setting. V3_7_12_RPM2
Bo Peng [Mon, 18 Nov 2019 09:04:32 +0000 (18:04 +0900)]
Fix missing syslog setting.

5 years agoPrepare 3.7.12-2.
Bo Peng [Mon, 18 Nov 2019 01:07:15 +0000 (10:07 +0900)]
Prepare 3.7.12-2.

5 years agoFix the missing syslog in configure file.
Bo Peng [Fri, 15 Nov 2019 07:39:50 +0000 (16:39 +0900)]
Fix the missing syslog in configure file.

per bug557.

5 years agoDoc: update release-note. V3_7_12 V3_7_12_RPM
Bo Peng [Thu, 31 Oct 2019 00:58:53 +0000 (09:58 +0900)]
Doc: update release-note.

5 years agoPrepare 3.7.12.
Bo Peng [Thu, 31 Oct 2019 00:32:05 +0000 (09:32 +0900)]
Prepare 3.7.12.

5 years agoDoc: update doc version.
Bo Peng [Thu, 31 Oct 2019 00:24:05 +0000 (09:24 +0900)]
Doc: update doc version.

5 years agoFix incorrect query rewrite in replication mode.
Bo Peng [Thu, 31 Oct 2019 00:11:03 +0000 (09:11 +0900)]
Fix incorrect query rewrite in replication mode.

5 years agoDoc: Add release-note.
Bo Peng [Wed, 30 Oct 2019 23:56:15 +0000 (08:56 +0900)]
Doc: Add release-note.

5 years agoAdd RHEL 8 support.
Bo Peng [Wed, 30 Oct 2019 09:10:04 +0000 (18:10 +0900)]
Add RHEL 8 support.

5 years agoFix incorrect query rewrite in replication mode.
Bo Peng [Fri, 25 Oct 2019 08:22:22 +0000 (17:22 +0900)]
Fix incorrect query rewrite in replication mode.
For example:
- CREATE TABLE t1 AS SELECT now();
- SELECT now() INTO t1;
- WITH ins AS ( INSERT INTO t1 SELECT now()) SELECT;

5 years agoFix health check time out.
Tatsuo Ishii [Mon, 21 Oct 2019 04:44:37 +0000 (13:44 +0900)]
Fix health check time out.

Heal check time out could happen in several places:

1) connect system call
2) select system call
3) read system call

1) was ok but in 2) and 3) it was possible that it could go into
infinite loop in Pgpool-II 3.7 or later. This was due to a mistake
when health check process was modified to be separate process in 3.7,
and back patched to 3.7 and above.

Discussion:
https://www.pgpool.net/pipermail/pgpool-hackers/2019-October/003458.html
https://www.pgpool.net/pipermail/pgpool-hackers/2019-October/003459.html

5 years agoDoc: add failover_command description
Takuma Hoshiai [Tue, 15 Oct 2019 09:38:21 +0000 (18:38 +0900)]
Doc: add failover_command description

Add more exaplain about a case that failover_command execute when it
does not have a new master node. In this case, special characters in
failover_command are specified fixed values.

5 years agoFix memory leaks pointed out by coverity.
Tatsuo Ishii [Tue, 15 Oct 2019 02:59:58 +0000 (11:59 +0900)]
Fix memory leaks pointed out by coverity.

5 years agoMerge branch 'V3_7_STABLE' of ssh://git.postgresql.org/pgpool2 into V3_7_STABLE
Tatsuo Ishii [Tue, 15 Oct 2019 00:26:43 +0000 (09:26 +0900)]
Merge branch 'V3_7_STABLE' of ssh://git.postgresql.org/pgpool2 into V3_7_STABLE

5 years agoFix for miscellaneous watchdog issues.
Muhammad Usama [Mon, 14 Oct 2019 10:03:08 +0000 (15:03 +0500)]
Fix for miscellaneous watchdog issues.

The commit takes care of following reports in watchdog
-- pgpool-general: 6672 Query (watchdog split brain)
-- 0000547: We need to do arping again after recovering from split-brain.

Basically in a bid to solve these issue, the commit makes blow mentioned
behavioral changes in watchdog

1-- If life check reports a watchdog node is dead but the watchdog core is still
able to connect and communicate with it without any problem, the watchdog core
was getting into the dilemma of whether to consider it as a lost or an alive node.

Fix:
With this commit, the lost nodes reported by life-check (external or internal)
are treated as hard failures even when the node is reachable from the watchdog
core. and that node can only become alive if it is restarted or secondly if
life-check informs that the node has become alive again.
The second type of node failures that can mark the watchdog node as lost, occurs
when a watchdog node fails to respond to the messages sent to it or frequent
errors occur on its socket. These errors are detected by the watchdog core
itself and get recovered automatically whenever that node becomes responsive
again. Apart from this the commit also made some improvements in the area of
detecting such internal errors.

2-- Standby nodes were too aggressive in reacting to the coup attempt
(when another watchdog node tries to become a master while valid master already
exists in the cluster) or to the possibility of split-brain (when it receives
"I AM MASTER" message from the node that is not the master as per the standby
node record). In both these situations, the standby nodes used to re-join
the master node in the hope to find the true master.
But that didn't prove to be a very good strategy, since it may lead to
influence the selection of true master node when the true-master and
fake-master nodes get into a fight to retain the master node status.
As one of the things true and fake master compares is the number of connected
standby nodes. And if during the fight the standby leaves the current master
to re-join the cluster the standby node count on the true master becomes
lower than actual and that affects its chances of winning the elections.

Fix:
The commit makes the standby nodes more lean-back and to actively reject the
nodes that are trying to become a master in the presence of the true-master
and avoid re-joining the cluster until it is absolutely necessary.

3-- The third problem was in the case of network partitioning or partial
life-check failure (when node A thinks node B is lost but node B thinks
node A is not lost) In this case the kicked out standby node was too
aggressive in trying to connect to the master or become a master itself
so that potentially put the unnecessary burden on the network and the
cluster nodes.

Fix:
So the fix for this issue is to make the isolated node a bit calm and wait
between trying to connect to master or become a master. For that purpose,a new
WD_NETWORK_ISOLATION state is added to the state machine, which just adds a
delay between successive tries of becoming a master. The node can only go into
this state when it comes to knowing that it is marked as lost on the current
master and gets out of it when it gets an indication that life-check on the
remote node has informed that node is alive again or secondly it gets out of
it after 10 seconds anyway.

Finally, Because creating the partial or complete network failures scenario is
very difficult so the commit also adds a watchdog debug aid similar to the
health-check debug to simulate different scenarios.

To enable the watchdog-debug aid the Pgpool-II needs to be compiled with 
WATCHDOG_DEBUG=1" flag ($make WATCHDOG_DEBUG=1)

Once compiled with debug aid enabled, you can put the command in
pgpool_logdir->watchdog_debug_requests file to test different scenarios.

e.g.

$ echo "KILL_ALL_COMMUNICATION" > logdir/watchdog_debug_requests
$ echo "KILL_ALL_SENDERS" >> logdir/watchdog_debug_requests

The current list of commands that are supported by watchdog debug aid are

DO_NOT_REPLY_TO_BEACON <= Standby node stops replying master node beacon messages
            while this line is present in the watchdog_debug_requests file
DO_NOT_SEND_BEACON <= Master node stops sending beacon messages to standby nodes
            while this line is present in the watchdog_debug_requests file
KILL_ALL_COMMUNICATION <= Watchdog stops all communication with all nodes
            while this line is present in the watchdog_debug_requests file
KILL_ALL_RECEIVERS  <= Watchdog ignores messages of all node
            while this line is present in the watchdog_debug_requests file
KILL_ALL_SENDERS  <= Watchdog stops sending messages to all nodes
            while this line is present in the watchdog_debug_requests file

5 years agoDoc: add note to trusted_servers.
Tatsuo Ishii [Fri, 11 Oct 2019 00:52:53 +0000 (09:52 +0900)]
Doc: add note to trusted_servers.

"Please note that you should not assign PostgreSQL servers to this
parameter." This should have been noted since there is at least one
user who actually did it.

5 years agoUpdate chanelog.
Bo Peng [Thu, 10 Oct 2019 06:13:09 +0000 (15:13 +0900)]
Update chanelog.

5 years agoUpdate pgpool.spec to support PostgreSQL 12.
Bo Peng [Thu, 10 Oct 2019 05:52:49 +0000 (14:52 +0900)]
Update pgpool.spec to support PostgreSQL 12.

5 years agoUpdate src/redhat/pgpool_socket_dir.patch.
Bo Peng [Thu, 10 Oct 2019 04:58:32 +0000 (13:58 +0900)]
Update src/redhat/pgpool_socket_dir.patch.

5 years agoFix assorted ancient v2 protocol bugs.
Tatsuo Ishii [Thu, 10 Oct 2019 01:01:08 +0000 (10:01 +0900)]
Fix assorted ancient v2 protocol bugs.

- In v2 code path, extract_message() pfrees memory which was returned
  from pool_read_string(). This is plain wrong and could cause sefault
  since the memory returned by it is being managed by pool_stream
  modules.

- In v2 code path pool_process_notice_message_from_one_backend() added
  "NOTICE:" to the log message. This is not necessary as the part is
  already included in the message.

- In v2 code path pool_extract_error_message() did not prepare unread
  data correctly. This caused subsequent
  pool_process_notice_message_from_one_backend() produces empty
  message, read_kind_from_backend() failure.

5 years agoFix extended query communication in do_query()
Takuma Hoshiai [Tue, 8 Oct 2019 07:02:01 +0000 (16:02 +0900)]
Fix extended query communication in do_query()

do_query() didn't send Describe message to PostgreSQL.
It didn't use strcasecmp() but strcasecmp() when check if query is SELECT.

5 years agoFix problem that syslog_facility don't change by reload
Takuma Hoshiai [Tue, 8 Oct 2019 04:08:25 +0000 (13:08 +0900)]
Fix problem that syslog_facility don't change by reload

The cause is macro definition mistake. This fix unify macro definition, and delete old test code to use vsyslog().
Reported in bug 548.

5 years agoFix inappropriate ereport call in VALID_BACKEND.
Tatsuo Ishii [Fri, 4 Oct 2019 04:52:19 +0000 (13:52 +0900)]
Fix inappropriate ereport call in VALID_BACKEND.

VALID_BACKEND (more precisely pool_virtual_master_db_node_id) macro
emitted message if pgpool is performing failover/failback:

ereport(WARNING,
(errmsg("failover/failback is in progress"),
errdetail("executing failover or failback on backend"),
 errhint("In a moment you should be able to reconnect to the database")));

This could be called within signal handlers and
POOL_SETMASK(&BlockSig)/POOL_SETMASK(&UnBlockSig) was called to block
an interrupt because ereport is not reentrant. However it is possible
that callers have already called POOL_SETMASK, and this could result
unwanted signal unblock.

Fix is, removing ereport and POOL_SETAMASK all together. This results
in removing the message above but we have no choice.

I found the problem while investigating regression
055.backend_all_down failure but of course the bug could have bitten
users in other places.

5 years agoFix for Coverity warnings in watchdog and lifecheck
Muhammad Usama [Thu, 3 Oct 2019 14:53:44 +0000 (19:53 +0500)]
Fix for Coverity warnings in watchdog and lifecheck