pgpool2.git
2 years agoPrepare 4.2.13 V4_2_13 V4_2_13_RPM
Bo Peng [Wed, 17 May 2023 12:21:36 +0000 (21:21 +0900)]
Prepare 4.2.13

2 years agoBump version to 4.2.13
Bo Peng [Wed, 17 May 2023 12:17:26 +0000 (21:17 +0900)]
Bump version to 4.2.13

2 years agoDoc: modify release notes.
Bo Peng [Wed, 17 May 2023 12:11:20 +0000 (21:11 +0900)]
Doc: modify release notes.

2 years agoDoc: add release notes.
Bo Peng [Wed, 17 May 2023 11:48:49 +0000 (20:48 +0900)]
Doc: add release notes.

2 years agoFix possible dead lock with shared relation cache.
Tatsuo Ishii [Fri, 12 May 2023 11:41:36 +0000 (20:41 +0900)]
Fix possible dead lock with shared relation cache.

When a user defined function obtains table locking, call to the
function using extended query protocol could lead to dead lock. Here's
a scenario.

(1) In session A client sends parse, bind, execute request for the
    function to pgpol.

(2) Pgpool in session A forwards the request to PostgreSQL.

(3) PostgreSQL in session A performs execute, resulting in a table lock.

(4) In session B client sends parse, bind, execute request for the
    function to pgpool.

(5) Pgpool in session B forwards the request to PostgreSQL.

(6) PostgreSQL in session B performs bind but the table was already
    locked by PostgreSQL in session A, and it waits for release of the
    lock.

(7) After pgpool in session B forwards the execute to PostgreSQL, it
    acquires semaphore to search shared relation cache to check the
    volatility of the function. Then it calls do_query and sends flush
    message to PostgreSQL to obtain the response from PostgreSQL up to
    this point. But since PostgreSQL is waiting for table lock in #6,
    pgpool has to wait for messages beyond bind complete.

(8) After pgpool in session A forwards the execute to PostgreSQL, it
    tries to acquire semaphore to search shared relation cache to check
    the volatility of the function but the semaphore was already
    acquired by pgpool in session B, it waits for the release of the
    semaphore.

(9) Session A and session B wait for each other, resulting in a dead
    lock.

To fix this, modify pool_search_relcache() so that it releases
semaphore before calling do_query() (but acquires semaphore after
do_query()). By this, session A in #8 above can get semaphore, and go
forward. It receives sync message from client and forwards it to
PostgreSQL. Upon receiving sync, the user defined function will finish
the execution and releases the table lock. This makes PostgreSQL in
session B move forward because now it can obtain the table lock.

Back patch to 4.3, 4.2 and 4.1. On these versions semaphore based
shared release cache is used.

2 years agoTest: stabilize some tests.
Tatsuo Ishii [Fri, 12 May 2023 08:16:01 +0000 (17:16 +0900)]
Test: stabilize some tests.

069.memory_leak_extended, 070.memory_leak_extended_memqcache and
073.pg_terminate_backend uses "sleep 1" to confirm pgpool starting up,
which makes the tests unstable because there's no guarantee that pgpool
becomes ready within 1 second. Use wait_for_pgpool_startup instead to
stabilize the tests.

2 years agoTest: fix regress.sh to show correct number of total tests.
Tatsuo Ishii [Sat, 29 Apr 2023 12:44:59 +0000 (21:44 +0900)]
Test: fix regress.sh to show correct number of total tests.

Previously it ignored the number of timed out tests. As a result total
number of tests showed incorrect number because num-total tests was
calculated as num-ok + num-failed.

This is an oversight when timeout was introduced in 6688332da.

2 years agoDoc: add explanation for wd_priority.
Chen Ningwei [Tue, 25 Apr 2023 01:34:26 +0000 (10:34 +0900)]
Doc: add explanation for wd_priority.

2 years agoFix merging mistakes in the previous commit.
Tatsuo Ishii [Thu, 20 Apr 2023 06:53:39 +0000 (15:53 +0900)]
Fix merging mistakes in the previous commit.

2 years agoDoc: add restriction regarding PREPARE/EXECUTE/DEALLOCATE.
Tatsuo Ishii [Wed, 19 Apr 2023 10:41:21 +0000 (19:41 +0900)]
Doc: add restriction regarding PREPARE/EXECUTE/DEALLOCATE.

2 years agoUpdate src/Makefile.in.
Bo Peng [Wed, 19 Apr 2023 08:18:01 +0000 (17:18 +0900)]
Update src/Makefile.in.

2 years agoAdd src/utils/psqlscan.c.
Tatsuo Ishii [Wed, 19 Apr 2023 07:56:24 +0000 (16:56 +0900)]
Add src/utils/psqlscan.c.

V4.4 or older branches still keep generated files in git repository. I
forgot this in commit:
https://git.postgresql.org/gitweb/?p=pgpool2.git;a=commit;h=77f1e64d715c25d24830623f705877030d34e768

2 years agoDoc: add caution to use -D option with pgpool.
Tatsuo Ishii [Wed, 19 Apr 2023 03:40:48 +0000 (12:40 +0900)]
Doc: add caution to use -D option with pgpool.

2 years agoDoc: remove unnecessary restriction regarding multi-statement.
Tatsuo Ishii [Sun, 9 Apr 2023 04:11:12 +0000 (13:11 +0900)]
Doc: remove unnecessary restriction regarding multi-statement.

This applies to master branch only for now because this needs
commit:
https://git.postgresql.org/gitweb/?p=pgpool2.git;a=commit;h=48da8715bf403965507eef0321c0ab10054ac71c

If we decide to back port this, we will apply this change to stable
branches.

2 years agoJudge multi statement query using psqlscan.
Tatsuo Ishii [Sat, 25 Mar 2023 07:21:27 +0000 (16:21 +0900)]
Judge multi statement query using psqlscan.

Psqlscan is a module in the PostgreSQL source tree. It is essentially
subset of PostgreSQL SQL scanner but it is specialized for detecting
the end of each SQL statement. Therefore we can count the number of
SQL statements in a query string by using it.
Note that we use psqlscan only when query string is large.

Because psqlscan is not designed as an external library, it is hard to
call it from outside of PostgreSQL source tree. So I decided to import
psqlscan source code. This module consists of multiple files.  Program
sources are deployed in src/utils directory and header files are
deployed in src/include/utils directory.

psqlscan module was originally designed for frontend programs and uses
malloc directly. So I changed them so that it calls palloc and
friends. Additionally pgstrcasecmp.c and pqexpbuffer.c are also
imported. They are used by psqlscan.

The example usage of psqlscan can be found in
multi_statement_query():src/protocol/pool_proto_modules.c.

Discussion:
https://www.pgpool.net/pipermail/pgpool-hackers/2023-February/004291.html
Discussion: https://www.pgpool.net/pipermail/pgpool-hackers/2023-April/004320.html

2 years agoTest: skip the test if there's no test.sh.
Tatsuo Ishii [Sat, 15 Apr 2023 07:26:23 +0000 (16:26 +0900)]
Test: skip the test if there's no test.sh.

This is useful when developers want to run the test on git repository
because the check suppresses false positive errors. There could newer
branch's test directories remain without any contents and regress.sh
reports wrong failures.

2 years agoDoc: fix PostgreSQL version of the previous commit.
Bo Peng [Fri, 14 Apr 2023 05:26:48 +0000 (14:26 +0900)]
Doc: fix PostgreSQL version of the previous commit.

2 years agoDoc: Enhancing installation documentation.
Bo Peng [Fri, 14 Apr 2023 04:00:59 +0000 (13:00 +0900)]
Doc: Enhancing installation documentation.
- add detailed decriptions of packages
- mention that  pgpool-II-pgXX-extensions needs to be installed on PostgreSQL servers

2 years agoDoc: add "Backing up PostgreSQL database" section to "Server Setup and Operation...
Tatsuo Ishii [Thu, 13 Apr 2023 00:25:09 +0000 (09:25 +0900)]
Doc: add "Backing up PostgreSQL database" section to "Server Setup and Operation" chapter.

2 years agoDoc: remove the configuration of "- D" start OPTS from "8.2. Pgpool-II + Watchdog...
Bo Peng [Thu, 13 Apr 2023 09:00:08 +0000 (18:00 +0900)]
Doc: remove the configuration of "- D" start OPTS from "8.2. Pgpool-II + Watchdog Setup Example".

2 years agoFix occasional 005.jdbc test failure.
Tatsuo Ishii [Thu, 6 Apr 2023 03:43:06 +0000 (12:43 +0900)]
Fix occasional 005.jdbc test failure.

The direct cause of the error is:
2023-02-22 08:51:47.705: PostgreSQL JDBC Driver pid 12420: LOG:  Parse: Error or notice message from backend: : DB node id: 0 backend pid: 12488 statement: "COMMIT" message: "prepared statement "S_1" already exists"

Actually the root of the error is this:
 2023-02-22 08:51:45.242: PostgreSQL JDBC Driver pid 12420: LOG:  pool_send_and_wait: Error or notice message from backend: : DB node id: 0 backend pid: 12488 statement: "DISCARD ALL" message: "DISCARD ALL cannot be executed within a pipeline"

"DISCARD ALL" was generated by pgpool (reset_query_list) to discard
some objects including prepared statements created in the
session. Since DISCARD ALL failed, the prepared statement S_1 was not
removed. Thus the next session failed because S_1 already existed.

To fix this, new global boolean flag reset_query_error is
introduced. The flag is set inside pool_send_and_wait() when a reset
query executed by SimpleQuery() results in ERROR. If the flag is true,
backend_cleanup() discards the backend connection so that any objects,
including named statement, corresponding to the session is discarded

Discussion: https://www.pgpool.net/pipermail/pgpool-hackers/2023-February/004293.html

2 years agoDoc: fix restrictions section.
Tatsuo Ishii [Sun, 9 Apr 2023 02:36:30 +0000 (11:36 +0900)]
Doc: fix restrictions section.

- Add mention about SCRAM-SHA-256 authentication
- Add mention about snapshot isolation mode

2 years agoDoc: add index for online recovery.
Tatsuo Ishii [Mon, 3 Apr 2023 23:21:28 +0000 (08:21 +0900)]
Doc: add index for online recovery.

2 years agoMore schema qualification fix.
Tatsuo Ishii [Thu, 30 Mar 2023 00:15:42 +0000 (09:15 +0900)]
More schema qualification fix.

This is a follow up to:
https://git.postgresql.org/gitweb/?p=pgpool2.git;a=commit;h=49ca4800d1a804c1f6ef5807d9fbeeef85888fb6

Back patch to all supported branches: 4.4 to 4.0

2 years agoUse schema qualification for internal queries.
Tatsuo Ishii [Tue, 28 Mar 2023 01:55:59 +0000 (10:55 +0900)]
Use schema qualification for internal queries.

Some of objects such as function and cast did not use "pg_catalog."
schema qualification.  This does not lead to immediate security
concern but using the schema qualification is always good practice.

Not that for this I had to increase some buffer length:

- POOL_RELCACHE.query was changed from 1024 to 1500.
- query buffer size in pool_search_relcache was changed from 1024 to 1500.

Back patch to all supported branches: 4.4 to 4.0

2 years agoDoc: fix typo in the description of backend_application_name.
Tatsuo Ishii [Tue, 28 Mar 2023 00:49:08 +0000 (09:49 +0900)]
Doc: fix typo in the description of backend_application_name.

2 years agoFix compile error on systems using musl libc.
Tatsuo Ishii [Wed, 22 Mar 2023 11:53:38 +0000 (20:53 +0900)]
Fix compile error on systems using musl libc.

Patch provided by leimaohui.
https://www.pgpool.net/mantisbt/view.php?id=790

2 years agoDoc: mention that AES256 support requires --with-openssl option.
Tatsuo Ishii [Wed, 22 Feb 2023 01:20:15 +0000 (10:20 +0900)]
Doc: mention that AES256 support requires --with-openssl option.

2 years agoDoc: add index for "AES256".
Tatsuo Ishii [Tue, 21 Feb 2023 08:25:20 +0000 (17:25 +0900)]
Doc: add index for "AES256".

Also fix previous commit for adding index ".pcppass" and "PCPPASSFILE".

2 years agoDoc: explicitly stat that it is -w option of pcp command is needed to use .pcppass.
Tatsuo Ishii [Tue, 21 Feb 2023 05:49:02 +0000 (14:49 +0900)]
Doc: explicitly stat that it is -w option of pcp command is needed to use .pcppass.

Also add .pcppass and PCPPASSFILE to index.

Backpatch-through: master and 4.4 to 4.0.

2 years agoFix that show pool_version shows row description twice.
Tatsuo Ishii [Sat, 18 Feb 2023 07:34:14 +0000 (16:34 +0900)]
Fix that show pool_version shows row description twice.

test=# show pool_version;
 pool_version
--------------
(0 rows)

     pool_version
-----------------------
 4.3.5 (tamahomeboshi)
(1 row)

2 years agoAllow to use multiple statements extensively.
Tatsuo Ishii [Sun, 12 Feb 2023 10:59:00 +0000 (19:59 +0900)]
Allow to use multiple statements extensively.

This commit tries to eliminate pgpool's long standing limitations
regarding multiple statements (multi-statements).

Previously

BEGIN;SELECT;
SAVEPOINT foo;

will fail in streaming replication mode because "BEGIN" was sent to
the primar node, but "SAVEPOINT" will be sent to both the primary and
standbys, and standbys will complain "SAVEPOINT can only be used in
transaction blocks".

Basic idea to solve the problem is, tracking explicit transactions
started by multi-statement queries so that all commands including
PREPARE, EXECUTE, DEALLOCATE, SAVEPOINT and COMMIT/ROLLBACK are sent
to the primary node in streaming replication mode or logical
replication mode.  In native replication or snapshot isolation mode,
those queries are sent to all of the backend nodes.

For this purpose new member: is_tx_started_by_multi_statement is added
to session context and also support functions are added.

extern bool is_tx_started_by_multi_statement_query(void);
extern void set_tx_started_by_multi_statement_query(void);
extern void unset_tx_started_by_multi_statement_query(void);

Discussion: https://www.pgpool.net/pipermail/pgpool-hackers/2023-February/004287.html
Back-patch-through: 4.2 as backport to 4.1 and before looks difficult

2 years agoFix multiple query cache bug.
Tatsuo Ishii [Sun, 5 Feb 2023 09:56:05 +0000 (18:56 +0900)]
Fix multiple query cache bug.

1) pool_add_item_shmem_cache() calls pool_init_cache_block() when
   there's no free cache item hash table entry. But this is
   unnecessary since pool_reuse_block() is already called from
   pool_add_item_shmem_cache(). This is actually harmless because the
   second pool_init_cache_block() call just set the same data as the
   first call of pool_init_cache_block(). It's just a waste of CPU
   cycle.

2) The cache blocks are supposed to be initialized while Pgpool-II
   starts up but actually not. Each cache block has the free space
   length in the block header after initialization. Since the free
   space length is not set, pool_get_block() fails to find a cache
   block which has enough free space, and it calls pool_reuse_block(),
   which is actually unnecessary (you will see something like
   "pool_reuse_block: blockid: 0" in pgpool log). Since
   pool_reuse_block() returns a free block anyway, this is just a
   waste of CPU cycle but better to fix.

Discussion: https://www.pgpool.net/pipermail/pgpool-hackers/2023-January/004259.html
Backpatch-through: 4.0

2 years agoFix sr worker to not send wrong query to standby server in corner case.
Tatsuo Ishii [Sun, 5 Feb 2023 07:13:15 +0000 (16:13 +0900)]
Fix sr worker to not send wrong query to standby server in corner case.

When ALWAYS_PRIMARY flag is set, PRIMARY_NODE_ID macro returns node
id, rather than -1 even if the primary is down. This confuses the test
if a node is primary or not, because PRIMARY_NODE_ID macro returns
main node id.  In this case streaming replication delay check worker
sends "SELECT pg_current_wal_lsn()" or "SELECT
pg_current_xlog_location()" depending on PostgreSQL's version to
standby which of course raises an error.

To fix this, test the primary node is down or not, and if it's down,
skip the replication delay loop. If primary is down, there's no point
to perform streaming replication delay checking anyway.

Discussion: https://www.pgpool.net/pipermail/pgpool-hackers/2023-February/004279.html
Backpatch-through: 4.0

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 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:36:42 +0000 (00:36 +0900)]
Fix compile error of regression test

The error occurred by timestamp test using gcc10.

2 years agoPrepare 4.2.12 V4_2_12 V4_2_12_RPM
Bo Peng [Sat, 21 Jan 2023 15:28:36 +0000 (00:28 +0900)]
Prepare 4.2.12

2 years agoDoc: Bump version to 4.2.12
Bo Peng [Sat, 21 Jan 2023 15:28:23 +0000 (00:28 +0900)]
Doc: Bump version to 4.2.12

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

2 years agoDoc: Add release notes.
Bo Peng [Sat, 21 Jan 2023 15:27:59 +0000 (00:27 +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 15:24:03 +0000 (00:24 +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 15:23:49 +0000 (00:23 +0900)]
Do not expose wd_lifecheck_password in show pool_status command.

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 agoAdd patch files to EXTRA_DIST.
Bo Peng [Mon, 16 Jan 2023 13:51:21 +0000 (22:51 +0900)]
Add patch files to EXTRA_DIST.

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

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 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 "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 agoFix SPEC file typo.
Bo Peng [Sun, 25 Dec 2022 11:33:24 +0000 (20:33 +0900)]
Fix SPEC file typo.

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 agoFix SPEC file typo.
Bo Peng [Fri, 23 Dec 2022 14:16:43 +0000 (23:16 +0900)]
Fix SPEC file typo.

2 years agoFix SPEC file typo.
Bo Peng [Fri, 23 Dec 2022 07:51:01 +0000 (16:51 +0900)]
Fix SPEC file typo.

2 years agoUpdate SPEC file to change /lib/tmpfiles.d/ file from /var/run to /run.
Bo Peng [Fri, 23 Dec 2022 07:28:52 +0000 (16:28 +0900)]
Update SPEC file to change /lib/tmpfiles.d/ file from /var/run to /run.

2 years agoPrepare 4.2.11 V4_2_11 V4_2_11_RPM
Bo Peng [Thu, 22 Dec 2022 06:46:33 +0000 (15:46 +0900)]
Prepare 4.2.11

2 years agoDoc: Bump doc version to 4.2.11
Bo Peng [Thu, 22 Dec 2022 06:42:05 +0000 (15:42 +0900)]
Doc: Bump doc version to 4.2.11

2 years agoDoc: update repo package version.
Bo Peng [Thu, 22 Dec 2022 06:28:38 +0000 (15:28 +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 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: 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 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 agoFix typo in comments.
Tatsuo Ishii [Sat, 10 Dec 2022 06:23:30 +0000 (15:23 +0900)]
Fix typo in comments.

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 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 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 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 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

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 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.

3 years agoFix to not allow Unix-domain socket path with invalid length.
Masaya Kawamoto [Mon, 12 Sep 2022 09:18:21 +0000 (09:18 +0000)]
Fix to not allow Unix-domain socket path with invalid length.

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 agoDoc: fix typo.
Bo Peng [Thu, 18 Aug 2022 05:18:20 +0000 (14:18 +0900)]
Doc: fix typo.

3 years agoPrepare 4.2.10 V4_2_10 V4_2_10_RPM
Bo Peng [Wed, 17 Aug 2022 08:30:52 +0000 (17:30 +0900)]
Prepare 4.2.10

3 years agoDoc: update doc version.
Bo Peng [Wed, 17 Aug 2022 08:23:58 +0000 (17:23 +0900)]
Doc: update doc version.

3 years agoSetting PGPOOLDIR before using it set SAMPLE_CONF when TEST_SAMPLES is enabled.
Bo Peng [Wed, 17 Aug 2022 07:29:15 +0000 (16:29 +0900)]
Setting PGPOOLDIR before using it set SAMPLE_CONF when TEST_SAMPLES is enabled.

3 years agoDoc: add release notes.
Bo Peng [Tue, 16 Aug 2022 05:45:17 +0000 (14:45 +0900)]
Doc: add release notes.

3 years agoDoc: enhance description in the memory requirement section.
Tatsuo Ishii [Tue, 26 Jul 2022 06:23:40 +0000 (15:23 +0900)]
Doc: enhance description in the memory requirement section.

Add explanation about memory usage while pgpool child process is running.

3 years agoDoc: fix typo.
Tatsuo Ishii [Tue, 26 Jul 2022 02:31:44 +0000 (11:31 +0900)]
Doc: fix typo.

3 years agoDoc: mention that certain SELECTs are not cached.
Tatsuo Ishii [Tue, 19 Jul 2022 13:14:41 +0000 (22:14 +0900)]
Doc: mention that certain SELECTs are not cached.

SELECTs including TIMESTAMP WITH TIMEZONE or TIME WITH TIMEZONE
SELECTs including CAST to TIMESTAMP WITH TIMEZONE or TIME WITH TIMEZONE
SELECTs including SQLValueFunction (CURRENT_TIME, CURRENT_USER etc.)

3 years agoTest: print Pgpool-II version in the regression test.
Tatsuo Ishii [Sun, 10 Jul 2022 07:04:49 +0000 (16:04 +0900)]
Test: print Pgpool-II version in the regression test.

3 years agoTest: Fix regression test script to look for pgpool.conf in the proper install directory.
Tatsuo Ishii [Sat, 9 Jul 2022 09:41:18 +0000 (18:41 +0900)]
Test: Fix regression test script to look for pgpool.conf in the proper install directory.

regress.sh did set PGPOOLDIR environment variable despite that
pgpool_setup look for pgpool.conf sample files at $PGPOOLDIR/etc. As a
result, pgpool_setup looked for pgpool.conf.sample at default install
directory (usually /usr/local/etc) even if "-m noinstall" is not
set. If inappropriate pgpool.conf sample files are in
/usr/local/etc., regression test fails.

3 years agoFix to not cache SELECT having functions with return types are timestamptz or timetz.
Tatsuo Ishii [Wed, 6 Jul 2022 12:31:08 +0000 (21:31 +0900)]
Fix to not cache SELECT having functions with return types are timestamptz or timetz.

Functions with return type is timestamptz or timetz is affected by time zone setting.
Consider following scenario:

1) SELECT having such functions gets called and cache created.

2) time zone is changed.

3) same SELECT is called and the cache is used. The cache value is
correct any more because of the time zone change.

Discussion: https://www.pgpool.net/pipermail/pgpool-general/2022-July/008367.html

3 years agoFix query cache to not cache timestamptz and timetz cast.
Tatsuo Ishii [Tue, 5 Jul 2022 05:06:10 +0000 (14:06 +0900)]
Fix query cache to not cache timestamptz and timetz cast.

Even if query is constant + cast (like '2022-07-05
14:07:00'::timestamptz), the result can be changed by SET TIME ZONE
command etc. and the result should not be cached.
Also regression test data added.

Discussion: https://www.pgpool.net/pipermail/pgpool-general/2022-July/008353.html

3 years agoFix bug in query cache.
Tatsuo Ishii [Mon, 4 Jul 2022 05:23:48 +0000 (14:23 +0900)]
Fix bug in query cache.

[pgpool-general: 8285] Timestamp cast not cached

reported that query like "Select '2022-02-18
07:00:00.006547’::timestamp" is not cached.

The function non_immutable_function_call_walker() which judges whether
the query contains non immutable functions mistakenly assumes that any
query including cast to timestamp etc. should not to be cached. These
codes were originally added to detect CURRENT_TIMESTAMP etc. as they
are transformed to type cast in raw parser. Unfortunately this is
overkill since "'2022-02-18 07:00:00.006547’::timestamp" is also
transformed to a type cast.

Fortunately Pgpool-II 3.7 and after imported PostgreSQL 10 or newer
parser, which transforms CURRENT_TIMESTAMP etc. to SQLValueFunction.

As a result, the type cast handling code in
non_immutable_function_call_walker() is not necessary anymore. So this
commit removed the code.

Note: an interested thing in the report is, "Select '2022-02-18
07:00:00.006547’::timestamp" is not cached while "Select '2022-02-18
07:00:00.006547’::date" is cached. Why? Well
non_immutable_function_call_walker() (wrongly) assumes that the type
cache is always created by SystemTypeName (a parser's function), which
always adds pg_catalog schema. This only happens when the type name is
a reserved keyword. TIMESTAMP is a reserved keyword (and TIME too). So
non_immutable_function_call_walker() catches TIMESTAMP cast as
expected, but DATE is not a reserved keyword and it is transformed to
type name without "pg_catalog" schema. So
non_immutable_function_call_walker() misses it, and it is cached.

3 years agoAdd ssh options to restore_command in sample scripts.
Bo Peng [Sun, 3 Jul 2022 12:09:17 +0000 (21:09 +0900)]
Add ssh options to restore_command in sample scripts.

Patch is created by Jon SCHEWE and updated by Bo Peng.

3 years agoDoc: fix description about using PCP password file when connect to Unix domain socket
Masaya Kawamoto [Thu, 30 Jun 2022 03:58:37 +0000 (03:58 +0000)]
Doc: fix description about using PCP password file when connect to Unix domain socket

The localhost entry in pcppass matches only for the default PCP socket
directory path, not all Unix socket connections. This behavior is the
same as pgpass.

3 years agoAllow to run pgpool_setup on PostgreSQL 15.
Tatsuo Ishii [Sun, 26 Jun 2022 09:11:08 +0000 (18:11 +0900)]
Allow to run pgpool_setup on PostgreSQL 15.

basebackup.sh created by pgpool_setup uses pg_start_backup() and
pg_stop_backup().  PostgreSQL 15 renamed them. But there's more
problem. The renamed functions (pg_backup_start() and
pg_backup_stop()) must be called within a same connection. Adapting
these requires non-trivial changes. So I decided to rewrite the code
to not use pg_start_backup() and pg_stop_backup() so that it uses
pg_basebackup command instead.

Per https://www.pgpool.net/mantisbt/view.php?id=757

3 years agoAllow pgpool_setup to test sample scripts and sample config files contained in RPMs.
Bo Peng [Sun, 19 Jun 2022 09:51:38 +0000 (18:51 +0900)]
Allow pgpool_setup to test sample scripts and sample config files contained in RPMs.

Currently, pgpool_setup generates scripts (e.g. failover.sh, follow_primary.sh) to test pgpool.

This commit addes a new option "-c" in src/test/regression/regress.sh
and a new environment variables TEST_SAMPLES in pgpool_setup.
Option "-c" enables TEST_SAMPLES and allows pgpool_setup to test sample scripts and
sample config files contained in RPMs.

This commit also changes "backend_hostnameX = '/tmp'" to "backend_hostnameX = 'localhost'".

3 years agoAdd pool_config.c to src/tools/pgmd5/.gitignore.
Tatsuo Ishii [Mon, 13 Jun 2022 07:09:46 +0000 (16:09 +0900)]
Add pool_config.c to src/tools/pgmd5/.gitignore.

This should avoid the error:
error: The following untracked working tree files would be overwritten by checkout:
src/tools/pgmd5/pool_config.c

3 years agoDoc: fix memory requirement section.
Tatsuo Ishii [Mon, 6 Jun 2022 13:06:37 +0000 (22:06 +0900)]
Doc: fix memory requirement section.

- enhance the formula to calculate shared memory requirement so that it computes more accurate result.

- fix shared memory requirement for shared rel cache. The old value 64MB was simply wrong.

- fix process memory requirement. Previously the formula was based on
  RSS. However PSS should be used because RSS includes shared memory
  such as the memory used for libraries. This resuls in lot smaller
  memory requirement than before.

3 years agoAllow to rewrite archive_command in sample scripts.
Bo Peng [Sun, 5 Jun 2022 13:51:52 +0000 (22:51 +0900)]
Allow to rewrite archive_command in sample scripts.