pgpool2.git
9 years agoFix bug with load balance node id info on shmem
Tatsuo Ishii [Wed, 15 Jun 2016 07:34:51 +0000 (16:34 +0900)]
Fix bug with load balance node id info on shmem

There are few places where the load balance node was mistakenly put on
wrong place. It should be placed on:
ConnectionInfo *con_info[child id, connection pool_id, backend id].load_balancing_node].
In fact it was placed on:
*con_info[child id, connection pool_id, 0].load_balancing_node].

As long as the backend id in question is 0, it is ok. However while
testing pgpool-II 3.6's enhancement regarding failover, if primary
node is 1 (which is the load balance node) and standby is 0, a client
connecting to node 1 is disconnected when failover happens on node
0. This is unexpected and the bug was revealed.

It seems the bug was there since long time ago but it had not found
until today by the reason above.

9 years agochange the Makefile under this directory src/sql/,that is proposed by
pengbo [Thu, 9 Jun 2016 04:25:57 +0000 (13:25 +0900)]
change the Makefile under this directory src/sql/,that is proposed by
[pgpool-hackers: 1611]

    -PG_CONFIG = pg_config
    +PG_CONFIG ?= pg_config

9 years agoFix a posible hang during health checking
Yugo Nagata [Wed, 8 Jun 2016 11:59:03 +0000 (20:59 +0900)]
Fix a posible hang during health checking

Helath checking was hang when any data wasn't sent
from backend after connect(2) succeeded. To fix this,
pool_check_fd() returns 1 when select(2) exits with
EINTR due to SIGALRM while health checkking is performed.

Reported and patch provided by harukat and some modification
by Yugo. Per bug #204.

9 years agoDeal with the case when the primary is not node 0 in streaming replication mode.
Tatsuo Ishii [Wed, 25 May 2016 01:57:42 +0000 (10:57 +0900)]
Deal with the case when the primary is not node 0 in streaming replication mode.

http://www.pgpool.net/mantisbt/view.php?id=194#c837 reported that if
primary is not node 0, then statement timeout could occur even after
bug194-3.3.diff was applied. After some investigation, it appeared
that MASTER macro could return other than primary or load balance
node, which was not supposed to happen, thus do_query() sends queries
to wrong node (this is not clear from the report but I confirmed it in
my investigation).

pool_virtual_master_db_node_id(), which is called in MASTER macro
returns query_context->virtual_master_node_id if query context
exists. This could return wrong node if the variable has not been set
yet. To fix this, the function is modified: if the variable is not
either load balance node or primary node, the primary node id is
returned.

9 years agoIf statement timeout is enabled on backend and do_query() sends a
Tatsuo Ishii [Tue, 24 May 2016 14:29:54 +0000 (23:29 +0900)]
If statement timeout is enabled on backend and do_query() sends a
query to primary node, and all of following user queries are sent to
standby, it is possible that the next command, for example END, could
cause a statement timeout error on the primary, and a kind mismatch
error on pgpool-II is raised.

This fix tries to mitigate the problem by sending sync message instead
of flush message in do_query(), expecting that the sync message reset
the statement timeout timer if we are in an explicit transaction. We
cannot use this technique for implicit transaction case, because the
sync message removes the unnamed portal if there's any.

Plus, pg_stat_statement will no longer show the query issued by
do_query() as "running".

Per bug194.

9 years agoPermit pgpool to support multiple SSL cipher protocols
Muhammad Usama [Mon, 23 May 2016 15:24:08 +0000 (20:24 +0500)]
Permit pgpool to support multiple SSL cipher protocols

Currently TLSv1_method() is used to initialize the SSL context, that puts an
unnecessary limitation to allow only TLSv1 protocol for SSL communication.
While postgreSQL supports other ciphers protocols as well. The commit changes
the above and initializes the SSLSession using the SSLv23_method()
(same is also used by PostgreSQL). Because it can negotiate the use of the
highest mutually supported protocol version and remove the limitation of one
specific protocol version.

9 years agoFix confusing comments in pgpool.conf
Tatsuo Ishii [Fri, 20 May 2016 17:48:18 +0000 (02:48 +0900)]
Fix confusing comments in pgpool.conf

9 years agoFix Chinese documetation bug about raw mode
pengbo [Thu, 12 May 2016 02:15:17 +0000 (11:15 +0900)]
Fix Chinese documetation bug about raw mode

Connection pool is avalilable in raw mode.

9 years agoFix documetation bug about raw mode
Yugo Nagata [Wed, 11 May 2016 09:35:08 +0000 (18:35 +0900)]
Fix documetation bug about raw mode

Connection pool is avalilable in raw mode.

9 years agoFix is_set_transaction_serializable() when
pengbo [Mon, 9 May 2016 05:43:19 +0000 (14:43 +0900)]
Fix is_set_transaction_serializable() when
SET default_transaction_isolation TO 'serializable'.

SET default_transaction_isolation TO 'serializable' is sent to
not only primary but also to standby server in streaming replication mode,
and this causes an error. Fix is, in streaming replication mode,
SET default_transaction_isolation TO 'serializable' is sent only to the
primary server.

See bug 191 for related info.

9 years agoAllow to access to pgpool while doing health checking
Tatsuo Ishii [Thu, 5 May 2016 05:09:07 +0000 (14:09 +0900)]
Allow to access to pgpool while doing health checking

Currently any attempt to connect to pgpool fails if pgpool is doing
health check against failed node even if fail_over_on_backend_error is
off because pgpool child first tries to connect to all backend
including the failed one and exits if it fails to connect to a backend
(of course it fails). This is a temporary situation and will be
resolved before pgpool executes failover. However if the health check
is retrying, the temporary situation keeps longer depending on the
setting of health_check_max_retries and health_check_retry_delay. This
is not good. Attached patch tries to mitigate the problem:

- When an attempt to connect to backend fails, give up connecting to
  the failed node and skip to other node, rather than exiting the
  process if operating in streaming replication mode and the node is
  not primary node.

- Mark the local status of the failed node to "down".

- This will let the primary node be selected as a load balance node
  and every queries will be sent to the primary node. If there's other
  healthy standby nodes, one of them will be chosen as the load
  balance node.

- After the session is over, the child process will suicide to not
  retain the local status.

Per [pgpool-hackers: 1531].

9 years agoPrepare 3.4.6 V3_4_6 V3_4_6_RPM
pengbo [Tue, 26 Apr 2016 03:10:51 +0000 (12:10 +0900)]
Prepare 3.4.6

9 years agoPrepare 3.4.6
pengbo [Tue, 26 Apr 2016 01:31:22 +0000 (10:31 +0900)]
Prepare 3.4.6

9 years agoChange the PID length of pcp_proc_count command result to 6 characters long
pengbo [Wed, 20 Apr 2016 03:23:53 +0000 (12:23 +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 03:55:17 +0000 (12:55 +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:02:29 +0000 (20:02 +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 agoFix for [pgpool-general: 4569] PGPoolII-3.5 : segfault
Muhammad Usama [Wed, 6 Apr 2016 18:57:46 +0000 (23:57 +0500)]
Fix for [pgpool-general: 4569] PGPoolII-3.5 : segfault

PostgreSQL's memory and exception manager APIs adopted by the pgpool 3.4 are not
thread safe and are causing the segmentation fault in the watchdog lifecheck
process, as it uses the threads to ping configured trusted hosts for checking
the upstream connections.
Fix is to remove threads and use the child process approach instead.

9 years agoPrepare 3.4.5 V3_4_5 V3_4_5_RPM
Yugo Nagata [Mon, 4 Apr 2016 10:50:50 +0000 (19:50 +0900)]
Prepare 3.4.5

9 years agoPrepare 3.4.5
Yugo Nagata [Mon, 4 Apr 2016 10:18:55 +0000 (19:18 +0900)]
Prepare 3.4.5

9 years agoValidating the PCP packet length
Muhammad Usama [Tue, 29 Mar 2016 20:16:40 +0000 (01:16 +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:07:24 +0000 (14:07 +0900)]
Fix typo

9 years agoFix pgpool_setup to not confuse log output
Tatsuo Ishii [Sat, 26 Mar 2016 22:49:53 +0000 (07:49 +0900)]
Fix pgpool_setup to not confuse log output

Before it simply redirects the stdout and stderr of pgpool process to
a log file.  This could cause log contents being garbled or even
missed because of race condition caused by multiple process being
writing concurrently. I and Usama found this while investigating the
regression failure of 004.watchdog.

To fix this, pgpool_setup now generates startall script so that pgpool
now sends stdout/stderr to cat command and cat writes to the log file
(It seems the race condition does not occur when writing to a pipe).

9 years agoFix installation procedure.
Tatsuo Ishii [Sat, 19 Mar 2016 02:05:26 +0000 (11:05 +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 agoFix typo in configure
Tatsuo Ishii [Mon, 14 Mar 2016 23:11:36 +0000 (08:11 +0900)]
Fix typo in configure

Patch provided by Thomas Munro.

9 years agoYet another reset query stuck problem fix. [pgpool-general: 4265]
Muhammad Usama [Mon, 22 Feb 2016 11:42:03 +0000 (16:42 +0500)]
Yet another reset query stuck problem fix. [pgpool-general: 4265]

The solution is to report FRONTEND_ERROR instead of simple ERROR when
pool_flush on front-end socket fails

The patch is generated by me and Pawel Ufnalewski<archon@foap.com> and
Gerhard Wiesinger <lists@wiesinger.com> helped to verify and test the fix

9 years agoFix previous bronken commit
Yugo Nagata [Wed, 17 Feb 2016 08:24:54 +0000 (17:24 +0900)]
Fix previous bronken commit

The following commit was broken and regress test 001 failed.
- Fix memorry leak reported by Coverity (CID 1350095)

9 years agoFixing pgpool-recovery module compilation issue with PostgreSQL 9.6
Muhammad Usama [Fri, 12 Feb 2016 12:30:10 +0000 (17:30 +0500)]
Fixing pgpool-recovery module compilation issue with PostgreSQL 9.6

Incorporating the change of function signature for GetConfigOption..()
functions in PostgreSQL 9.6

9 years agoFix memorry leak reported by Coverity (CID 1350095)
Yugo Nagata [Fri, 12 Feb 2016 06:41:39 +0000 (15:41 +0900)]
Fix memorry leak reported by Coverity (CID 1350095)

9 years agoFix test/regression/clean.sh to remove binary files of 010.rewrite_timestamp test
Yugo Nagata [Wed, 10 Feb 2016 08:46:05 +0000 (17:46 +0900)]
Fix test/regression/clean.sh to remove binary files of 010.rewrite_timestamp test

9 years agoPrepare 3.4.4 V3_4_4
Yugo Nagata [Fri, 5 Feb 2016 06:17:33 +0000 (15:17 +0900)]
Prepare 3.4.4

9 years agoFix a compile issue on freebsd, added missing include files
Muhammad Usama [Wed, 3 Feb 2016 12:03:47 +0000 (17:03 +0500)]
Fix a compile issue on freebsd, added missing include files

9 years agoAllow timeout value to be specified by the command option
Yugo Nagata [Tue, 2 Feb 2016 01:36:06 +0000 (10:36 +0900)]
Allow timeout value to be specified by the command option

9 years agoFix regression test to check timeout of each test
Yugo Nagata [Mon, 1 Feb 2016 08:58:12 +0000 (17:58 +0900)]
Fix regression test to check timeout of each test

9 years agoAdd some warning messages for wd_authkey hash calculation failure
Yugo Nagata [Mon, 1 Feb 2016 06:51:12 +0000 (15:51 +0900)]
Add some warning messages for wd_authkey hash calculation failure

Sometimes wd_authkey calculation fails for some reason other than
authkey mismatch. The additional messages make these distingushable
for each other.

9 years agoFix for [pgpool-II 0000165]: Performance degradation(x250) while using ipv6
Muhammad Usama [Fri, 29 Jan 2016 04:51:46 +0000 (09:51 +0500)]
Fix for [pgpool-II 0000165]: Performance degradation(x250) while using ipv6

Missing TCP_NODELAY option for ipV6 socket was the reason.

9 years agoFix regression test 008 & 009 failure in debug mode
Yugo Nagata [Wed, 27 Jan 2016 08:23:03 +0000 (17:23 +0900)]
Fix regression test 008 & 009 failure in debug mode

9 years agoFix reset query stuck problem.
Tatsuo Ishii [Wed, 27 Jan 2016 06:32:21 +0000 (15:32 +0900)]
Fix reset query stuck problem.

When pool_read fails to read from frontend or pool_flush fails to
write to the frontend, report FRONTEND_ERROR, rather than ERROR to
disconnect and terminate pgpool child process to prevent the query
stuck problem.

Patch for pool_read by Usama, for pool_flush by Tatsuo.

9 years agoAdd test of white/black_memqcache_table_list to regress #006
Yugo Nagata [Thu, 21 Jan 2016 02:16:28 +0000 (11:16 +0900)]
Add test of white/black_memqcache_table_list to regress #006

9 years agoFix bug#156: problem with reloading.
Tatsuo Ishii [Sun, 17 Jan 2016 12:11:31 +0000 (21:11 +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 agoFix white/black_memqcache_table_list not require quotaion
Yugo Nagata [Thu, 14 Jan 2016 04:33:14 +0000 (13:33 +0900)]
Fix white/black_memqcache_table_list not require quotaion

The tables and schemas name specified in *_memqcache_table_list
were needed to be quoted by double quotation since commit
43ff7d3de9db4c8a1143258f4ffff98682dab560. This is fixed
by stripping quote from table name before pattern matching.

Patch contributed by Dang Minh Huong.
Per [pgpool-hackers: 1323]

9 years agoFix regression test 003.failover for rhel7 postgresql rpm
Yugo Nagata [Wed, 6 Jan 2016 04:08:45 +0000 (13:08 +0900)]
Fix regression test 003.failover for rhel7 postgresql rpm

The expected result of 'show pool_nodes' is fixed to use
PGSOCKET_DIR in hostname column.

9 years agoFixing the logic issue in get_backends_status() function
Muhammad Usama [Tue, 5 Jan 2016 18:19:21 +0000 (23:19 +0500)]
Fixing the logic issue in get_backends_status() function

get_backends_status () function counts the number of current valid and down
backend nodes. The issue with the function logic was, it assumes the node is
also invalid when its connection status is down, that is not always right.
The commit also fix some log messages

9 years agoAdd missing \n in help messages
Yugo Nagata [Tue, 5 Jan 2016 08:42:02 +0000 (17:42 +0900)]
Add missing \n in help messages

9 years agoFix to use saved errno for erreport instead of the direct value
Yugo Nagata [Mon, 4 Jan 2016 05:29:30 +0000 (14:29 +0900)]
Fix to use saved errno for erreport instead of the direct value

Some system calls are called in errmsg() and errhint(), and
it isn't safe to pass errno directly as an argument. This caused
the confusable log message as below.

 DETAIL: connect() reports failure "Success"

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

9 years agoFix to show wrong error.
Tatsuo Ishii [Fri, 25 Dec 2015 08:40:51 +0000 (17:40 +0900)]
Fix to show wrong error.

connect_with_timeout() does not show proper error info when
getsockopt(SO_ERROR) reports an error. Pointed out in bug#159.

9 years agoFix to use timeout command to handle time out of regress test 062
Yugo Nagata [Fri, 25 Dec 2015 05:46:46 +0000 (14:46 +0900)]
Fix to use timeout command to handle time out of regress test 062

9 years agoRemove comments for the function that doesn't exist
Yugo Nagata [Tue, 22 Dec 2015 08:47:46 +0000 (17:47 +0900)]
Remove comments for the function that doesn't exist

The source file was imported from postgresql but this
function was removed in pgpool and only the comments remained.

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

9 years agoFix 0000151: Error message has typo - "md5 authentication failed"
Muhammad Usama [Wed, 25 Nov 2015 08:11:18 +0000 (13:11 +0500)]
Fix 0000151: Error message has typo - "md5 authentication failed"

9 years agoFixing [pgpool-II 0000139]: broken arping_cmd
Muhammad Usama [Wed, 18 Nov 2015 13:53:01 +0000 (18:53 +0500)]
Fixing [pgpool-II 0000139]: broken arping_cmd

wd_chk_setuid() function was bailing out with the NOTICE message as soon as it
finds the setuid bit is not set on any configured network command and was
ignoring the rest of configurations.
wd_chk_setuid() function name is also changed to wd_check_network_command_configurations()

9 years agoFixing reset query stuck problem [pgpool-hackers: 1097]
Muhammad Usama [Wed, 18 Nov 2015 13:31:20 +0000 (18:31 +0500)]
Fixing reset query stuck problem [pgpool-hackers: 1097]

The issue is already fixed in older branches by the
commit id "cb735f22441001b6afdbb5bac72808db66094ca9", and this fix adopts the
same solution used by 3.3 branch, i.e. closing the backend connection
when client idle limit is reached.

9 years agoFix previous commit for regression test 055
Yugo Nagata [Wed, 11 Nov 2015 07:00:36 +0000 (16:00 +0900)]
Fix previous commit for regression test 055

9 years agoFix regression test 055 for rhel7 rpm
Yugo Nagata [Tue, 10 Nov 2015 12:28:52 +0000 (21:28 +0900)]
Fix regression test 055 for rhel7 rpm

9 years agoFix a bug of regress.sh option handling
Yugo Nagata [Mon, 9 Nov 2015 10:32:40 +0000 (19:32 +0900)]
Fix a bug of regress.sh option handling

9 years agoAdd missing descriptions about default values to documents
Yugo Nagata [Mon, 9 Nov 2015 05:20:50 +0000 (14:20 +0900)]
Add missing descriptions about default values to documents

9 years agoFix the previous commit's echo missing redirect to conf file
Yugo Nagata [Thu, 5 Nov 2015 17:29:28 +0000 (02:29 +0900)]
Fix the previous commit's echo missing redirect to conf file

9 years agoAdd option to regress.sh and pgpool_setup for unix domain socket directory
Yugo Nagata [Wed, 4 Nov 2015 09:30:20 +0000 (18:30 +0900)]
Add option to regress.sh and pgpool_setup for unix domain socket directory

The new option of regress.sh is -s to specivy unix domain socket
directory. Default is /tmp. And environment variable PGSOCKET_DIR
is added for pgpool_setup

9 years agoFix pgpool_setup to use DEFAULT_PGSOCKET_DIR in pg_config_manual.h
Yugo Nagata [Wed, 4 Nov 2015 07:28:23 +0000 (16:28 +0900)]
Fix pgpool_setup to use DEFAULT_PGSOCKET_DIR in pg_config_manual.h

Some Postgresql rpms define DEFAULT_PGSOCKET_DIR as /tmp, others as
/var/run/postgresql. This affects not only PostgreSQL server but
also libpq and psql.

This is a workaround for regression test. We might have to fix
pgpool-II code to control default value of backend_hostname*.

9 years agoForce pgpool_setup to set unix_socket_directories to '/tmp'
Yugo Nagata [Wed, 4 Nov 2015 04:56:27 +0000 (13:56 +0900)]
Force pgpool_setup to set unix_socket_directories to '/tmp'

This is a workaround for PostgreSQL RHEL7 RPM, which sets
it to '/var/run/postgresql'.

9 years agoUnbreak "make dist".
Tatsuo Ishii [Sat, 31 Oct 2015 00:29:13 +0000 (09:29 +0900)]
Unbreak "make dist".

While removing some directories under src/test, Makefile.am was left
unchaged and "make dist" has been broken since then.

9 years agoFix possible hang-up of regression test 054.postgres_fdw
Yugo Nagata [Fri, 30 Oct 2015 09:11:24 +0000 (18:11 +0900)]
Fix possible hang-up of regression test 054.postgres_fdw

In this test, psql acceses foreign table through backend node #1
like folowings:
 node #1 (PostgreSQL)-> pgpool -> node #0 (PostgreSQL)
For this purpose, node #1 should be detached from pgpool
to avoid closed loop. However, the node might not be detached yet
just after pcp_detach_node command. This caused the hang-up.

To fix this, sleep 1 is inserted after pcp_detach_node.

9 years agoFix regression test 065.
Tatsuo Ishii [Thu, 29 Oct 2015 04:23:17 +0000 (13:23 +0900)]
Fix regression test 065.

The path to JDBC driver was explicitly defined. This is wrong. This
should be inherited from JDBC_DRIVER environment variable.

9 years agoAdd comments to clarify what are the requirements for the script.
Tatsuo Ishii [Wed, 21 Oct 2015 05:07:30 +0000 (14:07 +0900)]
Add comments to clarify what are the requirements for the script.

Also add "-c" option to rsync to allow check sum checking.

9 years agoFix in memory query cache bug reported in bug#152.
Tatsuo Ishii [Mon, 19 Oct 2015 03:42:41 +0000 (12:42 +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*).

Also new regression test is added to check the bug.

9 years agoFix bug reported in bug#145.
Tatsuo Ishii [Fri, 16 Oct 2015 09:18:09 +0000 (18:18 +0900)]
Fix bug reported in bug#145.

The problem occurs when all the condition below are met:

1) pgpool-II 3.4 or later
2) streaming replication mode
3) primary node is also load balance node
4) extended protocol is used
5) client_idle_limit reached

After the extended protocol query finished, the client stays idle. When
client_idle_limit is reached, reset_query_list() is called to send
reset query but it is only sent to the primary node. CommandComplete
message is returned from the primary node. Because
doing_extended_query_message flag remains on, ProcessBackendResponse()
happily resets query_in_progress flag. The ReadyForQuery message
arrives and pgpool-II tries to read the message not only from the
primary but the standby because there's no query context (remember that
the query_in_progress flags is off). Since the standby did not receive
the reset query, it does not respond and pgpool-II hangs here.

The fix is, resetting doing_extended_query_message flag in
reset_query_list().

Note that pgpool-II 3.3 or before does not have the problem since it
disconnects connections to backend right after client_idle_limit is
reached.

9 years agoRemove restriction section regarding on disk query cache.
Tatsuo Ishii [Fri, 16 Oct 2015 06:06:30 +0000 (15:06 +0900)]
Remove restriction section regarding on disk query cache.

Accidentaly left when on disk query cache was removed.

9 years agoAdd caution about JDBC driver version regarding app_name_redirect_preference_list.
Tatsuo Ishii [Fri, 16 Oct 2015 06:01:53 +0000 (15:01 +0900)]
Add caution about JDBC driver version regarding app_name_redirect_preference_list.

9 years agoUpdate copyright year.
Tatsuo Ishii [Fri, 16 Oct 2015 05:32:24 +0000 (14:32 +0900)]
Update copyright year.

9 years agoFix segfalut that occurs when function is used in FROM clause
Yugo Nagata [Thu, 15 Oct 2015 02:48:08 +0000 (11:48 +0900)]
Fix segfalut that occurs when function is used in FROM clause

When a function is used in FROM, the parser makes a RangeFunction
node whose functions member is a list whose last element is NIL.
This caused segfault in foreach loop in _outList().

PRPARE statements in streaming-reaplication mode and INSERT/UPDATE
with SELECT in native-replication mode were affected. For example:

- prepare p as select * from generate_series(1,1);
- insert into tbl select now(), * from generate_series(1,1);

9 years agoFix bugs with data modifying WITH clause reported in bug#153.
Tatsuo Ishii [Wed, 14 Oct 2015 02:25:51 +0000 (11:25 +0900)]
Fix bugs with data modifying WITH clause reported in bug#153.

pgpool-II does not recognize the data modifying WITH clause despite
pgpool-II 3.3 or after has SQL parser which recognizes it. The bug has
been fixed in pgpool-II 3.5 (having PostgreSQL 9.5 parser).

Data modifying WITH clause was introduced in PostgreSQL 9.1. Since
pgpool-II 3.3 has 9.2 parser and pgpool-II 3.4 has 9.4 parser, the fix
is back ported to pgpool-II 3.3 and 3.4.

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 regression test driver.
Tatsuo Ishii [Thu, 27 Aug 2015 04:07:35 +0000 (13:07 +0900)]
Fix regression test driver.

In pgpool-II 3.5, libpcp.a is not compatible with previous ones. This
results in segfault when pcp_recovery_node gets executed if the
command links to older version of the library. Solution is, set
${PGPOOL_INSTALL_DIR}/lib to LD_LIBRARY_PATH so that the command links
proper version of library.

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

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

10 years agoRemove rpm_installer directory
Yugo Nagata [Fri, 21 Aug 2015 06:39:41 +0000 (15:39 +0900)]
Remove rpm_installer directory

Codes of RPM building and installer are maintained by GitHub.

10 years agoRemove tests directory which are incorporated into regression test
Yugo Nagata [Fri, 21 Aug 2015 06:05:05 +0000 (15:05 +0900)]
Remove tests directory which are incorporated into regression test

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 agoFix untranslated sentence in Japanese document
Yugo Nagata [Fri, 21 Aug 2015 04:33:33 +0000 (13:33 +0900)]
Fix untranslated sentence in Japanese document

10 years agoAdd forgotten Makefile to rewrite-timestamp regress test
Yugo Nagata [Thu, 20 Aug 2015 06:29:52 +0000 (15:29 +0900)]
Add forgotten Makefile to rewrite-timestamp regress test

10 years agoAdd unit test of timestamp rewrite into regession test suite
Yugo Nagata [Thu, 20 Aug 2015 03:05:55 +0000 (12:05 +0900)]
Add unit test of timestamp rewrite into regession test suite

10 years agoFix complication error and segfault of timestamp rewrite test
Yugo Nagata [Wed, 19 Aug 2015 09:53:59 +0000 (18:53 +0900)]
Fix complication error and segfault of timestamp rewrite test

10 years agoRemove a test code
Yugo Nagata [Wed, 19 Aug 2015 08:29:57 +0000 (17:29 +0900)]
Remove a test code

10 years agoFix inconsistency of sequence values in replication mode
Yugo Nagata [Wed, 19 Aug 2015 07:13:00 +0000 (16:13 +0900)]
Fix inconsistency of sequence values in replication mode

Due to the following commit, table names were always quoted
in queries to check needs for insert lock, whether this is
view, wheter this has default value of timestamp etc. However,
when schema name was provided, table name was quoted wrongly as
like "public.tbl" instead of "public"."tbl". So, pool_regclass
and to_regclass couldn't find right talbe oid and insert lock
was never executed. This caused inconsistency between DB nodes.

In previous codes, quotation marks "" are once remove from
table name returnd by nodeToString, and re-quoted in issued
query. Instead, fixed codes don't remove and use directy in
pgpool_regclass or to_regclass. make_table_from_rangevar()
are also fixed to return table name including quotation marks.
However, when neither pgool_regclass or to_regclass is available,
quotation marks and schema name are removed from table name,
because pg_class.relname is used in this case.

In addition, fix to use to_regclass in insert lock functions
if available.

10 years agoFix regress test to sleep after pgpool_reload
Yugo Nagata [Wed, 19 Aug 2015 04:11:25 +0000 (13:11 +0900)]
Fix regress test to sleep after pgpool_reload

Some regression tests test behaviors after pgpool-II configuration
is modified and reloaded. However, sometimes these modification
were not applied to pgpool just after reloading.

It was observed after the following commit.

 commit ba24a708ed61d6a5fa296451b194c4b448ed5966
 Author: Tatsuo Ishii <ishii@postgresql.org>
 Date:   Thu Aug 6 13:02:42 2015 +0900

 Issue fsync() when writing pgpool_status.

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

It seem to be because fsync() takes a time before SIGHUP is sent
to child processes in reload_config().

Fix is to add sleep to wait for applying modification after
pgpool_reload.

In addition, some messages are added to test for debugging.

10 years agoFix broken regression test for native replication
Yugo Nagata [Tue, 18 Aug 2015 10:31:03 +0000 (19:31 +0900)]
Fix broken regression test for native replication

Test for insert lock didn't work.

10 years agoFix false alert of regression tset 062
Yugo Nagata [Tue, 18 Aug 2015 10:25:30 +0000 (19:25 +0900)]
Fix false alert of regression tset 062

Sleep before timedout was too short.

10 years agoFix reset query stuck problem. (Porting the solution from older branches)
Muhammad Usama [Tue, 18 Aug 2015 12:20:37 +0000 (17:20 +0500)]
Fix reset query stuck problem. (Porting the solution from older branches)

It is reported that reset query (DISCARD ALL etc.) occasionally does not finish
and pgpool child remain waiting for reply from the 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 to keep track of the status of frontend socket state and not caching
the PostgreSQL connection if the connection to frontend was not properly terminated.

10 years agoIssue fsync() when writing pgpool_status.
Tatsuo Ishii [Thu, 6 Aug 2015 04:02:42 +0000 (13:02 +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.4.3 V3_4_3 V3_4_3_RPM1
Yugo Nagata [Fri, 24 Jul 2015 05:25:58 +0000 (14:25 +0900)]
Prepare 3.4.3

10 years agoCode cleanup: Removing the commented out code line.
Muhammad Usama [Thu, 9 Jul 2015 11:45:52 +0000 (16:45 +0500)]
Code cleanup: Removing the commented out code line.

10 years agoSave pgpool_status to disk each time when it is changed.
Tatsuo Ishii [Thu, 9 Jul 2015 04:13:00 +0000 (13:13 +0900)]
Save pgpool_status to disk each time when it is changed.

Currently pgpool-II does not save pgpool_status file when it's
changed. Instead it saves when pgpool-II explicitly is going
shutdown. This is fine in most cases and it saves slight CPU cycles.
But what if pgpool-II killed abnormally? Or the system forces
pgpool-II to go down by OOM killer?  In these cases next pgpool-II
restarting could load obsolete status file.

This fix is a guard against such that situation by saving the
pgpool_status file each time when it's changed.

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 agoAdd regression test for previous commit.
Tatsuo Ishii [Fri, 19 Jun 2015 17:07:30 +0000 (02:07 +0900)]
Add regression test for previous commit.

10 years agoFix the case when user table includes spaces.
Tatsuo Ishii [Fri, 19 Jun 2015 16:39:44 +0000 (01:39 +0900)]
Fix the case when user table includes spaces.

For example if table names including space are used (of course using
delimited identifier), pgpool-II cannot be handled correctly by the
internal functions which access system catalogs and it results in SQL
errors. Solution is, to always use delimited identifier. Per bug#136.
Also see [pgpool-general: 3818].

10 years agoFix "select() system call interrupted" error.
Tatsuo Ishii [Thu, 28 May 2015 23:03:52 +0000 (08:03 +0900)]
Fix "select() system call interrupted" error.

The health check process complains above then

ERROR:  failed to make persistent db connection
DETAIL:  connection to host:"x.x.x.x:5432 failed

But the healthchek does not trigger fail over nor retrying (if the
retry parameter is configured). So except the annoying message above
everything goes well.

I guess this is caused by SIGCHLD interrupt while select(2) waiting
for completion of connect(2) call. It is likely that pgpool child dies
because of child_life_time. The directive is triggered if child is
idle for specified period. Since this happens independently among each
child process, if num_init_children is big (in the reported case, it
is 2000). So the case could occur more easily if 1) num_init_children
is big and 2) pgpool children go into idle state (no query arrived
from client for child_life_time seconds).

We suppose a system call interruption could occur by SIGALRM which is
set by pgpool to detect time of the connect(2) call if
health_check_timeout is non 0. However we did not think about the case
above.

The fix is, if select(2) is interrupted by a system call, check
health_check_timeout variable and it is not set, we can assume that
the interruption is caused by other than SIGALRM and retries the
select(2).

Original bug report is [pgpool-general: 3756] Connection Interrupted.
Patch created by me. Enhancement from Usama.

Also I got similar report (but on 3.3) from another user. So I will
make similar commit to 3.3 stable tree as well.

10 years agoFixing a problem in elog.c when forwarding a message to frontend clients.
Muhammad Usama [Thu, 28 May 2015 12:17:35 +0000 (17:17 +0500)]
Fixing a problem in elog.c when forwarding a message to frontend clients.

Error while forwarding the message to the frontend client can potentially cause
the infinite recursion and terminate the child with ERRORDATA_STACK_SIZE exceeded error.
Fix is to check the recursion depth of send_message_to_frontend() function
and pulling the plug if it is more than two levels deep.