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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

7 years agoFix segfault when node 0 is in down status.
Tatsuo Ishii [Sun, 5 Aug 2018 01:54:18 +0000 (10:54 +0900)]
Fix segfault when node 0 is in down status.

MASTER_CONNECTION refers to the connection to "master"
node. "Master" means the first live backend appearing in
pgpool.conf. The master node is determined at the time of fail over.
Unfortunately with both health check and fail_over_on_backend_error
are disabled, there's no chance of failover, which means the master
node id is remained the default value 0. So the MASTER_CONNECTION
refers to the node 0, and the connection is NULL.

Fix is as follows.

If attempt to connection to backend fails, check the master node id in
the shared memory.  If the master node id is the failed node, then
look for new master node using get_next_master_node (this was a static
function, but now it's made to public) and set the node id to the
master node id in the shared memory area.

Problem reported by Muhammad Usama in [pgpool-hackers: 2905].

7 years agoPrepare 3.4.19. V3_4_19 V3_4_19_RPM
Bo Peng [Tue, 31 Jul 2018 00:14:36 +0000 (09:14 +0900)]
Prepare 3.4.19.

7 years agoTry to reduce the chance of regression 006.memcache failure.
Tatsuo Ishii [Wed, 11 Jul 2018 01:16:07 +0000 (10:16 +0900)]
Try to reduce the chance of regression 006.memcache failure.

It seems the occasional failure of the test is caused by replication
lag.  The script tries to read tables from standby but it returns a
table not existing error.  So insert pg_sleep() after creation of
tables.

7 years agoFix "write on backend 0 failed with error :"Success"" error.
Tatsuo Ishii [Wed, 4 Jul 2018 06:25:35 +0000 (15:25 +0900)]
Fix "write on backend 0 failed with error :"Success"" error.

While writing to a socket, sometimes write() returns 0. Before we
treated this as an error, but it seems this could happen in the field
and is better to be treated as normal. So if write() returns 0, then
retry write() instead of raise an error.

Per bug #403.

7 years agoAdd nap time after failover.
Tatsuo Ishii [Fri, 22 Jun 2018 05:37:25 +0000 (14:37 +0900)]
Add nap time after failover.

This should make the test failure less frequent.

7 years agoFix comments and coding style.
Tatsuo Ishii [Wed, 20 Jun 2018 04:57:40 +0000 (13:57 +0900)]
Fix comments and coding style.

7 years agoFix 006.memqcache test.
Tatsuo Ishii [Wed, 20 Jun 2018 02:49:45 +0000 (11:49 +0900)]
Fix 006.memqcache test.

It forgot to execute shutdownall if some of tests failed. This lead to
hang up of subsequent tests.

7 years agoFix memory leaks related to pool_extract_error_message().
Tatsuo Ishii [Wed, 20 Jun 2018 01:25:23 +0000 (10:25 +0900)]
Fix memory leaks related to pool_extract_error_message().

After 3.4, the function starts to return palloc'ed memory, and the
caller should had been modified so that they pfree the memory returned
by it but actually they had not.

7 years agoFix oversight in pool_extract_error_message().
Tatsuo Ishii [Tue, 19 Jun 2018 02:31:29 +0000 (11:31 +0900)]
Fix oversight in pool_extract_error_message().

A variable used for storing the return value was mistakenly declared
as bool, rather than int.  This led to a segfault issue mentioned in
75b27e7 on certain platform.

7 years agoFix segfault in per_node_error_log() on armhf architecture.
Tatsuo Ishii [Tue, 19 Jun 2018 01:10:33 +0000 (10:10 +0900)]
Fix segfault in per_node_error_log() on armhf architecture.

pool_extract_error_message() incorrectly returns 255 (in decimal) on
the architecture when previous message was not an error or a notice
message. In this case per_node_error_log() happily calls ereport since
the return value from pool_extract_error_message() is greater than
0. Unfortunately the message string returned by
pool_extract_error_message() points to garbage memory in this case, a
segfault occurs.

The fix gives per_node_error_log() a guard against the bug of
pool_extract_error_message(). Moreover, the change is more consistent
with other places where pool_extract_error_message() is called.

Fix for pool_extract_error_message() will come later on.

See:
https://github.com/pgpool/pgpool2/issues/14
for more detailed discussion.

Problem reported and patch by Christian Ehrhardt.

7 years agoRevert "Fix 055.backend_all_down test failure."
Tatsuo Ishii [Tue, 12 Jun 2018 06:53:39 +0000 (15:53 +0900)]
Revert "Fix 055.backend_all_down test failure."

This reverts commit ca492a65bbf57c2dc78826690ea259ddc9d6e78b.

7 years agoFix 055.backend_all_down test failure.
Tatsuo Ishii [Tue, 12 Jun 2018 06:21:52 +0000 (15:21 +0900)]
Fix 055.backend_all_down test failure.

The test fails because pgpool zombie child process remains. Actually
the failover process is properly performed but when the shutdown
script is executed in background, output to stdout/stderr was blocked,
and this could cause the zombie process syndrome. Soltution is,
redirecting stdout/stderr to /dev/null when sponing the shutdown
script in background.

7 years agoPrepare 3.4.18. V3_4_18 V3_4_18_RPM
Bo Peng [Mon, 11 Jun 2018 14:10:22 +0000 (23:10 +0900)]
Prepare 3.4.18.

7 years agoFix compile error.
Bo Peng [Wed, 25 Apr 2018 14:31:12 +0000 (23:31 +0900)]
Fix compile error.

7 years agoPrevent pcp_recovery_node from recovering "unused" status node.
Tatsuo Ishii [Wed, 18 Apr 2018 01:03:37 +0000 (10:03 +0900)]
Prevent pcp_recovery_node from recovering "unused" status node.

This allowed to try to recover a node without configuration data,
which leads to variety of problems. See discussion:
https://www.pgpool.net/pipermail/pgpool-general/2018-March/006021.html
for more details.

Also I fixed pgpool_recovery function so that it quotes an empty
string argument with double quotes. Without this, the argument is
treated as if it does not exist, which was the source of the complain
from the user.

7 years agoPrepare 3.4.17. V3_4_17 V3_4_17_RPM
Bo Peng [Tue, 17 Apr 2018 08:51:17 +0000 (17:51 +0900)]
Prepare 3.4.17.

7 years agoAdd new regression test for node 0 is down.
Tatsuo Ishii [Mon, 9 Apr 2018 05:45:37 +0000 (14:45 +0900)]
Add new regression test for node 0 is down.

test case 1: node 0 is already down before pgpool starts.
test case 2: node 0 goes down after pgpool starts.
test case 3: node 0 goes down and DISALLOW_TO_FAILOVER flag is set after pgpool starts.

7 years agoMake calls to to_regclass fully schema qualified.
Tatsuo Ishii [Sun, 8 Apr 2018 10:18:36 +0000 (19:18 +0900)]
Make calls to to_regclass fully schema qualified.

This is always recommended way.

7 years agoChange test script to allow test failure.
Bo Peng [Fri, 23 Mar 2018 09:21:34 +0000 (18:21 +0900)]
Change test script to allow test failure.

7 years agoAdd wait_for_failover_done function for test.
Bo Peng [Tue, 20 Mar 2018 08:42:46 +0000 (17:42 +0900)]
Add wait_for_failover_done function for test.

7 years agoImprove the test script 003.failover.
Bo Peng [Tue, 20 Mar 2018 08:31:31 +0000 (17:31 +0900)]
Improve the test script 003.failover.

7 years agoChange the release version.
Bo Peng [Wed, 14 Mar 2018 08:27:36 +0000 (17:27 +0900)]
Change the release version.

7 years agoPrepare 3.4.16-2.
Bo Peng [Wed, 14 Mar 2018 06:36:34 +0000 (15:36 +0900)]
Prepare 3.4.16-2.

7 years agoFix some test errors.
Bo Peng [Wed, 14 Mar 2018 05:01:52 +0000 (14:01 +0900)]
Fix some test errors.

Add "wait_for_pgpool_startup" to wait for Pgpool-II starting.

7 years agoAllow to support pgpool_switch_xlog PostgreSQL 10.
Tatsuo Ishii [Tue, 27 Feb 2018 04:22:15 +0000 (13:22 +0900)]
Allow to support pgpool_switch_xlog PostgreSQL 10.

Since PostgreSQL 10, pgpool_switch_xlog used in the recovery second
stage fails due to function name changes in PostgreSQL 10.

7 years agoFix failure in replication mode.
Tatsuo Ishii [Tue, 27 Feb 2018 04:29:38 +0000 (13:29 +0900)]
Fix failure in replication mode.

If .psqlrc exists, pgpool_seup for replication mode fails because psql
produces messages like "Pager usage is off." which in turn confuses
a command after a pipe. Fix is add -q option to psql.

7 years agoPrepare 3.4.16. V3_4_16 V3_4_16_RPM
Bo Peng [Tue, 13 Feb 2018 05:20:30 +0000 (14:20 +0900)]
Prepare 3.4.16.

7 years agoFix typos.
Bo Peng [Mon, 12 Feb 2018 14:56:52 +0000 (23:56 +0900)]
Fix typos.

7 years agoSet TCP_NODELAY and non blocking to frontend socket.
Tatsuo Ishii [Mon, 29 Jan 2018 04:53:18 +0000 (13:53 +0900)]
Set TCP_NODELAY and non blocking to frontend socket.

TCP_NODELAY is employed by PostgreSQL, so do we it.

Listen fd is set to non blocking. To make sure accept fd is set to non
blocking.

7 years agoFix segfault when %a is in log_line_prefix and debug message is on.
Tatsuo Ishii [Tue, 23 Jan 2018 23:01:22 +0000 (08:01 +0900)]
Fix segfault when %a is in log_line_prefix and debug message is on.

log_line_prefix() gets called to create a log line prefix string. If
"%a" is specified in "log_line_prefix" parameter, log_line_prefix()
calls MASTER_CONNECTION macro, which calls
pool_virtual_master_db_node_id(), which calls ereport(), which calls
log_line_prefix() if debug message is on. This leads to an infinite
recursion and a segfault. Fix is, calling MASTER_NODE_ID macro instead
of MASTER_CONNECTION macro.

Per bug 376.

7 years agoChange systemd service file to use STOP_OPTS=" -m fast".
Bo Peng [Fri, 19 Jan 2018 05:00:27 +0000 (14:00 +0900)]
Change systemd service file to use STOP_OPTS=" -m fast".

7 years agoChange pgpool_setup to add restore_command in recovery.conf.
Bo Peng [Fri, 19 Jan 2018 04:58:44 +0000 (13:58 +0900)]
Change pgpool_setup to add restore_command in recovery.conf.

7 years agoRevert "Fix queries hanging in parse_before_bind with extended protocol and replicati...
Tatsuo Ishii [Thu, 18 Jan 2018 14:34:38 +0000 (23:34 +0900)]
Revert "Fix queries hanging in parse_before_bind with extended protocol and replication + load-balancing."

This reverts commit 0ac97a9c9600d1ec8c4cbd0bf30191beeb28ace9.

7 years agoFix queries hanging in parse_before_bind with extended protocol and replication ...
Tatsuo Ishii [Thu, 18 Jan 2018 13:14:38 +0000 (22:14 +0900)]
Fix queries hanging in parse_before_bind with extended protocol and replication + load-balancing.

In case the client sends a BIND message for a query
that has not yet been parsed by the executing node,
the PARSE will be executed before attempting to BIND
the parameters.

However, during the execution of the PARSE, the session
context is not set to in_progress, which leads to wrong
backend validity tests in read_kind_from_backend which
in turn makes the process wait on a backend which is not
going to send anything.

Fixes bug #377.

Problem analysis and fix by Ancoron Luciferis and me.

7 years agoFix queries hanging in parse_before_bind with extended protocol and replication ...
Tatsuo Ishii [Thu, 18 Jan 2018 01:37:23 +0000 (10:37 +0900)]
Fix queries hanging in parse_before_bind with extended protocol and replication + load-balancing.

In case the client sends a BIND message for a query
that has not yet been parsed by the executing node,
the PARSE will be executed before attempting to BIND
the parameters.

However, during the execution of the PARSE, the session
context is not set to in_progress, which leads to wrong
backend validity tests in read_kind_from_backend which
in turn makes the process wait on a backend which is not
going to send anything.

Fixes bug #377.

Bug report, analysis and fix by Ancoron Luciferis.

7 years agoPrepare 3.4.15. V3_4_15 V3_4_15_RPM
Bo Peng [Mon, 8 Jan 2018 07:20:35 +0000 (16:20 +0900)]
Prepare 3.4.15.

7 years agoReplace /bin/ed with /bin/sed.
Tatsuo Ishii [Fri, 22 Dec 2017 06:20:13 +0000 (15:20 +0900)]
Replace /bin/ed with /bin/sed.

This change requires less packages in order to install pgpool_setup,
because /bin/sed is included in most distribution's base packages,
while //bin/ed is not.

7 years agoChange the pgpool.service and sysconfig files to output Pgpool-II log.
Bo Peng [Thu, 21 Dec 2017 05:42:39 +0000 (14:42 +0900)]
Change the pgpool.service and sysconfig files to output Pgpool-II log.

Removeing "Type=forking" and add OPTS=" -n" to
run Pgpool-II with non-daemon mode, because we need to redirect logs.
Using "journalctl" command to see Pgpool-II systemd log.

7 years agoFix some test script error of 002.native_replication.
Bo Peng [Mon, 18 Dec 2017 02:31:59 +0000 (11:31 +0900)]
Fix some test script error of 002.native_replication.

7 years agoFix timestamp data inconsistency by replication mode.
Bo Peng [Sun, 17 Dec 2017 14:30:15 +0000 (23:30 +0900)]
Fix timestamp data inconsistency by replication mode.

From PostgreSQL10 the column default value such as 'CURRENT_DATE' changes,
Pgpool-II should also rewrite timestamp by the added default values in stead of
"'now'::text::date".

7 years agoFix returning transaction state when "ready for query" message received.
Tatsuo Ishii [Sun, 10 Dec 2017 12:04:15 +0000 (21:04 +0900)]
Fix returning transaction state when "ready for query" message received.

We return primary or master node state of ready for query message to
frontend. In most cases this is good. However if other than primary
node or master node returns an error state (this could happen if load
balance node is other than primary or master node and the query is an
errornous SELECT), this should be returned to frontend, because the
frontend already received an error.

How much this affects to applications is not clear. However this
behavior has been there for long time, probably applications do not
care the state returned by ready for query message.

7 years agoFix pgpool start message printed multiple times.
Tatsuo Ishii [Wed, 15 Nov 2017 23:12:13 +0000 (08:12 +0900)]
Fix pgpool start message printed multiple times.

When an exception occurs in the main loop, longjmp() gets called and
the variable "first" restored to the initial value. This make the
pgpool start message printed multiple times. This is harmless but
confusing. To fix that, add "volatile" qualifier so that the variable
is on the stack, rather than on a register.

Fix suggested by Muhammad Usama.

7 years agoAdd pgpool_rhel7.sysconfig and pgpool_rhel6.sysconfig files to distribution. V3_4_14 V3_4_14_RPM
pengbo [Wed, 1 Nov 2017 00:39:17 +0000 (09:39 +0900)]
Add pgpool_rhel7.sysconfig and pgpool_rhel6.sysconfig files to distribution.

7 years agoPrepare 3.4.14.
pengbo [Wed, 1 Nov 2017 00:06:25 +0000 (09:06 +0900)]
Prepare 3.4.14.