pgpool2.git
2 years agoFix comment mistakes.
Tatsuo Ishii [Thu, 2 Feb 2023 10:34:00 +0000 (19:34 +0900)]
Fix comment mistakes.

2 years agoFix comment mistakes.
Tatsuo Ishii [Thu, 2 Feb 2023 05:29:33 +0000 (14:29 +0900)]
Fix comment mistakes.

2 years agoDoc: enhance show pool_cache manual.
Tatsuo Ishii [Wed, 1 Feb 2023 13:39:41 +0000 (22:39 +0900)]
Doc: enhance show pool_cache manual.

Add a table to explain each items shown by show pool_cache.

2 years agoRemove unnecessary macro.
Tatsuo Ishii [Tue, 31 Jan 2023 11:36:29 +0000 (20:36 +0900)]
Remove unnecessary macro.

The macro "DUAL_MODE" is no longer used anywhere.
Moreover, if it is used, it causes a compile error.

2 years agoFix kind mimatch error with DEALLOCATE
Tatsuo Ishii [Tue, 31 Jan 2023 09:49:48 +0000 (18:49 +0900)]
Fix kind mimatch error with DEALLOCATE

When conditions below are all met:
- streaming replication mode
- load balance node is other than primary
- PREPARE is used in a multi-statement query

Kind mimatch error occurs.

For DEALLOCATE pool_where_to_send() sets the nodes to be sent to all
backend if pgpool failed to find a prepared statement previously
received. For example with "SELECT 1\;PREPARE foo;", pgpool ignores
"PREPARE" part and just sends the whole multi-statement query to
primary. So primary actually has the prepared statement "foo" but
pgpool thinks that there's no prepared statement named "foo". And
pgpool sends DEALLOCATE to both primary and standby, then a kind
mismatch error raised. Fix is, just sending DEALLOCATE to primary node
in this case if pgpool is in streaming replication mode.  Same thing
can be said to EXECUTE too. I fixed this and merge similar treatment
with EXECUTE into where_to_send_deallocate() to make the code simpler.

I also found another bug: in replication mode or SI mode, pgpool needs
to send multi-statement query to all backend because the
multi-statement query maybe a write query. However pgpool sends to
main node only in this case.

Test cases are added to 071..execute_and_deallocate.

Backpatch-through: 4.0

Problem reported in:
https://www.pgpool.net/mantisbt/view.php?id=780

2 years agoObtain stronger lock while commiting shared relcache.
Tatsuo Ishii [Mon, 30 Jan 2023 02:02:22 +0000 (11:02 +0900)]
Obtain stronger lock while commiting shared relcache.

Previously pool_search_relcache() obtained only shared lock, which is
not safe enough to call pool_catalog_commit_cache() because it
registers new cache entry. Unfortunately our locking system does not
allow to escalate a shared lock to an exclusive lock. So we release
the shared lock then acquire the exclusive lock before calling
pool_catalog_commit_cache(). There's a window between them and we may
end up with an effort to register duplicate cache entry. But
underlying infrastructure of the query system will reject it and
should be safe.

Back-patch through 4.4 where the shared locking of the query cache
system was introduced.

2 years agoTest: refactor 071.execute_and_deallocate/test.sh.
Tatsuo Ishii [Sat, 28 Jan 2023 03:17:23 +0000 (12:17 +0900)]
Test: refactor 071.execute_and_deallocate/test.sh.

Previously the test was performed on only streaming replication mode.
Now the test covers native replication mode, snapshot isolation mode
and raw mode. Note that since case 6 test tries to test load balancing
on node 1, the case is not applied to raw mode.

2 years agoTest: fix indentation for further refactoring.
Tatsuo Ishii [Sat, 28 Jan 2023 02:37:18 +0000 (11:37 +0900)]
Test: fix indentation for further refactoring.

2 years agoDoc: fix typo in the description of read_only_function_list.
Tatsuo Ishii [Wed, 25 Jan 2023 05:45:34 +0000 (14:45 +0900)]
Doc: fix typo in the description of read_only_function_list.

2 years agoFix compile error of regression test
Takuma Hoshiai [Tue, 24 Jan 2023 15:48:33 +0000 (00:48 +0900)]
Fix compile error of regression test

The error occurred by timestamp test using gcc10.

2 years agoDoc: update copy right.
Bo Peng [Sat, 21 Jan 2023 15:00:17 +0000 (00:00 +0900)]
Doc: update copy right.

2 years agoDoc: Add release notes.
Bo Peng [Sat, 21 Jan 2023 15:00:04 +0000 (00:00 +0900)]
Doc: Add release notes.

2 years agoChange the default value for wd_lifecheck_password to empty string as documented.
Bo Peng [Sat, 21 Jan 2023 14:54:35 +0000 (23:54 +0900)]
Change the default value for wd_lifecheck_password to empty string as documented.

2 years agoDo not expose wd_lifecheck_password in show pool_status command.
Bo Peng [Sat, 21 Jan 2023 14:54:24 +0000 (23:54 +0900)]
Do not expose wd_lifecheck_password in show pool_status command.

2 years agoAdd pgpool_adm--1.5.sql and pgpool_adm--1.4--1.5.sql.
Bo Peng [Mon, 16 Jan 2023 13:43:41 +0000 (22:43 +0900)]
Add pgpool_adm--1.5.sql and pgpool_adm--1.4--1.5.sql.

2 years agoAdd patch files to EXTRA_DIST.
Bo Peng [Mon, 16 Jan 2023 13:42:45 +0000 (22:42 +0900)]
Add patch files to EXTRA_DIST.

2 years agoFix pgpool_adm: pcp_pool_status.
Tatsuo Ishii [Mon, 16 Jan 2023 09:45:59 +0000 (18:45 +0900)]
Fix pgpool_adm: pcp_pool_status.

If the function is used with PostgreSQL 15, it fails with:

ERROR:  table-function protocol for value-per-call mode was not followed

pcp_pool_status actually returns set of record but it was declared as
"returns record".  This sloppiness had been tolerated until 14 but 15
becomes more strict. To fix this we need to change the return type of
pcp_pool_status from "returns record" to "returns setof record".
So the pgpool_adm extension version is bumped up.

2 years agoRemove pgpool-II-head.patch from SPEC file.
Bo Peng [Mon, 16 Jan 2023 08:27:50 +0000 (17:27 +0900)]
Remove pgpool-II-head.patch from SPEC file.

2 years agoTest: tweak 028.watchdog_enable_consensus_with_half_votes.
Tatsuo Ishii [Sat, 14 Jan 2023 11:10:06 +0000 (20:10 +0900)]
Test: tweak 028.watchdog_enable_consensus_with_half_votes.

Sometimes buildfarm fails by:

bind on socket failed with error "Address already in use".

This happens after shutting down all pgpools then start them again. So
wait for 5 seconds between them instead of 1 second.  Let's see if
things are going to get better.

2 years agoFix integer overflow in streaming replication check.
Tatsuo Ishii [Fri, 13 Jan 2023 00:21:59 +0000 (09:21 +0900)]
Fix integer overflow in streaming replication check.

When delay_threshold_by_time is enabled, following query is
periodically sent to the primary node to obtain the replication delay
in micro seconds.

SELECT application_name, state, sync_state,(EXTRACT(EPOCH FROM
replay_lag)*1000000)::integer FROM pg_stat_replication";

Unfortunately the result from EXTRACT::integer overflows if replay_lag
is bigger than 2147483647/1000000 (that is about 35 minutes and 47
seconds). Fix is, changing "integer" to "bigint". By this, the result
will not overflow unless it becomes bigger than 292,472 years.
Discussion: https://www.pgpool.net/pipermail/pgpool-general/2023-January/008600.html
Backpatch-through: 4.4

2 years agoFix Uninitialized variables pointed out by Coverity
Takuma Hoshiai [Mon, 9 Jan 2023 18:05:48 +0000 (03:05 +0900)]
Fix Uninitialized variables pointed out by Coverity

Fix Uninitialized variables pointed out by Coverity.

2 years agoFix comment.
Tatsuo Ishii [Sat, 7 Jan 2023 04:27:34 +0000 (13:27 +0900)]
Fix comment.

sizeof(POOL_CACHE_ITEM_HEADER) is 16 bytes, not 24 bytes.

2 years agoDoc: enhance "Configurations to use shared memory" chapter.
Tatsuo Ishii [Fri, 6 Jan 2023 01:37:21 +0000 (10:37 +0900)]
Doc: enhance "Configurations to use shared memory" chapter.

Enhance the description to try to explain what the parameters actually
mean. Also fix wrong number, i.e. the size of data management area is
64 bytes, not 48 bytes.

2 years agoAdd comment to query cache module header file.
Tatsuo Ishii [Thu, 5 Jan 2023 07:50:43 +0000 (16:50 +0900)]
Add comment to query cache module header file.

Some struct size added to explain required shared memory size.

2 years agoDoc: enhance explanation of delay_threshold_by_time.
Tatsuo Ishii [Tue, 3 Jan 2023 09:05:03 +0000 (18:05 +0900)]
Doc: enhance explanation of delay_threshold_by_time.

Explicitly mention that in order to show delay_threshold_by_time,
backend_application_name is correctly set and match the
application_name in primary_conninfo.

Suggestion by zam bak.
Discussion: https://www.pgpool.net/pipermail/pgpool-general/2022-December/008584.html

2 years agoFix compiler warning.
Tatsuo Ishii [Sat, 24 Dec 2022 03:41:01 +0000 (12:41 +0900)]
Fix compiler warning.

pgpool-regclass.c needed to include "utils/varlena.h".  Also sort out
the header files order (except postgres.h which needs to be appear at
the top among PostgreSQL header files).

The compiler warning was reported by Florian Weimer.
https://www.pgpool.net/pipermail/pgpool-hackers/2022-December/004241.html

2 years agoDoc: update repo package version.
Bo Peng [Thu, 22 Dec 2022 06:37:25 +0000 (15:37 +0900)]
Doc: update repo package version.

2 years agoDoc: add release note.
Bo Peng [Thu, 22 Dec 2022 06:11:16 +0000 (15:11 +0900)]
Doc: add release note.

2 years agoFix time stamp rewrite bug.
Tatsuo Ishii [Tue, 20 Dec 2022 10:06:22 +0000 (19:06 +0900)]
Fix time stamp rewrite bug.

In native replication/snapshot isolation mode, any write query
including timestamp/date/time data are rewritten so that all
PostgreSQL servers accept same timestamp etc. value. From 4.4 outfuncs
module which is used to generate rewritten query was broken for
boolean data. In a parse tree constant data is represented as
"A_Const". 4.4 updated the module by using PostgreSQL 15's outfuncs
module. Starting from PostgreSQL 15 A_Const handles more data type
including boolean. Unfortunately the pgpool's outfuncs module did not
adopt the change. As a result boolean constant was ignored and turned
into empty string in the rewritten query string, which caused syntax
errors.

This commit fixes the issue. Also modify _outA_Const() so that it uses
_out* functions to handle other data types to save a few lines of
code.

Per report from Michiel van Leening.
Discussion: at: https://www.pgpool.net/pipermail/pgpool-general/2022-December/008581.html
Back-patch to: 4.4.

2 years agoFix for :[pgpool-hackers: 4227] Issue with failover_require_consensus
Muhammad Usama [Mon, 19 Dec 2022 19:39:32 +0000 (00:39 +0500)]
Fix for :[pgpool-hackers: 4227] Issue with failover_require_consensus

The fix is to dynamically set the failover command timeout based on the maximum
value of health check parameters across the watchdog cluster.

Reviewed and tested by Tatsuo Ishii

2 years agoDoc: enhance the performance section.
Tatsuo Ishii [Mon, 19 Dec 2022 07:04:39 +0000 (16:04 +0900)]
Doc: enhance the performance section.

Mention about dynamic process management.

2 years agoDoc: fix Japanese documentation to sync with English docs.
Tatsuo Ishii [Mon, 19 Dec 2022 04:50:33 +0000 (13:50 +0900)]
Doc: fix Japanese documentation to sync with English docs.

2 years agoAllow to define PGPOOLDIR uing environment variable.
Bo Peng [Sat, 17 Dec 2022 00:57:37 +0000 (09:57 +0900)]
Allow to define PGPOOLDIR uing environment variable.

per bug766.

2 years agoDowngrade streaming replication debugging message.
Tatsuo Ishii [Fri, 16 Dec 2022 09:49:02 +0000 (18:49 +0900)]
Downgrade streaming replication debugging message.

The log line "standby_delay: 54" was actually for debugging and should
have been down graded.  So I have downgraded to DEBUG1 from LOG. Also
tweaked the message to be saner.

2 years agoEnhance status file reading log.
Tatsuo Ishii [Thu, 15 Dec 2022 05:56:25 +0000 (14:56 +0900)]
Enhance status file reading log.

Previously only if pgpool_status exists and the status is down, a log
message was printed.  However it is more useful no matter what the
status (up or unused) is because it also represents that pgpool_status
exists and it is read while pgpool starting up, which is useful
information.

2 years agoDoc: fix typo in Aurora example.
Tatsuo Ishii [Wed, 14 Dec 2022 08:38:29 +0000 (17:38 +0900)]
Doc: fix typo in Aurora example.

2 years agoAdd more .gitignore files.
Tatsuo Ishii [Wed, 14 Dec 2022 01:23:08 +0000 (10:23 +0900)]
Add more .gitignore files.

src/include/config.h.in
some files under test/regression

2 years agoRemove more files under parser directory.
Tatsuo Ishii [Wed, 14 Dec 2022 00:23:17 +0000 (09:23 +0900)]
Remove more files under parser directory.

This is following commit caeb3a8681d7aa0f5b24539de12d29dd5a8d9997
"Remove Makefile.in etc. generated by autoconf."  Create .gitignore
under src/parser and add generated files by bison and flex.

2 years agoRemove Makefile.in etc. generated by autoconf.
Tatsuo Ishii [Tue, 13 Dec 2022 09:21:15 +0000 (18:21 +0900)]
Remove Makefile.in etc. generated by autoconf.

Also update some .ignore files and add some new .gitignore files.  Now
developers need to run autoconf/autoreconf before compiling since the
generated files are not provided by git anymore.

2 years agoDoc: enhance dynamic process management document.
Tatsuo Ishii [Mon, 12 Dec 2022 06:56:22 +0000 (15:56 +0900)]
Doc: enhance dynamic process management document.

2 years agoDowngrade "we have hit the ceiling" log.
Tatsuo Ishii [Mon, 12 Dec 2022 06:20:55 +0000 (15:20 +0900)]
Downgrade "we have hit the ceiling" log.

Under dynamic process management, when connection request exceeds
num_init_children, pgpool keeps on logging every 2 seconds "we have
hit the ceiling", which is flooding log file. So downgrade the log
level from LOG to DEBUG5.

2 years agoDoc: fix typo.
Tatsuo Ishii [Mon, 12 Dec 2022 05:48:06 +0000 (14:48 +0900)]
Doc: fix typo.

2 years agoFix typo in comments.
Tatsuo Ishii [Sat, 10 Dec 2022 06:23:30 +0000 (15:23 +0900)]
Fix typo in comments.

2 years agoUpdate version to 4.5devel.
Bo Peng [Tue, 6 Dec 2022 01:53:19 +0000 (10:53 +0900)]
Update version to 4.5devel.

2 years agoUpdate PGPOOLVERSION to "hotooriboshi".
Bo Peng [Tue, 6 Dec 2022 01:51:50 +0000 (10:51 +0900)]
Update PGPOOLVERSION to "hotooriboshi".

2 years agoUpdate SPEC file BuildRequires.
Bo Peng [Tue, 6 Dec 2022 01:34:06 +0000 (10:34 +0900)]
Update SPEC file BuildRequires.

2 years agoDoc: update release note.
Bo Peng [Mon, 5 Dec 2022 15:46:16 +0000 (00:46 +0900)]
Doc: update release note.

2 years agoDoc: fix doc typos.
Bo Peng [Mon, 5 Dec 2022 15:29:43 +0000 (00:29 +0900)]
Doc: fix doc typos.

Patch is created by Youichi Yabuki.

2 years agoFix typo in pgpool.spec.
Bo Peng [Sun, 4 Dec 2022 08:34:32 +0000 (17:34 +0900)]
Fix typo in pgpool.spec.

2 years agoDoc: update 4.4 release note.
Bo Peng [Sat, 3 Dec 2022 15:27:14 +0000 (00:27 +0900)]
Doc: update 4.4 release note.

2 years agoDowngrade LOG messages "new IPC connection received" to DEBUG1.
Bo Peng [Sat, 3 Dec 2022 13:31:15 +0000 (22:31 +0900)]
Downgrade LOG messages "new IPC connection received" to DEBUG1.

It is a normal messages and should not be logged as LOG.
Patch is created by pstef and reviewed by Bo Peng.

2 years agoDoc: update exapmles
Bo Peng [Tue, 29 Nov 2022 06:20:01 +0000 (15:20 +0900)]
Doc: update exapmles

2 years agoUpdate PostgreSQL version of sample scripts
Bo Peng [Tue, 29 Nov 2022 05:59:32 +0000 (14:59 +0900)]
Update PostgreSQL version of sample scripts

2 years agoUpdate pgpool.spec to generate /var/run/pgpool
Bo Peng [Tue, 29 Nov 2022 05:52:50 +0000 (14:52 +0900)]
Update pgpool.spec to generate /var/run/pgpool

2 years agoFix ROLLBACK TO command to work in aborted transaction.
Tatsuo Ishii [Fri, 25 Nov 2022 07:33:17 +0000 (16:33 +0900)]
Fix ROLLBACK TO command to work in aborted transaction.

Commit:

https://git.postgresql.org/gitweb/?p=pgpool2.git;a=commit;h=eea522ebfcf791a623e865deaa1aa6fb59e3c50b

fixed some cases in aborted transaction so that SQL commands except
COMMIT/ROLLBACK are not forwarded to backend. But it missed ROLLBACK
TO command. As a result even if ROLLBACK TO command is issued, the
command was not forwarded to backend and the transaction keeps on in
aborted state.
Back patched through 4.3 which the commit was brought in.
Also add a test case for ROLLBACK TO to test 078.
Discussion:
https://www.pgpool.net/pipermail/pgpool-general-jp/2022-November/001715.html

2 years agoFix not to print warnings of use of backslashes in parser.
Tatsuo Ishii [Thu, 24 Nov 2022 06:31:48 +0000 (15:31 +0900)]
Fix not to print warnings of use of backslashes in parser.

When standard_conforming_strings = off and escape_string_warning = on,
PostgreSQL prints warnings if backslashes are used in string
literal. This is fine. But previously Pgpool-II's parser printed the
same message too. This is redundant.

2 years agoDoc: enhance restrictions section.
Tatsuo Ishii [Tue, 22 Nov 2022 11:39:21 +0000 (20:39 +0900)]
Doc: enhance restrictions section.

Mention that failover_on_backend_shutdown can be used to avoid
unwanted failover caused by pg_terminate_backend.

2 years agoDoc: update release note.
Bo Peng [Tue, 22 Nov 2022 07:37:05 +0000 (16:37 +0900)]
Doc: update release note.

2 years agoFix typo in sample configuration file.
Bo Peng [Mon, 21 Nov 2022 14:55:08 +0000 (23:55 +0900)]
Fix typo in sample configuration file.

2 years agoFix "show pool_status" command doesn't show the new parameters process_management_mod...
Bo Peng [Mon, 21 Nov 2022 10:59:01 +0000 (19:59 +0900)]
Fix "show pool_status" command doesn't show the new parameters process_management_mode and process_management_strategy.

2 years agoTest: update sample scripts directory.
Bo Peng [Sun, 13 Nov 2022 13:50:01 +0000 (22:50 +0900)]
Test: update sample scripts directory.

2 years agoDoc: update documentation.
Bo Peng [Sat, 12 Nov 2022 14:47:50 +0000 (23:47 +0900)]
Doc: update documentation.

2 years agoUpdate src/pgpool.spec to delete %tmpfiles_create.
Bo Peng [Sat, 12 Nov 2022 01:24:05 +0000 (10:24 +0900)]
Update src/pgpool.spec to delete %tmpfiles_create.

2 years agoEnable AM_MAINTAINER_MODE on master branch.
Bo Peng [Fri, 11 Nov 2022 14:27:42 +0000 (23:27 +0900)]
Enable AM_MAINTAINER_MODE on master branch.

2 years agoDisable AM_MAINTAINER_MODE.
Bo Peng [Fri, 11 Nov 2022 14:23:26 +0000 (23:23 +0900)]
Disable AM_MAINTAINER_MODE.

2 years agoDoc: update 4.4 release note.
Bo Peng [Fri, 11 Nov 2022 14:18:19 +0000 (23:18 +0900)]
Doc: update 4.4 release note.

2 years agoDoc: add Japanese documentation of process management.
Bo Peng [Fri, 11 Nov 2022 14:15:00 +0000 (23:15 +0900)]
Doc: add Japanese documentation of process management.

2 years ago[New-Feature] Dynamic spare process management
Muhammad Usama [Wed, 9 Nov 2022 07:43:25 +0000 (12:43 +0500)]
[New-Feature] Dynamic spare process management

This feature allows selecting between static and dynamic process management modes.
Static process management is the same as the existing behavior of Pgpool-II, where it
spawns all child processes at startup. The new Dynamic mode keeps track of idle
processes and forks or kills processes to keep this number within
the specified boundaries.

Four new settings, process_management_mode,  process_management_strategy,
min_spare_children, and max_spare_children are added to configure the process
management behavior, while  process_management_strategy allows selecting
between three possible scaling-down strategies.

The first version of the patch was shared by "zhoujianshen at highgo.com" and reworked by me
Discussion: https://www.pgpool.net/pipermail/pgpool-hackers/2022-September/004189.html
Reviewed by: Bo Peng and Tatsuo Ishii

2 years agoUpdate Makefile and configure files to remove doc.zh-cn which is deleted in previous...
Bo Peng [Mon, 7 Nov 2022 06:15:31 +0000 (15:15 +0900)]
Update Makefile and configure files to remove doc.zh-cn which is deleted in previous commit fc2beb28d29667064d0c6156b9db320e1ec415fc

2 years agoRemove out-of-date doc.zh-cn directory.
Bo Peng [Mon, 7 Nov 2022 05:27:01 +0000 (14:27 +0900)]
Remove out-of-date doc.zh-cn directory.
doc.zh-cn is not actually translated, it's just a copy of doc.

2 years agoImprove follow_primary.sh.sample script:
Bo Peng [Mon, 7 Nov 2022 04:49:06 +0000 (13:49 +0900)]
Improve follow_primary.sh.sample script:
- run checkpoint command on primary to update control file before running pg_rewind
- check if a directory exists before removing it

2 years agoTest: update src/test/pgpool_setup.in
Bo Peng [Sun, 6 Nov 2022 10:43:01 +0000 (19:43 +0900)]
Test: update src/test/pgpool_setup.in

2 years agoUpdate src/redhat/pgpool_socket_dir.patch
Bo Peng [Sun, 6 Nov 2022 07:40:27 +0000 (16:40 +0900)]
Update src/redhat/pgpool_socket_dir.patch

2 years agoUpdate comments in pgpool.conf.
Tatsuo Ishii [Sun, 6 Nov 2022 01:20:28 +0000 (10:20 +0900)]
Update comments in pgpool.conf.

Update comments for listen_addresses and pcp_listen_addresses.
This shoud have been done in commits:
https://git.postgresql.org/gitweb/?p=pgpool2.git;a=commit;h=fd0efceae011c8d2c2f7c2b26dc0a738f055972e
https://git.postgresql.org/gitweb/?p=pgpool2.git;a=commit;h=9f727c1e267f1363012a3af599b7d7515e4ec355

2 years agoUpdate src/pgpool.spec:
Bo Peng [Sat, 5 Nov 2022 03:42:11 +0000 (12:42 +0900)]
Update src/pgpool.spec:
- Change /lib/tmpfiles.d/ file from /var/run to /run
- Install /etc/sudoers.d/pgpool
- Add new scripts aws_eip_if_cmd.sh.sample and aws_rtb_if_cmd.sh.sample

2 years agoAdd trusted_server_command parameter
Takuma Hoshiai [Fri, 4 Nov 2022 02:07:09 +0000 (11:07 +0900)]
Add trusted_server_command parameter

This patch be able to specify a command that is used by trusted_servers
for checking up stream connection. Previously, ping command was only used,
and it was hard coded.

Default is 'ping -q -c3 %h' which means same as before.

2 years agoDoc: update Pgpool-II 4.4 release note.
Bo Peng [Thu, 27 Oct 2022 03:20:06 +0000 (12:20 +0900)]
Doc: update Pgpool-II 4.4 release note.

2 years agoDoc: Update documentation of AWS configuration example and add sample scripts used...
Bo Peng [Thu, 27 Oct 2022 03:03:01 +0000 (12:03 +0900)]
Doc: Update documentation of AWS configuration example and add sample scripts used for AWS.

2 years agoDeal with idle_session_timeout.
Tatsuo Ishii [Wed, 26 Oct 2022 23:45:17 +0000 (08:45 +0900)]
Deal with idle_session_timeout.

If idle_session_timeout (added in PostgreSQL 14) is enabled and the
timeout fires, followings happen:

- If failover_on_backend_error is on (the default), Pgpool-II will
  trigger failover.

- If only one of PostgreSQL servers enables idle_session_timeout,
  Pgpool-II could hang.

To deal with idle_session_timeout detect_idle_session_timeout_error()
is added to detect the error code for idle_session_timeout. If the
error is detected, Pgpool-II returns the error code to frondend as a
fatal error and disconnects the session.  This is a similar fix
implemented for idle_in_transaction_session_timeout.

https://git.postgresql.org/gitweb/?p=pgpool2.git;a=commit;h=3f5986eee360f12e6a0bb77aa46f95abf5f6bc10

Discussion: https://www.pgpool.net/pipermail/pgpool-hackers/2022-October/004209.html
Back-path-through: 4.0

2 years agoDoc: enhance description about memqcache_method.
Tatsuo Ishii [Fri, 7 Oct 2022 02:26:28 +0000 (11:26 +0900)]
Doc: enhance description about memqcache_method.

Add explanation which method should be used.

Backpatch-through: 3.7.

2 years agoDoc: first cut of Pgpool-II 4.4 release note.
Tatsuo Ishii [Wed, 5 Oct 2022 01:34:18 +0000 (10:34 +0900)]
Doc: first cut of Pgpool-II 4.4 release note.

2 years agoFix comment in is_select_query().
Tatsuo Ishii [Mon, 3 Oct 2022 10:21:40 +0000 (19:21 +0900)]
Fix comment in is_select_query().

This function returns false for SELECT INTO, rather than plain SELECT.

2 years agoFix: Setting memory cache size greater than 2GB causes a segfault.
Muhammad Usama [Fri, 30 Sep 2022 20:33:12 +0000 (01:33 +0500)]
Fix: Setting memory cache size greater than 2GB causes a segfault.

The problem was in the block_address() function that returns the memory address
for a given cache block, It was using 32bit integers to calculate the offset of
the block within the shared memory space that is only good until the 2GB limit.

2 years agoFix to to use NIL to judge a List is empty or not.
Tatsuo Ishii [Mon, 26 Sep 2022 02:31:42 +0000 (11:31 +0900)]
Fix to to use NIL to judge a List is empty or not.

Previously it mistakenly judge by the value of the pointer itself is
NULL, which is not allowed by our coding standard.

2 years agoFix query cache.
Tatsuo Ishii [Sat, 24 Sep 2022 08:00:12 +0000 (17:00 +0900)]
Fix query cache.

The commit dc559c07ee5affc7035efa6e0f00185e211079a0 introduced shared
lock by using flock(2).  However it opened lock file in parent process
then the file descriptor was shared by child process. This is
wrong. The lock file needs to be opened by each child process.

2 years agoRemove unused semaphore number.
Tatsuo Ishii [Sat, 24 Sep 2022 02:55:03 +0000 (11:55 +0900)]
Remove unused semaphore number.

Commit dc559c07ee5affc7035efa6e0f00185e211079a0 replaced use of
semaphore with flock. Thus the semaphore number is no longer
necessary.

2 years agoFix rare segfaults in pcp_proc_info, SHOW pool_pools and SHOW pool_processes.
Tatsuo Ishii [Fri, 23 Sep 2022 06:46:33 +0000 (15:46 +0900)]
Fix rare segfaults in pcp_proc_info, SHOW pool_pools and SHOW pool_processes.

The segfaults were in get_pools() and get_processes(). They first
extracted pid of particular process info slot on shared memory then
searched the slot again by using pid as the key. Because these steps
were not protected by any locking, it was possible that the search
using the pid failed and returned NULL if the process id is
overwritten by pgpool parent which is responsible for forking new
child process after the process exiting. As a result any subsequent
reference to the NULL pointer generated segfaults.

Solution is, first get the pointer to the process info slot then
extract the process id member from the pointer. This way, still
concurrent updating to the shared memory info by the parent process is
possible (which may lead to strange results in the output) but at
least we can avoid segfaults.

2 years agoFix coding style.
Tatsuo Ishii [Thu, 22 Sep 2022 11:49:24 +0000 (20:49 +0900)]
Fix coding style.

Declaration of variables must be before any execute statements.

2 years agoRemove unused variable.
Bo Peng [Thu, 22 Sep 2022 09:13:13 +0000 (18:13 +0900)]
Remove unused variable.

2 years agoFix coding style.
Tatsuo Ishii [Thu, 22 Sep 2022 04:37:09 +0000 (13:37 +0900)]
Fix coding style.

Declaration of variables must be before any execute statements.

2 years agoFeature: Import PostgreSQL 15 BETA4 new parser.
Bo Peng [Wed, 21 Sep 2022 15:23:53 +0000 (00:23 +0900)]
Feature: Import PostgreSQL 15 BETA4 new parser.

Major changes of PostgreSQL 15 parser include:

- Add new SQL MERGE command

  MERGE INTO ... USING ...

- Add new option HEADER MATCH to COPY FROM

  COPY ... FROM stdin WITH (HEADER MATCH);

- Allow foreign key ON DELETE SET actions

  CREATE TABLE t1 (
      ...
      FOREIGN KEY (c1, c2) REFERENCES t2 ON DELETE SET NULL (c2)
  );

- Allow SET ACCESS METHOD in ALTER TABLE

  ALTER TABLE ... SET ACCESS METHOD ...;

3 years agoReplace exclusive locking with shared locking in query cache.
Tatsuo Ishii [Mon, 19 Sep 2022 05:35:02 +0000 (14:35 +0900)]
Replace exclusive locking with shared locking in query cache.

Previously the query cache module used semaphore to protect critical
region in the query cache module. However this had serious down side
because the locking using semaphore is exclusive lock. This
introduces unnecessary wait for cache reading clients and performance
degradation when there are many concurrent clients.

To overcome the issue replace locking implementation with flock(2)
which allows share locking. Now the cache reading clients do not need
to fight each other to obtain a lock thus this increases
concurrency.

For this purpose pgpool main process creates a dummy file as
"logdir/memq_lock_file" and opens it. The file descriptor is inherited
by all child process so that they can issue flock(2) on the file.

Discussion: https://www.pgpool.net/pipermail/pgpool-general/2022-September/008442.html
Discussion: https://www.pgpool.net/pipermail/pgpool-hackers/2022-September/004196.html

3 years agoDeal with SSL error SSL_ERROR_ZERO_RETURN.
Tatsuo Ishii [Wed, 14 Sep 2022 02:16:03 +0000 (11:16 +0900)]
Deal with SSL error SSL_ERROR_ZERO_RETURN.

Previously this caused failover, which was actually unnecessary because
it means the server is just going to close the connection.

Discussion: https://www.pgpool.net/pipermail/pgpool-general/2022-September/008425.html
Discussion: https://www.pgpool.net/pipermail/pgpool-hackers/2022-September/004194.html

3 years agoFix memory leak.
Masaya Kawamoto [Wed, 14 Sep 2022 00:15:26 +0000 (00:15 +0000)]
Fix memory leak.

This was added in the previous commit a94451901c9be0627c5e9db04e05ef2d6835dcd7

3 years agoFix to not allow Unix-domain socket paths with invalid lengths.
Masaya Kawamoto [Mon, 12 Sep 2022 09:17:08 +0000 (09:17 +0000)]
Fix to not allow Unix-domain socket paths with invalid lengths.

3 years agoUse $HOME/tmp or $HOME for the second Unix domain path.
Tatsuo Ishii [Mon, 12 Sep 2022 04:48:26 +0000 (13:48 +0900)]
Use $HOME/tmp or $HOME for the second Unix domain path.

The socket API does not allow to use too long Unix domain socket paths.

3 years agoApply changes introduced in the previous commit 50cc6f18d742c76fcc3d0ba60d2b5058267ef...
Bo Peng [Mon, 29 Aug 2022 01:46:23 +0000 (10:46 +0900)]
Apply changes introduced in the previous commit 50cc6f18d742c76fcc3d0ba60d2b5058267effb8 to src/parser/gram_template.y and src/parser/Makefile.in.

3 years agoDoc: mention that health check process may use SSL.
Tatsuo Ishii [Sun, 28 Aug 2022 03:54:51 +0000 (12:54 +0900)]
Doc: mention that health check process may use SSL.

Also mention that streaming replication check may use SSL too.
This should have been added since 2010.

Discussion: https://www.pgpool.net/pipermail/pgpool-hackers/2022-August/004188.html

3 years agoApply changes introduced in the previous commit to src/parser/gram_template.y and...
Bo Peng [Sat, 27 Aug 2022 14:51:38 +0000 (23:51 +0900)]
Apply changes introduced in the previous commit to src/parser/gram_template.y and src/parser/Makefile.in.

3 years agoRetire pool_string module.
Tatsuo Ishii [Fri, 26 Aug 2022 05:23:59 +0000 (14:23 +0900)]
Retire pool_string module.

Currently there are two string manipulation modules: pool_string and
StringInfo. StringInfo is more feature rich and PostgreSQL compatible
because it was imported from PostgreSQL. So replace all usages of
pool_string by StringInfo. This also solves a problem reported by
Peng: i.e. struct name "String" collision: pool_string uses "String"
and PostgreSQL 15's parser also uses "String".