pgpool2.git
8 years agoFix occasional segfault when query cache is enabled.
Tatsuo Ishii [Tue, 20 Dec 2016 02:38:12 +0000 (11:38 +0900)]
Fix occasional segfault when query cache is enabled.

Per bug 263.

8 years agoAdopt the incompatibility with psql of PostgreSQL 9.6.
Tatsuo Ishii [Thu, 27 Oct 2016 08:36:28 +0000 (17:36 +0900)]
Adopt the incompatibility with psql of PostgreSQL 9.6.

Since -c option does not imply -X anymore in 9.6, regression fails if
.psqlrc is set, for example "\pset pager" is set.

8 years agoDo not cancel a query when the query resulted in an error other than in native replic...
Tatsuo Ishii [Thu, 27 Oct 2016 08:04:46 +0000 (17:04 +0900)]
Do not cancel a query when the query resulted in an error other than in native replication mode.

It was intended to keep the consistency, but there's no point in other
than native replication mode.

8 years agoRemove obsoleted option "-c".
Tatsuo Ishii [Thu, 27 Oct 2016 04:24:56 +0000 (13:24 +0900)]
Remove obsoleted option "-c".

Also fix typo in the help message.

9 years agoFix broken pool_config.c in the previous commit.
Tatsuo Ishii [Sat, 24 Sep 2016 09:24:33 +0000 (18:24 +0900)]
Fix broken pool_config.c in the previous commit.

9 years agoChange the default value of search_primary_node_timeout from 10 to 300.
Tatsuo Ishii [Sat, 24 Sep 2016 01:42:12 +0000 (10:42 +0900)]
Change the default value of search_primary_node_timeout from 10 to 300.

Prior default value 10 seconds is sometimes too short for a standby to
be promoted.

Per [pgpool-general: 5026].

9 years agoFix the case when all backends are down then 1 node attached.
Tatsuo Ishii [Wed, 21 Sep 2016 00:26:46 +0000 (09:26 +0900)]
Fix the case when all backends are down then 1 node attached.

When all backends are down, no connection is accepted. Then 1
PostgreSQL becomes up, and attach the node using pcp_attach_node. It
successfully finishes. However, when a new connection arrives, still
the connection is refused because pgpool child process looks into the
cached status, in which the recovered node is still in down status if
mode is streaming replication mode (native replication and other modes
are fine). Solution is, if all nodes are down, force to restart all
pgpool child.

Per bug 248.

9 years agoDo not use random() while generating MD5 salt.
Tatsuo Ishii [Fri, 9 Sep 2016 02:24:54 +0000 (11:24 +0900)]
Do not use random() while generating MD5 salt.

random() should not be used in security related applications.  To
replace random(), import PostmasterRandom() from PostgreSQL.  Also
store current time at the start up of Pgpool-II main process for later
use.

Per Coverity CID 1362583.

9 years agoRemove useless assignment.
Tatsuo Ishii [Fri, 9 Sep 2016 00:57:14 +0000 (09:57 +0900)]
Remove useless assignment.

Per coverity CID 1362589.

9 years agoDon't ignore sync message from frontend when query cache is enabled.
Tatsuo Ishii [Mon, 5 Sep 2016 23:08:32 +0000 (08:08 +0900)]
Don't ignore sync message from frontend when query cache is enabled.

While returning cached query result, sync message sent from frontend
is discarded. This is harmless because "ready for query" messages is
sent to frontend afterward. Problem is, AccessShareLock held by
previous parse message processing is not released until sync message
is received by the backend. Fix is, forwarding the sync message to
backend and discarding "ready for query" message returned from
backend.

Per [pgpool-hackers: 1787].

9 years agoPrepare 3.4.8 V3_4_8 V3_4_8_RPM
pengbo [Tue, 30 Aug 2016 10:02:34 +0000 (19:02 +0900)]
Prepare 3.4.8

9 years agoFix for 237: Pgpool-II fails to start if listen_addresses is empty string
Muhammad Usama [Mon, 29 Aug 2016 14:32:31 +0000 (19:32 +0500)]
Fix for 237: Pgpool-II fails to start if listen_addresses is empty string

The socket descriptor array (fds[]) was not getting the array end marker
when TCP listen addresses are not used.

9 years agoAdd comment to the document about connection_cache.
Tatsuo Ishii [Sat, 27 Aug 2016 08:22:26 +0000 (17:22 +0900)]
Add comment to the document about connection_cache.

Mention that connections to template0, template1, postgres and
regression databases are not cached even if connection_cache is on.

9 years agoTighten up health check timer expired condition in pool_check_fd()
Muhammad Usama [Mon, 22 Aug 2016 13:48:48 +0000 (18:48 +0500)]
Tighten up health check timer expired condition in pool_check_fd()

check if the signal was actually the health check timer expire to make sure that
we do not declare the timer expire due to some other signal arrived while
waiting for data for health check in pool_check_fd()

9 years agoFixing a typo in the log message
Muhammad Usama [Fri, 12 Aug 2016 12:07:10 +0000 (17:07 +0500)]
Fixing a typo in the log message

9 years agoUnbreak version 2 protocol case.
Tatsuo Ishii [Thu, 11 Aug 2016 09:35:19 +0000 (18:35 +0900)]
Unbreak version 2 protocol case.

Commit:
https://git.postgresql.org/gitweb/?p=pgpool2.git;a=commit;h=3cbce4eaf870e89fdd8f8a2ad8fab8d3d8aadf65

broke version 2 protocol case. In the session initiation phase,
"MAJOR" macro is used *before* session context is created.  In this
MAJOR macro returns PROTO_MAJOR_V3, which of course breaks v2 protocol
negotiation. Fix is, not to use MAJOR macro here.

9 years agofix japanese doc typo
Bo Peng [Wed, 3 Aug 2016 02:31:32 +0000 (11:31 +0900)]
fix japanese doc typo

9 years agoFixing a typo in english doc
Muhammad Usama [Mon, 1 Aug 2016 14:22:41 +0000 (19:22 +0500)]
Fixing a typo in english doc

9 years agoReplace "MAJOR" macro to prevent occasional failure.
Tatsuo Ishii [Wed, 27 Jul 2016 05:28:28 +0000 (14:28 +0900)]
Replace "MAJOR" macro to prevent occasional failure.

It is reported that the macro could cause segfault
[http://www.pgpool.net/mantisbt/view.php?id=225].  The macro calls
pool_virtual_master_db_node_id() and then access
backend->slots[id]->con using the node id returned.  In rare cases, it
could point to 0 (in case when the DB node is not connected), which
gives access to con->major, then it causes a segfault.

Since the intention of the macro is obtaining the protocol major
number, it is a little bit pointless to keep the info on the data for
each DB node because the number should be identical among DB
nodes. To fix this, now we have the protocol major and minor version
numbers in the session context and they are set when pgpool-II
connects to backend. The setter and getter functions are added .The
macro now just returns the stored data by using the getter function
(this will save a few cpu cycle).

9 years agoFix for [pgpool-hackers: 1501] kind does not match error
Muhammad Usama [Thu, 14 Jul 2016 13:50:51 +0000 (18:50 +0500)]
Fix for  [pgpool-hackers: 1501]  kind does not match error

pgpool throws ".. kind does not match.." error message when all the attached
backend nodes do not return the same response to the query. Although this error
message can be a symptom of the backend node sync issue in most cases, but in
case when the message kind of backend nodes differs because one of the backend
returned the notice response while the other returned some other kind then that
case should not be considered as an error case.

Consider the scenario where a pgpool is connected to multiple backend nodes and
is expecting to receive "[C] command complete" message from all nodes.
But while processing the query one of the backend also produced an extra warning message.
... WARNING: database "testdb" must be vacuum within 11000000 transaction

Although that the query was eventually successful on all backends, but as soon
as pgpool reads this WARNING message from one backend it will throw an error
ERROR: read_kind_from_backend: 1 th kind N does not match with master or majority connection kind C

But if pgpool would have kept reading from the backend, It would have also got
the expected command complete message after that warning notice

The solution for this is to keep forwarding the notice/log messages to the
frontend while reading the backend response in read_kind_from_backend() function
until the ERROR or expected message is received.

Though there is also one slight drawback of this approach, If the backends are
configured to forward all log messages to the client application, then the client
applications will get multiple log messages for the queries that are sent to
more than one node by pgpool.

test=# begin;
LOG:  statement: begin;
LOG:  statement: begin;
BEGIN

But since it is a very rare scenario, and just a minor inconvenience so it's not
holding us back to commit this solution until a better one arrives.

9 years agoFix handling of pcp_listen_addresses config parameter.
Muhammad Usama [Thu, 14 Jul 2016 12:33:43 +0000 (17:33 +0500)]
Fix handling of pcp_listen_addresses config parameter.

The config parameter was added by Ishii-San's
patch:d87e2706b88558321b2ad287374149d5ba15c3af but few changes were mistakenly
removed by commit:cdb49d3b783c03a7394e191e86763f364c7c6ce6

9 years agoSave and restore errno in each signal handler.
Tatsuo Ishii [Thu, 7 Jul 2016 07:17:39 +0000 (16:17 +0900)]
Save and restore errno in each signal handler.

9 years agoFix usage of wait(2) in pgpool main process
Tatsuo Ishii [Thu, 7 Jul 2016 05:19:35 +0000 (14:19 +0900)]
Fix usage of wait(2) in pgpool main process

Per [pgpool-hackers: 1444]. Here is the copy of the message:

Hi Usama,

I have noticed that the usage of wait(2) in pgpool main could cause
infinite wait in the system call.

    /* wait for all children to exit */
    do
    {
        wpid = wait(NULL);
    }while (wpid > 0 || (wpid == -1 && errno == EINTR));

When child process dies, SIGCHLD signal is raised and wait(2) knows
the event. However, multiple child death does not necessarily creates
exact same number of SIGCHLD signal as the number of dead children and
wait(2) could wait for an event which never happens in this case. I
actually encountered this situation while testing pgpool-II. Solution
is, to use waitpid(2) instead of wait(2).

9 years agoFix buffer over run problem in "show pool_nodes".
Tatsuo Ishii [Fri, 24 Jun 2016 06:56:01 +0000 (15:56 +0900)]
Fix buffer over run problem in "show pool_nodes".

While processing "show pool_nodes", the buffer for hostname was too
short. It should be same size as the buffer used for pgpool.conf.
Problem reported by a twitter user who is using pgpool on AWS (which
could have very long hostname).

9 years agochange docs V3_4_7 V3_4_7_RPM
pengbo [Mon, 20 Jun 2016 10:29:36 +0000 (19:29 +0900)]
change docs

9 years agochange docs
pengbo [Mon, 20 Jun 2016 09:50:44 +0000 (18:50 +0900)]
change docs

9 years agoPrepare 3.4.7
pengbo [Fri, 17 Jun 2016 09:23:07 +0000 (18:23 +0900)]
Prepare 3.4.7

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