pgpool2.git
6 years agoAdd execute permission to extended-query-test/extra_scripts.
Bo Peng [Wed, 3 Jul 2019 03:51:23 +0000 (12:51 +0900)]
Add execute permission to extended-query-test/extra_scripts.

6 years agoChange config type of relcache_query_target from string to enum.
Tatsuo Ishii [Wed, 3 Jul 2019 00:05:55 +0000 (09:05 +0900)]
Change config type of relcache_query_target from string to enum.

This parameter is implemented as enum, so change samples and docs
accordingly.

6 years agoMake shutdownall to wait for completion of shutdown of Pgpool-II.
Tatsuo Ishii [Tue, 2 Jul 2019 09:40:11 +0000 (18:40 +0900)]
Make shutdownall to wait for completion of shutdown of Pgpool-II.

It was observed that regression test occasionally failed because
previous does not completely finished before next test started. To fix
the problem, make shutdownall script generated by pgpool_setup to wait
for completion of shutdown of Pgpool-II.

6 years agoDoc: enhance performance docs.
Tatsuo Ishii [Tue, 2 Jul 2019 05:09:54 +0000 (14:09 +0900)]
Doc: enhance performance docs.

6 years agoDoc: add more explanation for quorum failover of watchdog.
Tatsuo Ishii [Tue, 2 Jul 2019 04:53:56 +0000 (13:53 +0900)]
Doc: add more explanation for quorum failover of watchdog.

Also add newer descriptions to Japanese doc added by English doc.

6 years agoChange check_temp_table's type to enum.
Tatsuo Ishii [Tue, 2 Jul 2019 02:27:58 +0000 (11:27 +0900)]
Change check_temp_table's type to enum.

It was actually implemented as 'enum' rather than 'string'. So change
all docs and sample configuration files.

Also allow to specify on/off for backward compatibility.

6 years agoDoc: mention that in raw mode or load_balance_mode = off case for relation cache.
Tatsuo Ishii [Tue, 2 Jul 2019 00:37:38 +0000 (09:37 +0900)]
Doc: mention that in raw mode or load_balance_mode = off case for relation cache.

In this case queries for relation cache will not be sent.

6 years agoDown grade LOG to DEBUG5 in sent message module.
Tatsuo Ishii [Tue, 2 Jul 2019 00:08:57 +0000 (09:08 +0900)]
Down grade LOG to DEBUG5 in sent message module.

The log was added in commit 56a6b6a72, but in some cases it is
disturbing users.

Discussion: [pgpool-general: 6620] Fwd: A lot of "checking zapping sent message" in log

6 years agoAdd test case for 'trace' to 026.temp_table's test.sh.
Tatsuo Ishii [Mon, 1 Jul 2019 22:25:05 +0000 (07:25 +0900)]
Add test case for 'trace' to 026.temp_table's test.sh.

Commit 7a0471bb for test.sh forgot to test 'trace' case.

6 years agoDow grade some LOG messages to DEBUG1 in the temp table trace module.
Tatsuo Ishii [Mon, 1 Jul 2019 22:16:51 +0000 (07:16 +0900)]
Dow grade some LOG messages to DEBUG1 in the temp table trace module.

6 years agoDoc: fix typo.
Tatsuo Ishii [Mon, 1 Jul 2019 04:59:18 +0000 (13:59 +0900)]
Doc: fix typo.

6 years agofeature: Disable load balance after a SELECT having functions specified in black...
Bo Peng [Mon, 1 Jul 2019 03:50:49 +0000 (12:50 +0900)]
feature: Disable load balance after a SELECT having functions specified in black/white function list.

In Pgpool-II 4.0 or earlier, if we set "disable_load_balance_on_write = transaction",
when a write query is issued inside an explicit truncation,
subsequent queries should be sent to primary only until the
end of this transactionin in order to avoid the replication
delay.

However, the SELECTs having write functions specified in black_function_list
are not regarded as a write query and the subsequent read queries are still load balanced.

This commit will disable load balance after a SELECT having functions
specified in black/white function list.

6 years agoDoc: change check_temp_table Japanese docs.
Tatsuo Ishii [Sat, 29 Jun 2019 23:03:10 +0000 (08:03 +0900)]
Doc: change check_temp_table Japanese docs.

This is due to recent change to English doc of the part.

Also enhance docs to add literal tag to string parameters.

6 years agoAdd new method to check temporary table.
Tatsuo Ishii [Thu, 27 Jun 2019 05:49:34 +0000 (14:49 +0900)]
Add new method to check temporary table.

Checking temporary tables are slow because it needs to lookup system
catalogs. To eliminate the lookup, new method to trace CREATE TEMP
TABLE/DROP TABLE is added. For this purpose a linked list is added to
session context. In the list, information of creating/dropping temp
tables (not yet committed) and created/dropped temp tables (committed
or aborted) is kept. By looking up the list, it is possible to decide
whether given table is a temporary or not.

However it is impossible to trace the table creation in functions and
triggers. thus the new method does not completely replace existing
method and choice of method are given by changing check_temp_table
type from boolean to string.

"catalog": existing method (catalog lookup, same as check_temp_table = on)
"trace":   the proposed new way
"none":    no temp table checking (same as check_temp_table = off)

6 years agoReduce internal queries against system catalogs.
Tatsuo Ishii [Wed, 26 Jun 2019 01:31:15 +0000 (10:31 +0900)]
Reduce internal queries against system catalogs.

Currently the relcache module issues 7+ queries to obtain various info
from PostgreSQL system catalogs. Some of them are necessary for
Pgpool-II to work with multiple version of PostgreSQL.

Idea is, if we already know the version of PostgreSQL, we can
eliminate some of queries. For example, we need to know if
pg_namespace exists and for this purpose we send a query against
pg_class. But if we know that pg_namespace was introduced in
PostgreSQL 7.3, we do not need to inquire pg_class.

To implement this, new function:
PGVersion *
Pgversion(POOL_CONNECTION_POOL * backend)

is added and "SELECT version()" is used to get PostgreSQL's major and
minor version number (the minor version is not used for now). The
query itself is cached using relcache infrastructure. Plus Pgversion()
has its own cache using static memory. Thus obtaining PostgreSQL
version is quite fast for the second or later call to the function.

In my testing with "select * from t1" issues 7 queries. After the
patch, it reduces to 3. The remaining queries are:

- to know if it's a temporary table or not.
- to know if it's a unlogged table or not.
- to know if it's a system catalog table or not.

Discussion: [pgpool-hackers: 3344] Reducing query issued by relcache

6 years agoFix regression test 023 ssl_connection
Takuma Hoshiai [Tue, 25 Jun 2019 06:09:37 +0000 (15:09 +0900)]
Fix regression test 023 ssl_connection

If TLS1.3 was used by openssl, this test failed.
This mistake is due to #51bc494aaa7fd191e14038204d18effe2efb0ec8 .

6 years agoFix mistake introduced in the previous commit.
Tatsuo Ishii [Mon, 24 Jun 2019 13:13:18 +0000 (22:13 +0900)]
Fix mistake introduced in the previous commit.

6 years agoFix segfault when "samenet" is specified in pool_hba.conf.
Tatsuo Ishii [Mon, 24 Jun 2019 01:57:34 +0000 (10:57 +0900)]
Fix segfault when "samenet" is specified in pool_hba.conf.

When "samenet" is specified, SockAddr_cidr_mask(struct
sockaddr_storage *mask, char *numbits, int family) gets called with
numbits == NULL. However the function was not prepared for
it. Originally the function was imported from PostgreSQL. When the bug
was fixed in PostgreSQL, unfortunately the fix was not applied to
Pgpool-II. This commit applies the same fix as PostgreSQL.

Discussion: [pgpool-general: 6601] Pgpool-II + hba + samenet = segfault in libc-2.24.so

6 years agoAllow to route relcache queries to load balance node.
Tatsuo Ishii [Thu, 20 Jun 2019 04:06:27 +0000 (13:06 +0900)]
Allow to route relcache queries to load balance node.

Queries to build relcache entries were always sent to master (primary)
node. This is usually good because we could eliminate the bad effect
of replication delay. However if users want to lower the load of
master node, it would be nice if we could route the queries to other
than master node. This patch introduces new parameter
"relache_query_target". If it is set to 'load_balance_node', relcache
queries will be routed to load balance node.  If it is set to
'master', the queries are routed to master node, which is same as
before (this is the default).

6 years agodoc: Fix documentation typos.
Bo Peng [Thu, 20 Jun 2019 03:53:40 +0000 (12:53 +0900)]
doc: Fix documentation typos.

6 years agodoc: Fix documentation typo.
Bo Peng [Wed, 19 Jun 2019 01:59:59 +0000 (10:59 +0900)]
doc: Fix documentation typo.

6 years agodoc: Fix documentation errors in follow_master.sh script.
Bo Peng [Wed, 19 Jun 2019 01:49:33 +0000 (10:49 +0900)]
doc: Fix documentation errors in follow_sh script.

6 years agoDoc: fix typo in performance section.
Tatsuo Ishii [Tue, 11 Jun 2019 22:18:11 +0000 (07:18 +0900)]
Doc: fix typo in performance section.

6 years agoSupport ECDH key exchange with SSL
Takuma Hoshiai [Tue, 18 Jun 2019 06:02:38 +0000 (15:02 +0900)]
Support ECDH key exchange with SSL

Pgpool-II is supported ECDH key exchange with SSL connections.
Add new parameter 'ssl_ecdh_curve' and 'ssl_dh_params_file' to use
ECDH key exchange. The user can use more secure communication with
SSL as with PostgreSQL.

6 years agoFix health check process is not shutting down in certain cases.
Tatsuo Ishii [Tue, 11 Jun 2019 04:47:42 +0000 (13:47 +0900)]
Fix health check process is not shutting down in certain cases.

When watchdog detects fatal events, including not reaching to
trusted_servers, watchdog suicides with POOL_EXIT_FATAL exit status
code. In this case the parent of watchdog, the pgpool main process's
SIGCHILD handler reaper() exits and on_exit call back calls
system_will_go_down(), which in turn calls terminate_all_children().
Problem is, terminate_all_children() forgot to kill health check
process. This commit fixes that.

Also there are some not well behaving codings are enhanced.

Back patched to 3.7, when the bug was introduced.

6 years agoFix to deal with backslashes according to the config of standard_conforming_strings
Bo Peng [Fri, 7 Jun 2019 08:19:37 +0000 (17:19 +0900)]
Fix to deal with backslashes according to the config of standard_conforming_strings
in native replication mode.

per bug467.

6 years agoAllow to use MD5 hashed password in health_check_password and sr_check_password.
Tatsuo Ishii [Fri, 7 Jun 2019 07:50:39 +0000 (16:50 +0900)]
Allow to use MD5 hashed password in health_check_password and sr_check_password.

If they are left blank (empty string), then pool_passwd is consulted.

6 years agoDoc: add more description to pcp_node_info manual.
Tatsuo Ishii [Sun, 2 Jun 2019 03:29:09 +0000 (12:29 +0900)]
Doc: add more description to pcp_node_info manual.

To some of items be correctly displayed, sr_check_user needs more privilege.

6 years agoDoc: add description to pg_md5 man page how to show pool_passwd ready string.
Tatsuo Ishii [Sun, 2 Jun 2019 02:40:40 +0000 (11:40 +0900)]
Doc: add description to pg_md5 man page how to show pool_passwd ready string.

Sometimes it is necessary to just show md5 hash string suitable for
pool_passwd, without adding an entry to pool_passwd.

6 years agoFix segfault of worker process if sr_check_user does not have enough privilege.
Tatsuo Ishii [Wed, 29 May 2019 17:33:39 +0000 (02:33 +0900)]
Fix segfault of worker process if sr_check_user does not have enough privilege.

If sr_check_user does not have enough privilege, selecting on
pg_stat_replication returns some columns to be NULL, which caused a
segfault.

6 years agoDocumentation updates to reflect the changed behaviour of quarantined nodes.
Muhammad Usama [Tue, 28 May 2019 09:30:21 +0000 (14:30 +0500)]
Documentation updates to reflect the changed behaviour of quarantined nodes.

Mentioning about the resignation of watchdog-master when primary backend gets in
quarantine on it, and the continuous health checking of quarantined nodes.

6 years agoSecond part for [pgpool-hackers: 3295] duplicate failover request ...fix
Muhammad Usama [Sun, 26 May 2019 20:59:06 +0000 (01:59 +0500)]
Second part for [pgpool-hackers: 3295] duplicate failover request ...fix

As per the discussion on the thread [pgpool-hackers: 3295] we came to the
conclusion, that the master watchdog node should resign from master
responsibilities if the primary backend node gets into quarantine state on that.

The commit implements the said behaviour by making the master/coordinator watchdog
node resign from its status if it fails to get the consensus for the quarantined
primary node failover, with in FAILOVER_COMMAND_FINISH_TIMEOUT(15) seconds.

When the watchdog master resigns, because of quarantined primary node its
wd_priority is decreased to (-1), so that it should get the least preference
in the next election for the master/coordinator node selection. And once the
election is concluded the wd_priority for the node gets restored to the
original configured value.

In case of failed consensus for standby node failover no action is taken.

6 years agoEnhancing the debugging/testing aid for health check.
Muhammad Usama [Sun, 26 May 2019 20:46:38 +0000 (01:46 +0500)]
Enhancing the debugging/testing aid for health check.

To cater the continuous health check on quarantine nodes the commit extends
the check_backend_down_request() function to check for nodes that are marked
as "already_down" in the backend_down_request file. This should fix
013.watchdog_failover_require_consensus test case, that started failing
after 3dd1cd3f15287ee6bb8b09f0642f99db98e9776a commit.

6 years agoFix compile error on freebsd.
Bo Peng [Thu, 23 May 2019 10:46:27 +0000 (19:46 +0900)]
Fix compile error on freebsd.

Add missing include file "netinet/in.h".

per bug519 and bug512.

6 years agoFix memory leak in pgproto pointed out by Coverity.
Tatsuo Ishii [Thu, 23 May 2019 05:36:10 +0000 (14:36 +0900)]
Fix memory leak in pgproto pointed out by Coverity.

6 years agoFix to not access pg_stat_replication view if PostgreSQL version is not appropriate.
Tatsuo Ishii [Wed, 22 May 2019 23:22:19 +0000 (08:22 +0900)]
Fix to not access pg_stat_replication view if PostgreSQL version is not appropriate.

PostgreSQL 9.0 does not have it.

6 years agoMake failover in progress check more aggressively.
Tatsuo Ishii [Wed, 22 May 2019 22:34:03 +0000 (07:34 +0900)]
Make failover in progress check more aggressively.

In pool_virtual_master_db_node_id() the case when session context is
not available was not covered by the failover in progress checking
because I thought it'd be too aggressive. However a report from field
showed that that could happen while authenticating a client (and it
causes a segfault). So I decided to move the check to beginning of the
function to cover the case.

6 years agoAdd backend_application_name to "pgpool show backend" group.
Tatsuo Ishii [Wed, 22 May 2019 14:12:29 +0000 (23:12 +0900)]
Add backend_application_name to "pgpool show backend" group.

6 years agoFix backend_application_name not being set while reloading config file.
Tatsuo Ishii [Wed, 22 May 2019 14:01:48 +0000 (23:01 +0900)]
Fix backend_application_name not being set while reloading config file.

6 years agoFix memory leak in outfuncs.c pointed out by Coverity.
Tatsuo Ishii [Wed, 22 May 2019 08:01:47 +0000 (17:01 +0900)]
Fix memory leak in outfuncs.c pointed out by Coverity.

6 years agoFix NULL pointer dereference pointed out by Coverity.
Tatsuo Ishii [Wed, 22 May 2019 07:20:51 +0000 (16:20 +0900)]
Fix NULL pointer dereference pointed out by Coverity.

6 years agoFix memory leak pointed out by coverity.
Tatsuo Ishii [Wed, 22 May 2019 06:15:37 +0000 (15:15 +0900)]
Fix memory leak pointed out by coverity.

6 years agoFix coverity complain.
Tatsuo Ishii [Wed, 22 May 2019 05:22:14 +0000 (14:22 +0900)]
Fix coverity complain.

6 years agoDoc: fix mistake in the previous commit.
Tatsuo Ishii [Wed, 22 May 2019 01:20:32 +0000 (10:20 +0900)]
Doc: fix mistake in the previous commit.

Follow master command's %P is "old primary node id" and should have
not been changed.

6 years agoDoc: fix mistakenly described %P of failback command and follow master command.
Tatsuo Ishii [Wed, 22 May 2019 00:48:29 +0000 (09:48 +0900)]
Doc: fix mistakenly described %P of failback command and follow master command.

These should have been "current primary node id", rather than "old
primary node id".

6 years agoDeal pgpool_adm extension with PostgreSQL 12.
Tatsuo Ishii [Tue, 21 May 2019 22:39:37 +0000 (07:39 +0900)]
Deal pgpool_adm extension with PostgreSQL 12.

Now that oid is gone, the signature of CreateTemplateTupleDesc() has
been changed.

6 years agoAdd general description about failover.
Tatsuo Ishii [Wed, 15 May 2019 08:01:51 +0000 (17:01 +0900)]
Add general description about failover.

6 years agoFix for [pgpool-hackers: 3295] duplicate failover request ...
Muhammad Usama [Wed, 15 May 2019 21:36:35 +0000 (02:36 +0500)]
Fix for [pgpool-hackers: 3295] duplicate failover request ...

Pgpool should keep the backend health check running on quarantined nodes so
that when the connectivity resumes, they should automatically get removed
from the quarantine. Otherwise the temporary network glitch could send the node
into permanent quarantine state.

6 years agodoc: Add release nots 3.4.24-4.0.5.
Bo Peng [Wed, 15 May 2019 06:42:47 +0000 (15:42 +0900)]
doc: Add release nots 3.4.24-4.0.5.

6 years agoFix the wrong error message "ERROR: connection cache is full", when all backend nodes...
Bo Peng [Thu, 9 May 2019 08:22:29 +0000 (17:22 +0900)]
Fix the wrong error message "ERROR: connection cache is full", when all backend nodes are down.

When all backend nodes are down, Pgpool-II throws an uncorrect
error message "ERROR: connection cache is full". Change the error
message to "all backend nodes are down, pgpool requires at least one valid node".

per bug487.
https://www.pgpool.net/mantisbt/view.php?id=487

6 years agoDoc: update chapters that 'Server Configuration' of 'Server Administration'.
Takuma Hoshiai [Wed, 8 May 2019 05:06:04 +0000 (14:06 +0900)]
Doc: update chapters that 'Server Configuration' of 'Server Administration'.

Reviewed by Tatsu Ishii and Bo Peng.

6 years agoDoc: fix typo.
Tatsuo Ishii [Tue, 7 May 2019 07:43:03 +0000 (16:43 +0900)]
Doc: fix typo.

6 years agoDoc: add performance Japanese doc.
Tatsuo Ishii [Sat, 4 May 2019 09:00:12 +0000 (18:00 +0900)]
Doc: add performance Japanese doc.

Also fix typos in English performance doc.

6 years agoDoc: add useful link how to create pcp.conf in the pcp reference page.
Tatsuo Ishii [Fri, 3 May 2019 23:26:55 +0000 (08:26 +0900)]
Doc: add useful link how to create pcp.conf in the pcp reference page.

Also fix some typos.

6 years agoSpeed up failover when all of backends are down.
Tatsuo Ishii [Fri, 3 May 2019 00:02:29 +0000 (09:02 +0900)]
Speed up failover when all of backends are down.

Pgpool-II tries to find primary node till search_primary_node_timeout
expires even if all of the backend are in down status. This is not
only a waste of time but makes Pgpool-II looked like hanged because
while searching primary node failover process is suspended and all of
the Pgpool-II child process are in defunct state, thus there's no
process which accepts connection requests from clients. Since the
default value of searching primary is 300 seconds, typically this
keeps on for 300 seconds. This is not comfortable for users.

So immediately give up finding primary node regardless
search_primary_node_timeout and promptly finish the failover process
if all of the backend are in down status.

Discussion: https://www.pgpool.net/pipermail/pgpool-hackers/2019-May/003321.html

6 years agoDeal with PostgreSQL 12.
Tatsuo Ishii [Mon, 29 Apr 2019 23:49:48 +0000 (08:49 +0900)]
Deal with PostgreSQL 12.

recovery.conf cannot be used anymore. Standby's recovery configuration
is now in postgresql.conf. Also "standby.signal" file is needed in
PostgreSQL database cluster directory to start postmaster as a standby
server.

6 years agoDeal with PostgreSQL 12.
Tatsuo Ishii [Mon, 29 Apr 2019 23:46:06 +0000 (08:46 +0900)]
Deal with PostgreSQL 12.

HeapTupleGetOid() is not available any more in PostgreSQL 12. Use
GETSTRUCT() and refer to oid column of Form_pg_proc.

6 years agoDoc: first release of performance section.
Tatsuo Ishii [Fri, 26 Apr 2019 22:17:49 +0000 (07:17 +0900)]
Doc: first release of performance section.

6 years agoSet backend_application_nameN in pgpool.conf.
Tatsuo Ishii [Wed, 24 Apr 2019 04:16:37 +0000 (13:16 +0900)]
Set backend_application_nameN in pgpool.conf.

6 years agoAdd backend_application_nameN.
Tatsuo Ishii [Wed, 24 Apr 2019 04:05:48 +0000 (13:05 +0900)]
Add backend_application_nameN.

6 years agoDoc: fix typo.
Tatsuo Ishii [Wed, 24 Apr 2019 03:58:48 +0000 (12:58 +0900)]
Doc: fix typo.

6 years agoRemove .sgml file to not used.
Takuma Hoshiai [Wed, 24 Apr 2019 02:34:23 +0000 (11:34 +0900)]
Remove .sgml file to not used.

basic-config-example.sgml written by English exists doc.ja directory only,
and don't used document.

6 years agoAdd explanation about newly added columns.
Tatsuo Ishii [Wed, 24 Apr 2019 00:52:44 +0000 (09:52 +0900)]
Add explanation about newly added columns.

Those should have been added when English doc was updated.

6 years agoAdd "replication_state" and "replication_sync_state" columns to "show pool_nodes...
Tatsuo Ishii [Tue, 23 Apr 2019 08:32:59 +0000 (17:32 +0900)]
Add "replication_state" and "replication_sync_state" columns to "show pool_nodes" and friends.

This allows to show important information from pg_stat_replication,
which is available from PostgreSQL 9.1 (also without
replication_state_sync. it's available since 9.2).

For this purpose new "backend_application_name" parameter is added.
pg_stat_replication is called from pool_worker_process at the same
timing of replication delay checking.

Also modify following commands to add those new columns:

- pcp_node_info
- pgpool_adm's pcp_node_info function

Discussion: https://www.pgpool.net/pipermail/pgpool-hackers/2019-April/003315.html

6 years agoAvoid exit/fork storm of pool_worker_child process.
Tatsuo Ishii [Sun, 21 Apr 2019 06:57:22 +0000 (15:57 +0900)]
Avoid exit/fork storm of pool_worker_child process.

pool_worker_child issues query to get WAL position using do_query(),
which could throws FATAL error. In this case pool_worker_child process
exits and Pgpool-II parent immediately forks new process. This cycle
indefinitely repeats and gives high load to the system.

This could easily happen. For example if ALWAYS_MASTER flag is
mistakenly set to standby node, it will cause an error:

ERROR:  recovery is in progress
HINT:  WAL control functions cannot be executed during recovery.
STATEMENT:  SELECT pg_current_wal_lsn()

To avoid the exit/fork storm, sleep sr_check_period.

6 years agoFix black_function_list's broken default value.
Tatsuo Ishii [Wed, 17 Apr 2019 22:52:56 +0000 (07:52 +0900)]
Fix black_function_list's broken default value.

I accidentally broke the entry of pgpool.conf.sample when
database_redirect_preference_list and
app_name_redirect_preference_list were introduced.

Also fix mistake of the entry of pgpool.conf.sample-replication as
well.

Issue reported by Sebastiaan Alexander Mannem.

6 years agoFix "not enough space in buffer" error.
Tatsuo Ishii [Wed, 17 Apr 2019 13:11:00 +0000 (22:11 +0900)]
Fix "not enough space in buffer" error.

The error occurred while processing error message returned from
backend and the cause is that the query string in question is too
big. Problem is, the buffer is in fixed size (8192 bytes). From the
programming point of view there's absolutely no need to use fixed size
buffer. So eliminate the fixed size buffer and use palloced buffer
instead. This also saves some memory copy work.

Per bug 499.

6 years agoSet application_name in recovery_conf.
Tatsuo Ishii [Wed, 17 Apr 2019 02:41:11 +0000 (11:41 +0900)]
Set application_name in recovery_conf.

This allows to show each cluster name as application_name. Currently
each application_name is set to: server0, server1, server2 and so on,
where the numeric part is the cluster number. This is especially
useful to use pg_stat_replication because it does not provide any useful
information regarding UNIX socket path or port number.

6 years agoFix DROP DATABASE failure.
Tatsuo Ishii [Tue, 16 Apr 2019 06:48:44 +0000 (15:48 +0900)]
Fix DROP DATABASE failure.

When DROP DATABASE gets executed, SIGUSR1 is sent to the Pgpool-II
child process being issuing the command. In its SIGUSR1 handler,
MASTER macro is called while closing all idle connections. The MACRO
checks whether we are in failover process surely we are. As a result,
the process exits and DROP DATABASE command never been issued.

Per bug 486. However the reason of segfault in the report is not
clear.  After commit:
https://git.postgresql.org/gitweb/?p=pgpool2.git;a=commit;h=66b5aacfcc045ec1485921a5884b637fcfb6fd73

Things could be different. Let the user test the latest version in the
git repo and see if the problem is solved...

6 years agoDoc: add load balancing description.
Tatsuo Ishii [Thu, 11 Apr 2019 08:32:43 +0000 (17:32 +0900)]
Doc: add load balancing description.

More will come...

6 years agoDoc: fix typo.
Tatsuo Ishii [Thu, 11 Apr 2019 08:32:19 +0000 (17:32 +0900)]
Doc: fix typo.

6 years agoFix typoes.
Tatsuo Ishii [Tue, 9 Apr 2019 09:39:09 +0000 (18:39 +0900)]
Fix typoes.

6 years agoFix to compare wrong variable, when old pgpool_status file read.
Takuma Hoshiai [Wed, 10 Apr 2019 02:57:20 +0000 (11:57 +0900)]
Fix to compare wrong variable, when old pgpool_status file read.

Pgpool-II 3.4 or later, pgpool_status format changed, and format both old and new is supported.
Pgpool might read status in file incorrectly, when old format is reading by Pgpool.

This is rare case, and noproblem if it is happend.

6 years agoFix typo.
Tatsuo Ishii [Tue, 9 Apr 2019 08:15:30 +0000 (17:15 +0900)]
Fix typo.

6 years agoAdd more section to peformance chapter.
Tatsuo Ishii [Tue, 9 Apr 2019 07:14:55 +0000 (16:14 +0900)]
Add more section to peformance chapter.

6 years agoDoc: add description about multi-statement queries to restrictions section.
Tatsuo Ishii [Tue, 9 Apr 2019 05:17:57 +0000 (14:17 +0900)]
Doc: add description about multi-statement queries to restrictions section.

6 years agoAdd test/watchdog_setup to EXTRA_DIST.
Bo Peng [Sun, 7 Apr 2019 15:01:50 +0000 (00:01 +0900)]
Add test/watchdog_setup to EXTRA_DIST.
See bug470: https://www.pgpool.net/mantisbt/view.php?id=470

6 years agoDoc: mention that multi-statement queries are sent to primary node only.
Tatsuo Ishii [Sun, 7 Apr 2019 00:42:31 +0000 (09:42 +0900)]
Doc: mention that multi-statement queries are sent to primary node only.

Even if the multi-statement query includes SET command, they should be
sent to primary node only. This is not explicitly mentioned nowhere
in the doc.

Per bug 492.

6 years agoFix md5 auth broken in raw mode.
Tatsuo Ishii [Fri, 5 Apr 2019 07:53:51 +0000 (16:53 +0900)]
Fix md5 auth broken in raw mode.

In raw mode, pool_passwd is not necessary to authenticate PostgreSQL
using md5 auth.  However if there's more than 1 backend,
authenticating with md5 fails.

Fix is, checking whether we are operating in raw mode while do md5
authentication. This was broken in 4.0, so back-patched to only 4.0.

Per bug 491.

6 years agoFix occasional regression test error of 008.dbredirect.
Tatsuo Ishii [Fri, 5 Apr 2019 02:42:58 +0000 (11:42 +0900)]
Fix occasional regression test error of 008.dbredirect.

The test runs pgbench to create test data. Under slow environment
replication delay could become too much, and this would prevent load
balancing because the default value for delay_threshold is set to
10000000 in the default pgpool.conf-stream and the tests would fail.

The fix is, disabling delay_threshold. Also add "show_pool nodes" to
confirm that replication delay actually happens.

6 years agoFix occasional regression test failure of 014.watchdog_test_quorum_bypass.
Tatsuo Ishii [Wed, 3 Apr 2019 03:04:58 +0000 (12:04 +0900)]
Fix occasional regression test failure of 014.watchdog_test_quorum_bypass.

The test script does not retry psql while failover happens and
failed. So replace psql with wait_for_pgpool_startup.

6 years agoAbort session if failover/failback is ongoing.
Tatsuo Ishii [Tue, 2 Apr 2019 03:56:01 +0000 (12:56 +0900)]
Abort session if failover/failback is ongoing.

If failover/failback is ongoing, there would be a risk that MASTER
node macro cannot be used. If used, it could raise a segfault because
connection to the master node is NULL or bogus.

There are several reports suspected to be caused by this (see bug 481,
482 for example).

Now the guts of the MASTER* macro (pool_virtual_master_db_node_id())
is modified to check Req_info->switching which is true while
failover/failback is ongoing. If true, emit warning message and exit
the process. There's still a small window I know, but this should
greatly reduce the chance to access bogus MASTER connection without
using any locking.

6 years agoNew feature "statement_level_load_balancing".
Bo Peng [Tue, 2 Apr 2019 01:14:26 +0000 (10:14 +0900)]
New feature "statement_level_load_balancing".

This feature enables selecting load balancing node per statement.

The current feature for load balancing, the load balancing node is decided
at the session start time and will not be changed until the session ends.

When set to statement_level_load_balancing = on, the load balancing node
is decided for each read query.

For example, in applications that use connection pooling remain connections
open to the backend server, because the session may be held for a long time,
the load balancing node does not change until the session ends.
In such applications, when statement_level_load_balance is enabled,
it is possible to decide load balancing node per query, not per session.

6 years agoGenerate Makefile.in by automake 1.13.4.
Bo Peng [Tue, 2 Apr 2019 00:21:44 +0000 (09:21 +0900)]
Generate Makefile.in by automake 1.13.4.

6 years agoSuppress "ar: `u' modifier ignored since `D' is the default (see `U')".
Tatsuo Ishii [Sat, 30 Mar 2019 13:34:45 +0000 (22:34 +0900)]
Suppress "ar: `u' modifier ignored since `D' is the default (see `U')".

This is actually a bug with libtools. To deal with this, add ARFLAGS
to parser's Makefile.am.

6 years agoSuppress useless truncation warnings from gcc 8+.
Tatsuo Ishii [Sat, 30 Mar 2019 12:56:03 +0000 (21:56 +0900)]
Suppress useless truncation warnings from gcc 8+.

For this purpose update c-compiler.m4 (borrowed from PostgreSQL's
config/c-compiler.m4) and add PGAC_PROG_CC_VAR_OPT(NOT_THE_CFLAGS,
[-Wformat-truncation]) to configure.ac to generate -Wformat-truncation
compiler option.

6 years agoSuppress compiler warnings.
Tatsuo Ishii [Sat, 30 Mar 2019 12:29:41 +0000 (21:29 +0900)]
Suppress compiler warnings.

Suppress compiler warnings regarding write(2) returns values being
ignored.  Since they are used in signal handlers, it's impossible to
print info about errors. To shut up the warnings, create a static
variable and assign the return values from write().

6 years agoFix compiler warnings.
Tatsuo Ishii [Sat, 30 Mar 2019 11:56:29 +0000 (20:56 +0900)]
Fix compiler warnings.

To deal with compiler warnings regarding that the return value of
write(2) is ignored, replace it with write_it() which calls write()
and uses the return value from it to print error string when write()
returns error.

6 years agoFix wrong usage of volatile declaration.
Tatsuo Ishii [Sat, 30 Mar 2019 01:33:58 +0000 (10:33 +0900)]
Fix wrong usage of volatile declaration.

From a PostgreSQL commit message:
     Variables used after a longjmp() need to be declared volatile.  In
     case of a pointer, it's the pointer itself that needs to be declared
     volatile, not the pointed-to value.

Same thing can be said to:
     volatile StartupPacket *sp;

This should have been:
     StartupPacket *volatile sp;

This also suppresses a compiler warning.

6 years agoChange pgpool.spec.
Bo Peng [Thu, 28 Mar 2019 11:56:35 +0000 (20:56 +0900)]
Change pgpool.spec.

6 years agoUpdate pgpool_socket_dir.patch file.
Bo Peng [Thu, 28 Mar 2019 11:29:36 +0000 (20:29 +0900)]
Update pgpool_socket_dir.patch file.

6 years agoDoc: Add release-notes 4.0.4-3.4.23.
Bo Peng [Thu, 28 Mar 2019 09:18:10 +0000 (18:18 +0900)]
Doc: Add release-notes 4.0.4-3.4.23.

6 years agoFix memory leak in "batch" mode in extended query.
Tatsuo Ishii [Thu, 28 Mar 2019 04:58:27 +0000 (13:58 +0900)]
Fix memory leak in "batch" mode in extended query.

In "batch" mode, not for every execute message, a sync message is
followed.  Unfortunately Pgpool-II only discard memory of query
context for the last execute message while processing the ready for
query message. For example if 3 execute messages are sent before the
sync message, 2 of query context memory will not be freed and this
leads to serious memory leak.

To fix the problem, now the query context memory is possibly discarded
when a command complete message is returned from backend if the query
context is not referenced either by sent messages or pending messages.
If it is not referenced at all, we can discard the query context.

Also even if it is referenced, it is ok to discard the query context
if it is either an unnamed statement or an unnamed portal because it
will be discarded anyway when next unnamed statement or portal is
created.

Per bug 468.

6 years agoDoc: add ssl_prefer_server_ciphers paramter to Japanese doc.
Tatsuo Ishii [Wed, 27 Mar 2019 10:16:49 +0000 (19:16 +0900)]
Doc: add ssl_prefer_server_ciphers paramter to Japanese doc.

6 years agoAdd new configuration option ssl_prefer_server_ciphers
Muhammad Usama [Wed, 27 Mar 2019 07:51:20 +0000 (12:51 +0500)]
Add new configuration option ssl_prefer_server_ciphers

Add the new setting "ssl_prefer_server_ciphers" to let users configure if they
want client's or server's cipher order to take preference.

6 years agoSpecify default value of ssl_ciphers
Yugo Nagata [Wed, 27 Mar 2019 01:08:32 +0000 (10:08 +0900)]
Specify default value of ssl_ciphers

6 years agoAllow to set a client cipher list.
Tatsuo Ishii [Sat, 23 Mar 2019 04:04:21 +0000 (13:04 +0900)]
Allow to set a client cipher list.

For this purpose new parameter "ssl_ciphers" is added. This is already
implemented in PostgreSQL and useful to enhance security when SSL is
enabled.

6 years agoDoc: update chapters that 'Watchdog' of 'Tutorial' and some sections of 'Server Admin...
Takuma Hoshiai [Fri, 22 Mar 2019 04:30:30 +0000 (13:30 +0900)]
Doc: update chapters that 'Watchdog' of 'Tutorial' and some sections of 'Server Administration'

reviewed by Tatsu Ishii and Bo Peng.

6 years agoDoc: enhance watchdog/Pgpool-II example so that it mentions about pg_monitor role.
Tatsuo Ishii [Fri, 22 Mar 2019 02:45:42 +0000 (11:45 +0900)]
Doc: enhance watchdog/Pgpool-II example so that it mentions about pg_monitor role.

Per bug 469.

6 years agoFix unnecessary fsync to pgpool_status file.
Tatsuo Ishii [Mon, 18 Mar 2019 00:34:02 +0000 (09:34 +0900)]
Fix unnecessary fsync to pgpool_status file.

Whenever new connections are created to PostgreSQL backend, fsync()
was issued to pgpool_status file, which could generate excessive I/O
in certain conditions, for example num_init_children is large and
connections to backend have certain life time limit.

So reduce the chance of issuing fsync() so that it is issued only when
backend status is changed from CON_CONNECT_WAIT or others to CON_UP.
If the status is already CON_UP, we don't need to write to
pgpool_status.

Discussion: [pgpool-general: 6436] High I/O Usage on PGPool nodes