pgpool2.git
9 years agoChange the PID length of pcp_proc_count command result to 6 characters long
pengbo [Wed, 20 Apr 2016 03:40:41 +0000 (12:40 +0900)]
Change the PID length of pcp_proc_count command result to 6 characters long

If the pgpool process ID are over 5 characters, the 6th character of each process ID
will be removed.This commit changes the process ID length of pcp_proc_count command
result to 6 characters long.

See bug 188 for related info.

9 years agoRedirect all user queries to primary server
Tatsuo Ishii [Fri, 15 Apr 2016 04:17:23 +0000 (13:17 +0900)]
Redirect all user queries to primary server

Up to now some user queries are sent to other than the primary server
even if load_balance_mode = off. This commit changes the behavior: if
load_balance_mode = off in streaming replication mode, now all the
user queries are sent to the primary server only.

See bug 189 for related info.

9 years agoremoving the limit on the maximum number of items in the black_function_list
Muhammad Usama [Thu, 7 Apr 2016 15:29:33 +0000 (20:29 +0500)]
removing the limit on the maximum number of items in the black_function_list
and white_function_list lists.

extract_string_tokens in pool_config uses the fixed size malloc on the array to
hold the black_function_list/white_function_list items. This imposes a limit of
maximum items in these lists. The fix is to use realloc to increase the array
size when it gets full.

9 years agoPrepare 3.2.14 V3_2_14
Yugo Nagata [Mon, 4 Apr 2016 10:52:15 +0000 (19:52 +0900)]
Prepare 3.2.14

9 years agoPrepare 3.2.14
Yugo Nagata [Mon, 4 Apr 2016 10:24:44 +0000 (19:24 +0900)]
Prepare 3.2.14

9 years agoValidating the PCP packet length
Muhammad Usama [Tue, 29 Mar 2016 20:30:33 +0000 (01:30 +0500)]
Validating the PCP packet length

Without the validation check, a malformed PCP packet can crash the PCP child
and/or can run the server out of memory by sending the packet with a
very large data size.

9 years agoFix typo
Tatsuo Ishii [Mon, 28 Mar 2016 05:12:39 +0000 (14:12 +0900)]
Fix typo

9 years agoFix installation procedure.
Tatsuo Ishii [Sat, 19 Mar 2016 02:19:14 +0000 (11:19 +0900)]
Fix installation procedure.

With PostgreSQL 9.4 or later, installing pgpool_regclass is not
needed.

9 years agoChange description of backend_flag.
Tatsuo Ishii [Wed, 16 Mar 2016 00:28:38 +0000 (09:28 +0900)]
Change description of backend_flag.

It is pointed out that restarting pgpool-II is not
necessary. [pgpool-general-jp: 1394].

9 years agoYet another reset query stuck problem fix. [pgpool-general: 4265]
Muhammad Usama [Mon, 22 Feb 2016 12:23:46 +0000 (17:23 +0500)]
Yet another reset query stuck problem fix. [pgpool-general: 4265]

The solution is to return  POOL_END_WITH_FRONTEND_ERROR instead of
POOL_END when pool_flush on front-end socket fails

9 years agoPrepre 3.2.13 V3_2_13
Yugo Nagata [Fri, 5 Feb 2016 06:31:31 +0000 (15:31 +0900)]
Prepre 3.2.13

9 years agoFix bug#156: problem with reloading.
Tatsuo Ishii [Sun, 17 Jan 2016 12:57:49 +0000 (21:57 +0900)]
Fix bug#156: problem with reloading.

While reloading pgpool.conf, the number of DB nodes is tentatively set
to 0, then counted up until reaching to the actual number of backends
by the pgpool main process. Unfortunately the variable is on the
shared memory and it confuses pgpool child process if they are using
the variable. To solve the problem, a local variable is used to count
up the number of backend. After finishing the counting, the value of
the local variable is assigned to the variable on the shared memory.

I will explain why we don't need interlocking:

1) If the number of backend has not changed before/after the loop,
   it's obviously fine.

2) If the number of backend has increased after the loop, the new
   backend is recognized as "CON_UNUSED" because all the status for
   each backend is set to "CON_UNUSED" beforehand.

3) If the number of backend has decreased after the loop, failover
   should have happened and child process should have restarted.

However, we should be careful so that the assignment of the variable
should happen in an atomic manner. For this purpose I change the data
type of the variable from int to sig_atomic_t.

9 years agodoc: Add restriction about starting multiple pgpool simultaneously
Yugo Nagata [Mon, 28 Dec 2015 02:01:35 +0000 (11:01 +0900)]
doc: Add restriction about starting multiple pgpool simultaneously

10 years agoFix bug with "SET TRANSACTION READ ONLY".
Tatsuo Ishii [Wed, 2 Dec 2015 10:37:14 +0000 (19:37 +0900)]
Fix bug with "SET TRANSACTION READ ONLY".

Pgpool-II remembers that non read only queries (including SET) were
executed in an explicit transaction and adds a "writing transaction"
mark to the transaction. The mark affects the query routing behavior
of pgpool-II while running in streaming replication mode. Pgpool-II
starts sending queries to the primary after the mark is set. Because
the effect of writing queries may appear on standbys after some delay
in streaming replication mode, it is safer to route read queries to
the primary after the mark is set.

However there's oversight here. "SET TRANSACTION READ ONLY" does no
data modification and should be treated as an exception.

Per bug #157.

10 years agoIgnore close statement/portal request if they do not exist.
Tatsuo Ishii [Fri, 30 Oct 2015 06:08:42 +0000 (15:08 +0900)]
Ignore close statement/portal request if they do not exist.

In this case just returns a close complete message to client.
This is a back port of commit:

1a37e1c35bd8b6f10f524693bbcb7b51f73b4bf0

which should have been back ported earlier.

10 years agoFix in memory query cache bug reported in bug#152.
Tatsuo Ishii [Mon, 19 Oct 2015 04:18:06 +0000 (13:18 +0900)]
Fix in memory query cache bug reported in bug#152.

If extended query protocol is used and a bind/execute message arrives
which uses a statement created by prior parse message, the temp_cache
is not initialized by a parse messages. Thus messages are added to pre
existing temp cache buffer which causes the trouble (when the cached
result returns, Data Row message and Command Complete message appeared
*twice*).
t-ishii@localhost:

10 years agoUpdate copyright year.
Tatsuo Ishii [Fri, 16 Oct 2015 05:34:43 +0000 (14:34 +0900)]
Update copyright year.

10 years agoFix wrong description in documents about log_standby_delay
Yugo Nagata [Fri, 4 Sep 2015 05:10:39 +0000 (14:10 +0900)]
Fix wrong description in documents about log_standby_delay

10 years agoFix ancient bug of pool_push() and friends.
Tatsuo Ishii [Thu, 3 Sep 2015 01:28:29 +0000 (10:28 +0900)]
Fix ancient bug of pool_push() and friends.

It allocates buffer using realloc and uses the pointer
returned. However it does the pointer calculation *before* realloc
gets called. So the calculation uses the old pointer value, which
causes various problems including segfault later. It is surprising
that this bug was not found earlier because the bug was there since
the function was added. This is probably due to the fact that actual
pointer moving does not happen until certain amount of memory.

Also there were other problems with it. The buffer pointer and buffer
size variable is not initialized. The buffer is not freed by
pool_close. Typo in debugging message (3.4 or later only). They are
fixed as well.

10 years agoFix compiler warning.
Tatsuo Ishii [Mon, 24 Aug 2015 02:54:17 +0000 (11:54 +0900)]
Fix compiler warning.

Since memqcache_total_size is 64bit integer, the format string should
be %ld, rather than %d.

10 years agoFix typo in Document
Yugo Nagata [Fri, 21 Aug 2015 04:35:35 +0000 (13:35 +0900)]
Fix typo in Document

10 years agoIssue fsync() when writing pgpool_status.
Tatsuo Ishii [Thu, 6 Aug 2015 06:15:24 +0000 (15:15 +0900)]
Issue fsync() when writing pgpool_status.

This ensures that pgpool_status is saved to permanent storage and
allow to survive after system crash.

10 years agoFix misinformation regarding load balancing in docs.
Tatsuo Ishii [Wed, 5 Aug 2015 06:19:44 +0000 (15:19 +0900)]
Fix misinformation regarding load balancing in docs.

In streaming replication mode, DECLARE, FETCH, CLOSE and SHOW are sent
to primary node only. Pointed out in [pgpool-general-jp: 1378].

10 years agoPrepare 3.2.12 V3_2_12
Yugo Nagata [Fri, 24 Jul 2015 05:38:39 +0000 (14:38 +0900)]
Prepare 3.2.12

10 years agoDo not send a query for checking insert lock in non replication mode with extended...
Tatsuo Ishii [Sun, 21 Jun 2015 09:51:34 +0000 (18:51 +0900)]
Do not send a query for checking insert lock in non replication mode with extended query

This unnecessary code was there since day 0.

10 years agoAllow to use in memory query cache size > 4GB
Tatsuo Ishii [Sat, 20 Jun 2015 10:03:22 +0000 (19:03 +0900)]
Allow to use in memory query cache size > 4GB

This should have been allowed since in memory query cache was born.

10 years agoFix outdated limitation description about load balancing using JDBC driver.
Tatsuo Ishii [Wed, 13 May 2015 01:29:14 +0000 (10:29 +0900)]
Fix outdated limitation description about load balancing using JDBC driver.

Even if autocommit is false, load balancing is possible in certain conditions.

10 years agoPassing empty string parameters in failover command when pgpool-II does not have...
Muhammad Usama [Wed, 29 Apr 2015 14:10:04 +0000 (19:10 +0500)]
Passing empty string parameters in failover command when pgpool-II does not have a value for any particular parameter

Instead of omitting the values for the parameters when pgpool-II does not have
any value for a particular parameter, It now passes an empty string instead to
the failover command, This makes sure that failover script will always receive
the exact number of expected parameters.

10 years agoFixing "cannot find xlog functions" error in pgpool-recovery
Muhammad Usama [Thu, 9 Apr 2015 17:38:59 +0000 (22:38 +0500)]
Fixing "cannot find xlog functions" error in pgpool-recovery
The argument data type of PG's pg_xlogfile_name() function has been changed from
text to pg_lsn since PostgreSQL 9.4. And pgpool-recovery was still trying to
locate the function by old signature.

10 years agoPrepare 3.2 V3_2_11
Yugo Nagata [Wed, 8 Apr 2015 07:22:43 +0000 (16:22 +0900)]
Prepare 3.2

10 years agoFixing a problem with pcp_detach_node, When graceful node detach is requested
Muhammad Usama [Tue, 7 Apr 2015 12:48:44 +0000 (17:48 +0500)]
Fixing a problem with pcp_detach_node, When graceful node detach is requested

gracefully detaching a node by pcp_detach_node should check if it is allowed to
process detach_node command on the particular node before blocking the incoming
connections and closing the existing connections.

10 years agoSupport SSL certificate chains in the certificate file for incoming frontend connections.
Muhammad Usama [Wed, 18 Mar 2015 10:21:31 +0000 (15:21 +0500)]
Support SSL certificate chains in the certificate file for incoming frontend connections.

10 years agoEnlarge POOLCONFIG_MAXDESCLEN to 80.
Tatsuo Ishii [Thu, 19 Feb 2015 01:33:57 +0000 (10:33 +0900)]
Enlarge POOLCONFIG_MAXDESCLEN to 80.

This is used in show pool_status command and limits the length of
parameter description.  Unfortunately recovery_timeout description is
64 chars, which is 1 byte longer than former definition of the macro
because we need on more byte for null termination.

10 years agoRemove an unnecessary include directive
Yugo Nagata [Fri, 20 Feb 2015 07:31:09 +0000 (16:31 +0900)]
Remove an unnecessary include directive

10 years agoFix to set SIGCHLD to SIG_DFL instead of SIG_IGN in watchdog processes
Yugo Nagata [Fri, 20 Feb 2015 07:27:32 +0000 (16:27 +0900)]
Fix to set SIGCHLD to SIG_DFL instead of SIG_IGN in watchdog processes

When using waitpid, it isn't necessary to set SIGCHLD SIG_IGN. Rather,
waitpid returns ECHLD and WIFEXITED could be zero even when the child
process exit successfully. Due to this, it was recognized that ping
exited abnormally in error.

In addition, signal functions are replaced to pool_singal.

10 years agoFix to use void * for receiving return value of thread function
Yugo Nagata [Fri, 20 Feb 2015 05:27:41 +0000 (14:27 +0900)]
Fix to use void * for receiving return value of thread function

Previously int was used and this could occur stack buffer overflow.
This caused an infinity loop of ping error at bringing up or down
VIP, since a loop variable in a for loop was overwritten to zero.

10 years agoPrepare 3.2.10 V3_2_10
Yugo Nagata [Thu, 5 Feb 2015 10:20:54 +0000 (19:20 +0900)]
Prepare 3.2.10

10 years agoFix for [pgpool-general: 3374] show pool_nodes
Muhammad Usama [Tue, 23 Dec 2014 18:04:20 +0000 (23:04 +0500)]
Fix for [pgpool-general: 3374] show pool_nodes

The size of string for holding the node id in POOL_REPORT_NODES was too small
for ids having more than one digits. Also adjusting the port string size in
same structure which was lot more than what is actually required.

11 years agoFix for 0000122: pgpool-II 3.4.0 - if_up_cmd and if_down_cmd $_IP_$ substitution
Muhammad Usama [Fri, 12 Dec 2014 18:24:49 +0000 (23:24 +0500)]
Fix for 0000122: pgpool-II 3.4.0 - if_up_cmd and if_down_cmd $_IP_$ substitution
is too optimistic.

exec_ifconfig() function while breaking the command string into tokens was
assuming that "$_IP_$" keyword will always have a white space at the end and
when "$_IP_$" has some prefix, it gets broken down into two tokens "$_IP_$"
instead of one.
To fix this the command string in exec_ifconfig() is passed to newly added
string_replace() function to substitute all occurrences of "$_IP_$"
with delegate_IP before tokenizing.

11 years agoFix node id range check bug in trigger_failover_command().
Tatsuo Ishii [Wed, 19 Nov 2014 01:32:22 +0000 (10:32 +0900)]
Fix node id range check bug in trigger_failover_command().

The node id should be lower than NUM_BACKENDS. Probably harmless since
callers never pass node ids greater or equal to NUM_BACKENDS. But a
bug is a bug.

11 years agoFix possible segfault in query cache.
Tatsuo Ishii [Fri, 7 Nov 2014 00:43:53 +0000 (09:43 +0900)]
Fix possible segfault in query cache.

In ReadyForQuery, it does not check if session_context->query_context
exists. Thus it could lead to segfault later on if it does not exists.

11 years agoFix to disable debug mode with a config reload
Yugo Nagata [Wed, 22 Oct 2014 12:33:02 +0000 (21:33 +0900)]
Fix to disable debug mode with a config reload

Per bug #114.

11 years agoFix missing release note entries in the previous release.
Tatsuo Ishii [Tue, 21 Oct 2014 01:25:54 +0000 (10:25 +0900)]
Fix missing release note entries in the previous release.

11 years agoFix missing release note entries in the previous release.
Tatsuo Ishii [Tue, 21 Oct 2014 01:22:05 +0000 (10:22 +0900)]
Fix missing release note entries in the previous release.

11 years agoFix uninitialized variable.
Tatsuo Ishii [Fri, 17 Oct 2014 11:08:12 +0000 (20:08 +0900)]
Fix uninitialized variable.

Per Coverity 1234603.

11 years agoFix typo in docs.
Tatsuo Ishii [Thu, 25 Sep 2014 00:47:11 +0000 (09:47 +0900)]
Fix typo in docs.

Per Yaron Naveh.

11 years agoExplicitly stats that the number of slaves is not necessarily 1.
Tatsuo Ishii [Sat, 13 Sep 2014 05:58:59 +0000 (14:58 +0900)]
Explicitly stats that the number of slaves is not necessarily 1.

11 years agoFix typos
Yugo Nagata [Fri, 12 Sep 2014 07:19:21 +0000 (16:19 +0900)]
Fix typos

11 years agoPrepare 3.2.9 V3_2_9
Yugo Nagata [Fri, 5 Sep 2014 13:43:31 +0000 (22:43 +0900)]
Prepare 3.2.9

11 years agofixing small coverity issues: 751966 Argument cannot be negative,
Muhammad Usama [Wed, 3 Sep 2014 13:11:26 +0000 (18:11 +0500)]
fixing small coverity issues: 751966 Argument cannot be negative,
1111399 Explicit null dereferenced and 1111488 Uninitialized scalar variable

11 years agoFix coverity issue 1111480 Copy into fixed size buffer
Muhammad Usama [Tue, 12 Aug 2014 14:39:32 +0000 (19:39 +0500)]
Fix coverity issue 1111480 Copy into fixed size buffer
replacing strcpy() with much safer and recomended call strlcpy()

11 years agoRemove meaningless minus check because of unsigned int variable.
Tatsuo Ishii [Fri, 8 Aug 2014 13:15:41 +0000 (22:15 +0900)]
Remove meaningless minus check because of unsigned int variable.

Coverity issue #1111419, #1111420, #1111422.

11 years agoBack porting coverity issues fix patch from master branch.
Muhammad Usama [Tue, 5 Aug 2014 14:42:42 +0000 (19:42 +0500)]
Back porting coverity issues fix patch from master branch.
Fix coverity issue:1111377 Unchecked return value
Fix coverity issue:1111381 Logically dead code
Fix coverity issue:1222992 Unchecked return value
Fix coverity issue:1222993 Unchecked return value

11 years agoBack porting coverity issues fix patch from master branch.
Muhammad Usama [Mon, 28 Jul 2014 12:42:26 +0000 (17:42 +0500)]
Back porting coverity issues fix patch from master branch.

Fix coverity issue:1111394 Dereference after null check
Fix coverity issue:1111398 Dereference after null check
Fix coverity issue:1111399 Explicit null dereferenced
Fix coverity issue:1111400 Dereference after null check
Fix coverity issue:1111401 Explicit null dereferenced

11 years agoAdd a description that pcp_detach_node disconnects existing sessions.
Tatsuo Ishii [Fri, 25 Jul 2014 04:57:42 +0000 (13:57 +0900)]
Add a description that pcp_detach_node disconnects existing sessions.

11 years agoFix yet another reset query stuck problem.
Tatsuo Ishii [Thu, 24 Jul 2014 06:26:55 +0000 (15:26 +0900)]
Fix yet another reset query stuck problem.

If client_idle_limit is set and the idle limit reaches,
pool_process_query() returns and tries to execute reset query which
may not be acceptable by backend because it may not be in "ready for
query" state. The fix is, close connections to backend instead.

Per bug#107.
See also: http://git.postgresql.org/gitweb/?p=pgpool2.git;a=commit;h=52a3a8c6ab67be3e09db9a7bdfd8e74d81ae3687

11 years agoFix reset query stuck problem.
Tatsuo Ishii [Fri, 18 Jul 2014 07:37:56 +0000 (16:37 +0900)]
Fix reset query stuck problem.

It is reported that reset query (DISCARD ALL etc.) occasionally does
not finish and pgpool child remain waiting for reply from backend thus
client cannot connect to pgpool (for example
http://www.pgpool.net/mantisbt/view.php?id=107).  The cause of problem
is not identified yet but if client suddenly closes connection to
pgpool in the middle of query processing, backend may not accept the
reset queries because they are not ready for query.

The fix is, if frontend closes connection in unexpected way, query
process loop immediately returns with new state:
POOL_END_WITH_FRONTEND_ERROR and pgpool closes connection to
PostgreSQL then goes back to new connection request waiting loop.

11 years agoBack porting coverity issues fix patch from master branch.
Muhammad Usama [Thu, 17 Jul 2014 13:47:20 +0000 (18:47 +0500)]
Back porting coverity issues fix patch from master branch.

Fix coverity issue:1111380 Logically dead code
Fix coverity issue:1111382 Logically dead code
Fix coverity issue:1111402 Explicit null dereferenced
Fix coverity issue:1111405 Explicit null dereferenced
Fix coverity issue:1111407 Dereference after null check
Fix coverity issue:1111408 Explicit null dereferenced
Fix coverity issue:1111409 Dereference after null check
Fix coverity issue:1111383 Logically dead code
Fix coverity issue:1111492 Structurally dead code
Fix coverity issue:1111417 Nesting level does not match indentation
Fix coverity issue:1111379 Logically dead code
Fix coverity issue:1111406 Explicit null dereferenced
Fix coverity issue:1111396 Explicit null dereferenced
Fix coverity issue:1111397 Explicit null dereferenced

11 years agoFix wrong error message.
Tatsuo Ishii [Wed, 16 Jul 2014 09:22:21 +0000 (18:22 +0900)]
Fix wrong error message.

11 years agoBack porting coverity issues fix patch from master branch.
Muhammad Usama [Tue, 15 Jul 2014 12:37:27 +0000 (17:37 +0500)]
Back porting coverity issues fix patch from master branch.
Fix coverity issue:1111387 Explicit null dereferenced
Fix coverity issue:1111388 Explicit null dereferenced
Fix coverity issue:1111411 Missing break in switch
Fix coverity issue:1111412 Missing break in switch
Fix coverity issue:1111450 Resource leak
Fix coverity issue:1111451 Resource leak
Fix coverity issue:1111472 Dereference before null check
Fix coverity issue:1111473 Dereference before null check
Fix coverity issue:1111474 Dereference before null check
Fix coverity issue:1111475 Wrong sizeof argument
Fix coverity issue:1111495 Use after free
Fix coverity issue:1111496 Use after free
Fix coverity issue:1222989 Bad bit shift operation
Fix coverity issue:1222990 Bad bit shift operation
Fix coverity issue:1222994 Explicit null dereferenced

11 years agoChange connect() timeout longer (10 seconds) for flaky network.
Tatsuo Ishii [Sat, 12 Jul 2014 12:36:42 +0000 (21:36 +0900)]
Change connect() timeout longer (10 seconds) for flaky network.

Change connect() timeout in connect_inet_domain_socket_by_port() from
1 second to 10 seconds for flaky network such as AWS. This should help
reducing frequent failover. Pgpool-II 3.4 will have switch to control
the timeout value, rather than fixed value. However our policy does
not allow to add new feature like that. So I decided to just tweak the
fixed value.

11 years agoFix coverity issue:1222999 Resource leak.
Muhammad Usama [Fri, 11 Jul 2014 11:13:02 +0000 (16:13 +0500)]
Fix coverity issue:1222999 Resource leak.
Fix coverity issue:1222998 Resource leak.

11 years agoFix coverity issue:1223003 Uninitialized scalar variable.
Muhammad Usama [Fri, 11 Jul 2014 09:53:23 +0000 (14:53 +0500)]
Fix coverity issue:1223003 Uninitialized scalar variable.
Fix coverity issue:1223002 Uninitialized scalar variable.
Fix coverity issue:1223001 Resource leak.
Fix coverity issue:1223000 Resource leak.

11 years agoFix pool_handle_query_cache() to not free NULL pointer.
Tatsuo Ishii [Fri, 11 Jul 2014 01:25:53 +0000 (10:25 +0900)]
Fix pool_handle_query_cache() to not free NULL pointer.

11 years agofix coverity issue:1223007 Use after free.
Muhammad Usama [Tue, 8 Jul 2014 12:14:08 +0000 (17:14 +0500)]
fix coverity issue:1223007 Use after free.

get_insert_command_table_name() function was using the
freed pointer in pool_debug() function call.

11 years agoDisbale statement_timeout while executing online recovery.
Tatsuo Ishii [Sat, 21 Jun 2014 10:23:02 +0000 (19:23 +0900)]
Disbale statement_timeout while executing online recovery.

Online may take very long time and user may enable statement
timeout. To prevent online recovery canceled by statement timeout,
disable statement timeout in the connection used by online recovery.

See [pgpool-general: 2919] for whole story.

11 years agoAdd missing include file sys/wait.h.
Tatsuo Ishii [Sat, 14 Jun 2014 00:29:34 +0000 (09:29 +0900)]
Add missing include file sys/wait.h.

Per bug #104.

11 years agoRemove unnecessary call to pool_shmem_exit() which removes semaphore when it shouldn't.
Tatsuo Ishii [Mon, 9 Jun 2014 12:39:21 +0000 (21:39 +0900)]
Remove unnecessary call to pool_shmem_exit() which removes semaphore when it shouldn't.

exit_handler checks if the process is parent or not. This is
good. However, even if it is a child process, it calls
pool_shmem_exit() which removes semaphore and shmem when it should
not (it should be called only from parent process).

Per bug #102.

11 years agoFix pgpool.init's long-standing bug of stop/restart failure
Yugo Nagata [Wed, 28 May 2014 04:37:42 +0000 (13:37 +0900)]
Fix pgpool.init's long-standing bug of stop/restart failure

In previous, pgpool.init uses killproc for stopping pgpool, but there are
several problems; (1) some child processes can be left since the parent
process restarts killed processes; (2) when pgpool has connection from
clients, pgpool can't stop until connection closed; (3) restart() fails
for these reasons.

In the new version, "pgpool -m fast stop" is used in stop(). The problems
above are resolved and restart() also works well, even when watchdog enabled.
In addition, exit code according with LSB is considered, try-restart
option is implemented, and the old switch option is removed.

Original patch contributed by Ryan DeShone and modified by Yugo Nagata.

See [pgpool-hackers: 239][pgpool-hackers: 512].

11 years agoFix pgpool.init's long-standing bug of stop/restart failure
Yugo Nagata [Wed, 28 May 2014 04:37:42 +0000 (13:37 +0900)]
Fix pgpool.init's long-standing bug of stop/restart failure

In previous, pgpool.init uses killproc for stopping pgpool, but there are
several problems; (1) some child processes can be left since the parent
process restarts killed processes; (2) when pgpool has connection from
clients, pgpool can't stop until connection closed; (3) restart() fails
for these reasons.

In the new version, "pgpool -m fast stop" is used in stop(). The problems
above are resolved and restart() also works well, even when watchdog enabled.
In addition, exit code according with LSB is considered, try-restart
option is implemented, and the old switch option is removed.

Original patch contributed by Ryan DeShone and modified by Yugo Nagata.

See [pgpool-hackers: 239][pgpool-hackers: 512].

11 years agoFix memory leak.
Tatsuo Ishii [Fri, 23 May 2014 20:55:25 +0000 (05:55 +0900)]
Fix memory leak.

Per Coverity 1111442.

11 years agoFix file descriptor leak when daemonize.
Tatsuo Ishii [Fri, 23 May 2014 17:29:09 +0000 (02:29 +0900)]
Fix file descriptor leak when daemonize.

Per Coverity 1111471.

11 years agoUpdate copyright year
Yugo Nagata [Sun, 18 May 2014 22:16:13 +0000 (07:16 +0900)]
Update copyright year

11 years agoFix return type of text_to_lsn() function
Yugo Nagata [Fri, 16 May 2014 09:53:16 +0000 (18:53 +0900)]
Fix return type of text_to_lsn() function

11 years agoRemove old restriction description which is no longer true.
Tatsuo Ishii [Fri, 16 May 2014 07:39:38 +0000 (16:39 +0900)]
Remove old restriction description which is no longer true.

Following descriptions are removed ([pgpool-general: 2815].

>> pgpool-II does not support pg_hba.conf-like access controls. If TCP/IP
> connections are enabled, pgpool-II accepts all the connections from any
> host.

>> "hostssl" connection type is not supported

11 years agoFix names in release notes
Yugo Nagata [Fri, 18 Apr 2014 07:01:04 +0000 (16:01 +0900)]
Fix names in release notes

11 years agoFix release notes' style and add missing notes
Yugo Nagata [Fri, 18 Apr 2014 06:37:47 +0000 (15:37 +0900)]
Fix release notes' style and add missing notes

11 years agoAdd cautions that recovery commands are killed by statement_timeout of PostgreSQL.
Tatsuo Ishii [Thu, 3 Apr 2014 23:33:53 +0000 (08:33 +0900)]
Add cautions that recovery commands are killed by statement_timeout of PostgreSQL.

recovery_1st_stage_command can be killed if its execution time is
longer than statement_timeout and online recovery fails. The problem
was found and reported by Sean Hogan at [pgpool-general:
2680]. Samething can be said to recovery_2nd_stage_command.

11 years agoFix typo
Yugo Nagata [Fri, 4 Apr 2014 05:02:40 +0000 (14:02 +0900)]
Fix typo

11 years agoClose listen socket when smart shutdown request is made.
Tatsuo Ishii [Sat, 29 Mar 2014 08:36:50 +0000 (17:36 +0900)]
Close listen socket when smart shutdown request is made.

When smart shutdown process starts, pgpool children still listen on
the port and clients can send further connection requests which fail
in the end. Which is not only waste of time, but also prevents a load
balancer which sits in front of pgpool from realizing the pgpool is
going down.

Problem analyzed and patch provided by Junegunn Choi in pgpool-hackers
474, and enhanced to take care not only inet domain socket but UNIX
domain socket by me.

11 years agoFix worker child process keeps failing when there's no primary backend.
Tatsuo Ishii [Thu, 27 Mar 2014 07:55:11 +0000 (16:55 +0900)]
Fix worker child process keeps failing when there's no primary backend.

Problem identified and fix contributed by Junegunn Choi.

From pgpool-hackers: 471
==================================================================
Hi,

I've identified that worker child process keeps failing when
there's no primary backend in the cluster at the moment.

We're running a streaming replication cluster with 3 nodes. Because of
a sudden H/W problem of the master server, I detached the node from
pgpool using `pcp_detach_node` command, in order to temporarily make
the cluster read-only. pgpool then worked as expected, it rejected
write requests and still served read requests using the remaining two
standby nodes. The problem is, the worker child process which checks
for replication lag, keeps failing and being recreated without a
pause. So naturally it generates massive amount of log messages, and
keeps creating backend connections, which in turn leaves a large
number of TIME_WAIT sockets on the system.

2014-03-27 15:33:57 LOG:   pid: 21996 fork a new worker child pid 28453
2014-03-27 15:33:57 ERROR: pid: 28453 do_query: error message from backend:
recovery is in progress. Exit this session.
2014-03-27 15:33:57 LOG:   pid: 21996 worker child 28453 exits with status
256
2014-03-27 15:33:57 LOG:   pid: 21996 fork a new worker child pid 28455
2014-03-27 15:33:57 ERROR: pid: 28455 do_query: error message from backend:
recovery is in progress. Exit this session.
2014-03-27 15:33:57 LOG:   pid: 21996 worker child 28455 exits with status
256
2014-03-27 15:33:57 LOG:   pid: 21996 fork a new worker child pid 28459
2014-03-27 15:33:57 ERROR: pid: 28459 do_query: error message from backend:
recovery is in progress. Exit this session.
2014-03-27 15:33:57 LOG:   pid: 21996 worker child 28459 exits with status
256
...

Looking at the code, I found that the cause is that it invokes
`pg_current_xlog_location()` on the first remaining standby node, when
it shouldn't. In fact, there's no reason to check for replication lag
in such case.

I've attached a simple patch, which makes worker child to skip checking
when there's no primary node.

Please take a look.
Thanks.
Junegunn Choi.

11 years agoFix a typo of pgpool.spec
Yugo Nagata [Wed, 26 Mar 2014 07:24:03 +0000 (16:24 +0900)]
Fix a typo of pgpool.spec

11 years agoPrepare 3.2.8 V3_2_8
Yugo Nagata [Mon, 24 Mar 2014 14:04:06 +0000 (23:04 +0900)]
Prepare 3.2.8

11 years agoAdd description about parallel mode doesn't support PREPARE
Yugo Nagata [Mon, 24 Mar 2014 08:28:40 +0000 (17:28 +0900)]
Add description about parallel mode doesn't support PREPARE

11 years agoFix backend error of prepared statement including now() via JDBC in replication mode
Yugo Nagata [Mon, 24 Mar 2014 06:05:10 +0000 (15:05 +0900)]
Fix backend error of prepared statement including now() via JDBC in replication mode

With JDBC, when a prepared statement is executed more than PreparedThreshold times,
the statement is named, and pgpool rewrites now() to parameter in replication mode.
Hence, rewritten query has additonal parameter, so Bind message also should inclued
additional parameter format codes. However, when the number of original parameter was
one, pgpool didn't handle this. This caused a error like "incorrect binary data format
in bind parameter 2" on backend.

11 years agoFix JDBC exception of prepared statement including now() in replication mode
Yugo Nagata [Fri, 14 Mar 2014 06:20:59 +0000 (15:20 +0900)]
Fix JDBC exception of prepared statement including now() in replication mode

With JDBC, when a prepared statement is executed more than PreparedThreshold times,
the statement is named and Describe message is sent after Parse. With named statement,
pgpool rewrite now() to parameter at Parse in replication mode. Hence, rewritten query
has additonal parameter than original. However, ParameterDescription message sent to
frontend, which is response of Describe, should include OIDs of the same number os
original query's parameters. Otherwize, JDBC raises ArrayIndexoutOfBoundsException.

11 years agoFix to output debug messages in processing pgpool.conf with -d option
Yugo Nagata [Fri, 28 Feb 2014 10:40:17 +0000 (19:40 +0900)]
Fix to output debug messages in processing pgpool.conf with -d option

In previous, debug messages in pool_get_config() ware not output
even when -d option was used.

11 years agoFix a segmentation fault in parallel mode with system_db_hostname is empty
Yugo Nagata [Fri, 28 Feb 2014 07:19:20 +0000 (16:19 +0900)]
Fix a segmentation fault in parallel mode with system_db_hostname is empty

When system_db_hostname is empty, unix domain socket should be used.
However, the directory containing the socket file was't specified in this
case, and the initialization of system DB connection failed. This caused
segmentation fault, when processing a query to system db.

11 years agoFix memory leak.
Tatsuo Ishii [Wed, 26 Feb 2014 08:11:23 +0000 (17:11 +0900)]
Fix memory leak.

Per Coverity 1111446.

11 years agoDo not enable query cache on materialized views.
Tatsuo Ishii [Wed, 26 Feb 2014 06:49:45 +0000 (15:49 +0900)]
Do not enable query cache on materialized views.

Per bug #95.

11 years agoFix freeing NULL.
Tatsuo Ishii [Tue, 25 Feb 2014 06:43:43 +0000 (15:43 +0900)]
Fix freeing NULL.

free_systemdb_info() should check if the argument is NULL or not.
Per Coverity 1111384.

11 years agoFix possible buffer overrun.
Tatsuo Ishii [Mon, 24 Feb 2014 07:38:51 +0000 (16:38 +0900)]
Fix possible buffer overrun.

Replace strcpy() with strlcpy(). Per Coverity report 11114781111480,
1111481.

11 years agoAdd strlcpy.
Tatsuo Ishii [Mon, 24 Feb 2014 06:25:40 +0000 (15:25 +0900)]
Add strlcpy.

11 years agoFix possible buffer overrun problem and memory leak.
Tatsuo Ishii [Mon, 24 Feb 2014 06:14:03 +0000 (15:14 +0900)]
Fix possible buffer overrun problem and memory leak.

To fix the memory leak problem, now libs/pcp/libpcp.a links
strlcpy.o. For this purpose, libs/pcp/Makefile.am is also modified.
Per Coverity 1111465 and 1111482.

11 years agoAvoid to send queries to unrelated nodes in streaming replication mode.
Tatsuo Ishii [Mon, 24 Feb 2014 04:49:11 +0000 (13:49 +0900)]
Avoid to send queries to unrelated nodes in streaming replication mode.

Pgpool-II sends certain queries, such as BEGIN, END and SET commands to
all of DB nodes. However in streaming replication mode, only primary
node and at most one standby node are only concerned (if primacy node
is selected as the load balance node, only 1 node is concerned).

Think about 3 nodes cluster. Node 0 is primary, node 1 and 2 are
standby servers. Node 1 is selected as the load balance node. In this
case no query is needed to be sent to node 2, because DMLs are sent to
node 0 while SELECTs are sent to node 1.

For this purpose pool_setall_node_to_be_sent() is modified to only set
related nodes on the where_to_send node map. See [pgpool-hackers: 464]
for more details.

11 years agoAdd missing entries "relcache_size" and "check_temp_table" to show pool_status.
Tatsuo Ishii [Sun, 26 Jan 2014 06:10:39 +0000 (15:10 +0900)]
Add missing entries "relcache_size" and "check_temp_table" to show pool_status.

These should have been added when pgpool-II 3.2 was released...

11 years agoFix query cache bug with extended protocol.
Tatsuo Ishii [Sat, 25 Jan 2014 08:39:46 +0000 (17:39 +0900)]
Fix query cache bug with extended protocol.

SELECT retrieves outdated cache even DMS was executed in an expilicit
transaction. The bug had been there since in memory query cache was
born. Per [pgpool-general-jp: 1252].

11 years agoFix a link of documents
Yugo Nagata [Fri, 24 Jan 2014 09:45:55 +0000 (18:45 +0900)]
Fix a link of documents

11 years agoFix jdbc DML fails when operated in raw mode and auto commit is off.
Tatsuo Ishii [Sun, 19 Jan 2014 02:07:26 +0000 (11:07 +0900)]
Fix jdbc DML fails when operated in raw mode and auto commit is off.

When autocommit is off, bind() needs to start a transaction (if not
already in) for DMLs and do an insert lock if sequences are used in
replication mode. The fix was made into pgpool-II
3.3.2. Unfortunately, the fix forgot that it should be applied only
for replication mode. For other mode, that is not needed at all. The
bug reported in #92 happens when operated in raw mode and auto commit
is off.  When parse() executes it does not start a transaction because
we are in raw mode.  Then bind() starts a transaction by issuing
"BEGIN" which destroys the unnamed statement and the failure occurs.

Per bug #92.

11 years agoFix primary node detection logic.
Tatsuo Ishii [Tue, 14 Jan 2014 23:14:30 +0000 (08:14 +0900)]
Fix primary node detection logic.

There's a possibility that primary node is not detected. This happens
in following situation.  node 0: primary, node 1: standby. Node 0 goes
down. Health checking detects the fact but local status is not updated
yet. Primary node finding (find_primary_node) runs. Node 0's status is
yet healthy. Because find_primary_node fails to connect to node 0, it
immediately returns -1 and fails to find that fact that node 1 is now
primary.

Fix is just continuing to look for primary node when fails to connect
to a node.

Per [pgpool-general: 2409].