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

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

Per bug 565.

6 years agoFix missing syslog setting. V3_4_26_RPM2
Bo Peng [Mon, 18 Nov 2019 09:09:46 +0000 (18:09 +0900)]
Fix missing syslog setting.

6 years agoPrepare 3.4.26-2.
Bo Peng [Mon, 18 Nov 2019 01:08:27 +0000 (10:08 +0900)]
Prepare 3.4.26-2.

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

per bug557.

6 years agoPrepare 3.4.26. V3_4_26 V3_4_26_RPM
Bo Peng [Thu, 31 Oct 2019 00:35:47 +0000 (09:35 +0900)]
Prepare 3.4.26.

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

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

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

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

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

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

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

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

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

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

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

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

6 years agoFix signal unblock leak in failover.
Tatsuo Ishii [Thu, 3 Oct 2019 12:33:09 +0000 (21:33 +0900)]
Fix signal unblock leak in failover.

When failover event occurs, register_node_operation_request() gets
called to en-queue failover/failback requests. If the request queue is
full, this function returns false with unlocking semaphore. But it
forgot to unblock signal mask. This leads to block all signals
including SITERM, which makes pgpool fail to shutdown.

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

6 years agoFix memory leak in replication mode.
Tatsuo Ishii [Wed, 25 Sep 2019 05:22:21 +0000 (14:22 +0900)]
Fix memory leak in replication mode.

Per coverity.

6 years agoFix memory leak while attempting to connect to backend.
Tatsuo Ishii [Tue, 24 Sep 2019 23:49:48 +0000 (08:49 +0900)]
Fix memory leak while attempting to connect to backend.

If no backend is up and running, memory for copy of startup packet
will be lost. This was brought by commit cdb49d3b7. Per coverity.

6 years agoFix compiler warnings.
Tatsuo Ishii [Tue, 17 Sep 2019 23:07:27 +0000 (08:07 +0900)]
Fix compiler warnings.

6 years agoRevert "Fix occasional query hang while processing DEALLOCATE."
Tatsuo Ishii [Mon, 16 Sep 2019 22:23:03 +0000 (07:23 +0900)]
Revert "Fix occasional query hang while processing DEALLOCATE."

This reverts commit 14a7b822530878069ab14dca99e0fb26fc6597ee.

6 years agoFix occasional query hang while processing DEALLOCATE.
Tatsuo Ishii [Mon, 16 Sep 2019 00:24:08 +0000 (09:24 +0900)]
Fix occasional query hang while processing DEALLOCATE.

When DEALLOCATE tries to remove a named statement, it inherits
where_to_send map of the named statement in
where_to_send_deallocate(). However it forgot to copy the load balance
node id in the query context of the named statement. This made sending
query to backend not happen: if the target node id is different from
query_context->load_balance_node_id nor primary node id,
pool_virtual_master_db_node_id (it is called as MASTER_NODE_ID)
returns primary node id, and pool_send_and_wait(MASTER_NODE_ID)
ignores the request because VALID_BACKEND returns false in this case
(MASTER_NODE_ID = primary node id is not in the where_to_send map). As
a result, following check_error() waits for response from backend in
vain.

Fix is, let where_to_send_deallocate() copy load balance node id from
the query context of the previous named statement.

Per bug 546.

6 years agoFix segfault in certain case.
Tatsuo Ishii [Sun, 15 Sep 2019 13:39:18 +0000 (22:39 +0900)]
Fix segfault in certain case.

The scenario is something like:

1) a named statement is created.
2) DEALLOCATE removes it.
3) an erroneous query is executed.

In #2, "sent message" for the named statement is removed but
"uncompleted_message" is left. Then after #3, in ReadyForQuery()
uncompleted_message is added and removed. However, storage for the
uncompleted_message has been already freed in #2, and it causes a
segfault.

Fix is, in SimpleQuery() set NULL to uncompleted_message if it's not
PREPARE command so that ReadyForQuery() does not try to remove the
already removed message.

Per bug 546.

Here is a minimum test case.

'P' "_plan0x7f2d465db530" "SELECT 1" 0
'S'
'Y'
'Q' "DEALLOCATE _plan0x7f2d465db530"
'Y'
'Q' "CREATE INDEX users_auth_id_index ON non_existing_table ( auth_id )"
'Y'
'X'

6 years agoFix identical code used for different branches per Coverity.
Tatsuo Ishii [Thu, 12 Sep 2019 04:40:05 +0000 (13:40 +0900)]
Fix identical code used for different branches per Coverity.

6 years agoFix memory leak per Coverity.
Tatsuo Ishii [Thu, 12 Sep 2019 04:39:41 +0000 (13:39 +0900)]
Fix memory leak per Coverity.

6 years agoFix uninitialized variable.
Tatsuo Ishii [Fri, 6 Sep 2019 06:24:09 +0000 (15:24 +0900)]
Fix uninitialized variable.

Probably harmless but bug is bug...
Per Coverity.

6 years agoFix pgpool_setup to reflect the -p (baseport) to ORIGBASEPORT variable.
Tatsuo Ishii [Sun, 1 Sep 2019 02:38:35 +0000 (11:38 +0900)]
Fix pgpool_setup to reflect the -p (baseport) to ORIGBASEPORT variable.

Otherwise, shutdown generated script by pgpool_setup does not use
proper port number for netstat command.

6 years agoPrepare 3.4.25. V3_4_25 V3_4_25_RPM
Bo Peng [Thu, 15 Aug 2019 04:42:05 +0000 (13:42 +0900)]
Prepare 3.4.25.

6 years agoFix memory leak.
Tatsuo Ishii [Wed, 14 Aug 2019 00:14:36 +0000 (09:14 +0900)]
Fix memory leak.

Pointed out by Coverity.

6 years agoMake waiting for TIME_WAIT in pgpool_setup optional.
Tatsuo Ishii [Thu, 8 Aug 2019 02:38:02 +0000 (11:38 +0900)]
Make waiting for TIME_WAIT in pgpool_setup optional.

Since commit 3b32bc4e583da700cc8df7c5777e90341655ad3b the shutdownall
script generated by pgpool_setup waits for Pgpool-II socket in
TIME_WAIT state disappeared. However in most cases this takes long
time and it makes uncomfortable for developer's testing works.

This commit makes the wait to be optional: unless environment variable
"CHECK_TIME_WAIT" is set to other than "false", it never waits for the
TIME_WAIT state.

6 years agoImport some of memory manager debug facilities from PostgreSQL.
Tatsuo Ishii [Thu, 8 Aug 2019 02:02:50 +0000 (11:02 +0900)]
Import some of memory manager debug facilities from PostgreSQL.

Now we can use CLOBBER_FREED_MEMORY, which is useful to detect
accesses to already pfreed memory.

6 years agoFix pgpool_setup to produce correct follow master command.
Tatsuo Ishii [Sun, 28 Jul 2019 02:11:07 +0000 (11:11 +0900)]
Fix pgpool_setup to produce correct follow master command.

The produced script incorrectly checked whether PostgreSQL is running
or not, which resulted in that it mistakenly thought PostgreSQL is
always running.

6 years agoFix regression test errors.
Bo Peng [Thu, 25 Jul 2019 00:19:53 +0000 (09:19 +0900)]
Fix regression test errors.

6 years agoUse pg_get_expr() instead of pg_attrdef.adsrc to support for PostgreSQL 12.
Bo Peng [Wed, 24 Jul 2019 12:19:26 +0000 (21:19 +0900)]
Use pg_get_expr() instead of pg_attrdef.adsrc to support for PostgreSQL 12.

Since PostgreSQL 12 removed pg_attrdef.adsrc, use pg_get_expr() instead of pg_attrdef.adsrc if the backend version is 7.3 or later.

Thanks to Takuma Hoshiai for creating the patch.

6 years agoFix the failover() so that it does not access out of array.
Tatsuo Ishii [Wed, 17 Jul 2019 07:51:31 +0000 (16:51 +0900)]
Fix the failover() so that it does not access out of array.

Per Coverity.

6 years agoEnhance shutdown script of pgpool_setup.
Tatsuo Ishii [Wed, 17 Jul 2019 07:48:37 +0000 (16:48 +0900)]
Enhance shutdown script of pgpool_setup.

I observe occasional regression test failure caused by bind error to
the TCP/IP port.  This fix tries to confirm usage of the TCP/IP port
while executing shutdown script using netstat command.

6 years agoBackport Pgversion().
Tatsuo Ishii [Tue, 16 Jul 2019 06:21:10 +0000 (15:21 +0900)]
Backport Pgversion().

6 years agoFix possible out of array index access.
Tatsuo Ishii [Sun, 7 Jul 2019 13:58:35 +0000 (22:58 +0900)]
Fix possible out of array index access.

It was pointed out by Coverity that node_id could be -1.

6 years agoFix query cache module so that it checks oid array's bound.
Tatsuo Ishii [Sun, 7 Jul 2019 01:09:25 +0000 (10:09 +0900)]
Fix query cache module so that it checks oid array's bound.

6 years agoFix off-by-one error in query cache module.
Tatsuo Ishii [Sat, 6 Jul 2019 23:08:25 +0000 (08:08 +0900)]
Fix off-by-one error in query cache module.

When debug print is enabled, it might had tried to access out of bound
of oid array.

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 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 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 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 agoRevert "Fix memory leak pointed out by coverity."
Tatsuo Ishii [Wed, 22 May 2019 07:40:53 +0000 (16:40 +0900)]
Revert "Fix memory leak pointed out by coverity."

This reverts commit 9ce592cd05b8ea53fef581d2f0373efa39fe8722.

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 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 agoPrepare 3.4.24. V3_4_24 V3_4_24_RPM
Bo Peng [Wed, 15 May 2019 07:01:13 +0000 (16:01 +0900)]
Prepare 3.4.24.

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 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: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 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 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 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 agoFix to compare wrong variable, when old pgpool_status file read.
Takuma Hoshiai [Wed, 10 Apr 2019 02:53:46 +0000 (11:53 +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 agoUpdate Makefile.
Bo Peng [Tue, 2 Apr 2019 00:33:49 +0000 (09:33 +0900)]
Update Makefile.

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 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 "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 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 agoPrepare 3.4.23. V3_4_23 V3_4_23_RPM
Bo Peng [Thu, 28 Mar 2019 09:35:04 +0000 (18:35 +0900)]
Prepare 3.4.23.

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 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 agoFix unnecessary fsync to pgpool_status file.
Tatsuo Ishii [Mon, 18 Mar 2019 00:45:51 +0000 (09:45 +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

6 years agoAdd "tags" to gitignore file.
Bo Peng [Thu, 14 Mar 2019 05:21:59 +0000 (14:21 +0900)]
Add "tags" to gitignore file.

6 years agoFix some mistakes from previous commit.
Bo Peng [Thu, 7 Mar 2019 02:26:17 +0000 (11:26 +0900)]
Fix some mistakes from previous commit.

6 years agoFix indent of pgpool.conf sample files.
Bo Peng [Thu, 7 Mar 2019 01:27:31 +0000 (10:27 +0900)]
Fix indent of pgpool.conf sample files.

6 years agoFix write_status_file()'s signature.
Tatsuo Ishii [Wed, 27 Feb 2019 00:38:15 +0000 (09:38 +0900)]
Fix write_status_file()'s signature.

It was mistakenly declared as write_status_file(). Of course this
should be: write_status_file(void).

6 years agoPrepare 3.4.22. V3_4_22 V3_4_22_RPM
Bo Peng [Thu, 21 Feb 2019 01:09:04 +0000 (10:09 +0900)]
Prepare 3.4.22.

6 years agoFix configuration change timing regarding memory_cache_enabled.
Tatsuo Ishii [Fri, 15 Feb 2019 05:26:55 +0000 (14:26 +0900)]
Fix configuration change timing regarding memory_cache_enabled.

This parameter must not be changed after Pgpool-II start but it was
possible to change by reloading.

6 years agoFix unwanted recovery timeout in certain cases.
Tatsuo Ishii [Tue, 12 Feb 2019 07:59:35 +0000 (16:59 +0900)]
Fix unwanted recovery timeout in certain cases.

In the second stage of online recovery in replication mode, it is
possible it fails with timeout (message: "wait_connection_closed:
existing connections did not close in %d sec.") if connection counter
is malformed by a child process aborts with SIGKILL, SEGFAULT or etc.
This could be detected by checking if client_idle_limit_in_recovery is
enabled and it has less value than recovery_timeout because all
clients must be kicked out by the time when
client_idle_limit_in_recovery is expired. If so, we should reset
conn_counter to 0 also.

Per bug 431.

6 years agoFix corner case bug with strip_quote().
Tatsuo Ishii [Tue, 29 Jan 2019 08:20:41 +0000 (17:20 +0900)]
Fix corner case bug with strip_quote().

strip_quote(), which is called by pattern_compare() did not properly
handle empty query string case. In the worst case it could wipe out
memory after a pointer returned from malloc(), which could cause a
segmentation fault in free() called in pattern_compare().

Per bug 458.

6 years agoFix Pgpool child segfault in a race condition.
Tatsuo Ishii [Thu, 10 Jan 2019 03:20:07 +0000 (12:20 +0900)]
Fix Pgpool child segfault in a race condition.

1) frontend tries to connect to Pgpool-II

2) there's no existing connection cache

3) try to create new backend connections by calling connect_backend()

4) inside connect_backend(), pool_create_cp() gets called

5) pool_create_cp() calls new_connection()

6) failover occurs and the global backend status is set to down, but
   the pgpool main does not send kill signal to the child process yet

7) inside new_connection() after checking VALID_BACKEND, it checks the
   global backend status and finds it is set to down status, so that
   it returns without creating new connection slot

8) connect_backend() continues and accesses the down connection slot
   because local status says it's alive, which results in a segfault.

Since there's already checking for the global status in
new_connection(), a fix could be syncing the local status with the
global status there.

See [pgpool-hackers: 3214] for discussion.

7 years agoDeal with "terminating connection due to idle-in-transaction timeout" error.
Tatsuo Ishii [Thu, 6 Dec 2018 08:20:32 +0000 (17:20 +0900)]
Deal with "terminating connection due to idle-in-transaction timeout" error.

If idle_in_transaction_session_timeout parameter is set to reasonably
short in postgresql.conf, the fatal error easily occurs and the
connection from Pgpool-II to backend is terminated. This leads to
Pgpool-II either hang (if only one of PostgreSQL equips equips the
parameter) or unwanted failover (if all PostgreSQL equips with the
parameter), and both are not good. So intercept the message and send
the same message to frontend then exit to terminate the connection to
frontend. This is similar treatment as the error "connection was
terminated due to conflict with recovery, User was holding a relation
lock for too long."

Per bug 448.

7 years agoPrepare 3.4.21. V3_4_21 V3_4_21_RPM
Bo Peng [Wed, 21 Nov 2018 08:48:36 +0000 (17:48 +0900)]
Prepare 3.4.21.

7 years agoChange sort algorism buble sort to quick sort.
Takuma Hoshiai [Wed, 21 Nov 2018 07:48:35 +0000 (16:48 +0900)]
Change sort algorism buble sort to quick sort.

This is used to sort startup packet's parameters.

7 years agoFix to sort startup packet's parameters sent by client.
Takuma Hoshiai [Wed, 21 Nov 2018 02:35:58 +0000 (11:35 +0900)]
Fix to sort startup packet's parameters sent by client.

If order of startup packet's  parameters differ between cached connection pools and connection request, did't use connection pool ,and created new connection pool.
Per bug 444.

7 years agoFix memory leak found by Coverity,
Tatsuo Ishii [Thu, 15 Nov 2018 00:21:30 +0000 (09:21 +0900)]
Fix memory leak found by Coverity,

This is actually harmless since in the situation pgpool child process
exits and the leaked memory is gone anyway.  I just want to shut off
Coverity's complain.

7 years agoFix segmentation fault occurs when a certain Bind message is sent in native replicati...
Bo Peng [Tue, 13 Nov 2018 01:54:05 +0000 (10:54 +0900)]
Fix segmentation fault occurs when a certain Bind message is sent in native replication mode.

If the number of parameter format codes is specified to one, but the number of the original query's
parameter is zero, bind_rewrite_timestamp() will call memcpy with a negative value for size_t.
This causes segmentation fault.

Patch is provided by Yugo Nagata.
Per bug 443.

7 years agoFix a query passed to relcache so that it uses schema qualified table name.
Tatsuo Ishii [Thu, 8 Nov 2018 05:37:18 +0000 (14:37 +0900)]
Fix a query passed to relcache so that it uses schema qualified table name.

This should have been done for all similar queries to follow PostgreSQL's schema usage pattern.
However there was one missed at that time.

7 years agoFix query cache invalidation bug.
Tatsuo Ishii [Mon, 5 Nov 2018 12:43:01 +0000 (21:43 +0900)]
Fix query cache invalidation bug.

When a DML is executed in an explicit transaction, the table oid
buffer is wiped out by pool_reset_memqcache_buffer() and query cache
is not invalidated at the commit time because there's no DML oid
exists to invalidate query cache any more. To fix this, add new bool
parameter to pool_reset_memqcache_buffer() to specify whether to reset
table oid buffer or not. When a DML is executed in an explicit
transaction, call pool_reset_memqcache_buffer(false) to preserve the
table oid buffer.

Issue reported at https://github.com/pgpool/pgpool2/issues/19.

7 years agoFix memory leak in extended query + query cache enabled.
Tatsuo Ishii [Thu, 1 Nov 2018 00:22:46 +0000 (09:22 +0900)]
Fix memory leak in extended query + query cache enabled.

If a bind message is sent again to an existing prepared statement, it
is possible that the previously allocated bind parameter string
remains and newly allocated bind parameter string's pointer is set to
there, which leads to a memory leak.

Note that if a statement is parsed again in usual way, the parameter
string will be freed along with the old query context. So the leak
does not happen.

I suspect the use case for the memory leak (bind, execute is repeated
against a same prepared statement) is actually rare in the
field. Probably that's why the problem has not been reported until
today although the leak had existed since day 0.

The leak case can be easily reproduced by "pgbench -M prepared" by the
way.

7 years agoChange pgpool.spec. V3_4_20 V3_4_20_RPM
Bo Peng [Wed, 31 Oct 2018 04:40:41 +0000 (13:40 +0900)]
Change pgpool.spec.

7 years agoChange spec file to include pgpool_recovery--1.0.sql and pgpool_recovery--1.0--1...
Bo Peng [Wed, 31 Oct 2018 03:39:34 +0000 (12:39 +0900)]
Change spec file to include pgpool_recovery--1.0.sql and pgpool_recovery--1.0--1.1.sql.

7 years agoAdd pgpool_recovery--1.0.sql and pgpool_recovery--1.0--1.1.sql to tar ball.
Bo Peng [Wed, 31 Oct 2018 03:11:40 +0000 (12:11 +0900)]
Add pgpool_recovery--1.0.sql and pgpool_recovery--1.0--1.1.sql to tar ball.

7 years agoPrepare 3.4.20.
Bo Peng [Wed, 31 Oct 2018 02:17:00 +0000 (11:17 +0900)]
Prepare 3.4.20.

7 years agoFix typo in child_max_connections description.
Tatsuo Ishii [Thu, 25 Oct 2018 10:58:34 +0000 (19:58 +0900)]
Fix typo in child_max_connections description.

Patch provided by Phil Ramirez.

7 years agoFix segmentation fault, when client send sync message in native replication mode.
Takuma Hoshiai [Mon, 22 Oct 2018 08:18:35 +0000 (17:18 +0900)]
Fix segmentation fault, when client send sync message in native replication mode.

When the query to be executed does not exist, if client sent 'Sync' messages to Pgpool-II which in native replication mode, occurred segmentation fault.

See:
https://www.pgpool.net/mantisbt/view.php?id=434
for more details.

7 years agoFix syntax error in native replication, when queries including now() etc. and "IN... origin/V3_4_STABLE
Bo Peng [Thu, 18 Oct 2018 09:12:24 +0000 (18:12 +0900)]
Fix syntax error in native replication, when queries including now() etc. and "IN (SELECT ...)" in WHERE clause.

In native replication, queries including now() etc. are rewritten to a timestamp constant value.
However, Pgpool-II didn't support queries including now() etc. and "IN (SELECT ...)" in WHERE clause.

Per bug433.

7 years ago Change pgpool.spec file to install extension to server which supports LLVM JIT.
Bo Peng [Thu, 18 Oct 2018 08:51:13 +0000 (17:51 +0900)]
 Change pgpool.spec file to install extension to server which supports LLVM JIT.

7 years agoFix memory leak in trigger_failover_command.
Tatsuo Ishii [Tue, 9 Oct 2018 04:49:49 +0000 (13:49 +0900)]
Fix memory leak in trigger_failover_command.

Pointed out by Coverity.

7 years agoFix memory leak when memory_cache_enabled = on and write SQLs are sent.
Bo Peng [Tue, 9 Oct 2018 00:22:31 +0000 (09:22 +0900)]
Fix memory leak when memory_cache_enabled = on and write SQLs are sent.

In a explicit transaction, we the SELECT results are cached in temporary buffer.
If a write SQL is sent which modifies the table, the temporary buffe should be reset.

7 years agoFix occasional failure in regression 065.bug152.
Tatsuo Ishii [Mon, 8 Oct 2018 22:50:03 +0000 (07:50 +0900)]
Fix occasional failure in regression 065.bug152.

In the test first create a table with some data, then query
it. However sometimes it seems replication delay causes the table
still not ready in standby. Since there's no reason we need to a
standby or slave for this particular test, let the test have only
primary/master.

7 years agoAdd missing pgpool_recovery--1.0--1.1.sql file to update pgpool_recovery() function...
Bo Peng [Wed, 19 Sep 2018 00:25:31 +0000 (09:25 +0900)]
Add missing pgpool_recovery--1.0--1.1.sql file to update pgpool_recovery() function version to 1.1.

7 years agoAdd regression test for SSL connection.
Tatsuo Ishii [Wed, 29 Aug 2018 02:58:36 +0000 (11:58 +0900)]
Add regression test for SSL connection.

This tests SSL connection between frontend <--> Pgpool-II and
Pgpool-II <--> backend.

7 years agoDo not update pgpool_passwd if the password length is incorrect.
Tatsuo Ishii [Mon, 27 Aug 2018 06:16:17 +0000 (15:16 +0900)]
Do not update pgpool_passwd if the password length is incorrect.

For Pgpool-II 3.7 or before, the password stored in pool_passwd is MD5
password only.  So check the correctness of pool_passwd by scanning
entire file.

Patch created by Takuma Hoshiai. Minor error message tweak by me.
See bug425 for more details.

7 years agoRemove some .gitignore files which doesn't belong this branch.
Bo Peng [Sat, 11 Aug 2018 00:25:34 +0000 (09:25 +0900)]
Remove some .gitignore files which doesn't belong this branch.

7 years agoAdd definition of PGLIB in regress.sh.
Bo Peng [Fri, 10 Aug 2018 04:16:02 +0000 (13:16 +0900)]
Add definition of PGLIB in regress.sh.
Patch provided by Jesper Pedersen.

7 years agoUpdate clean.sh which clean up regression test results.
Bo Peng [Fri, 10 Aug 2018 03:40:10 +0000 (12:40 +0900)]
Update clean.sh which clean up regression test results.

Patch provided by Jesper Pedersen.

7 years agoAdd .gitignore files.
Bo Peng [Fri, 10 Aug 2018 03:34:32 +0000 (12:34 +0900)]
Add .gitignore files.

Patch provided by Jesper Pedersen.