pgpool2.git
11 years agoAdd a description that pcp_detach_node disconnects existing sessions.
Tatsuo Ishii [Fri, 25 Jul 2014 04:59:20 +0000 (13:59 +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:40:51 +0000 (15:40 +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.

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:50:50 +0000 (18:50 +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:42:53 +0000 (17:42 +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 agoFix coverity issue:1222999 Resource leak.
Muhammad Usama [Fri, 11 Jul 2014 11:14:00 +0000 (16:14 +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:58:29 +0000 (14:58 +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 coverity issue:1223007 Use after free.
Muhammad Usama [Tue, 8 Jul 2014 12:15:22 +0000 (17:15 +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 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:35:11 +0000 (15:35 +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 [Sat, 5 Apr 2014 09:27:41 +0000 (18:27 +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 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.1.11 V3_1_11
Yugo Nagata [Mon, 24 Mar 2014 13:55:31 +0000 (22:55 +0900)]
Prepare 3.1.11

11 years agoAdd description about parallel mode doesn't support PREPARE
Yugo Nagata [Mon, 24 Mar 2014 09:56:06 +0000 (18:56 +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 agoForgotten in previous commit
Yugo Nagata [Fri, 28 Feb 2014 10:51:02 +0000 (19:51 +0900)]
Forgotten in previous commit

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 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 agoFix possible buffer overrun problem and memory leak.
Tatsuo Ishii [Mon, 24 Feb 2014 06:39:30 +0000 (15:39 +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. Also add symlink to pcp/strlcpy.

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

11 years agoFix cache locality of unlogged tables detection code.
Tatsuo Ishii [Tue, 7 Jan 2014 04:54:02 +0000 (13:54 +0900)]
Fix cache locality of unlogged tables detection code.

It was mistakenly defined as a session local cache, which causes
unwanted cache invalidation at session starting, which brings bad
performance. Pointed out at [pgpool-hackers: 435][[pgpool-general:
2325].

11 years agoFix conflict caused by previous commit.
Tatsuo Ishii [Thu, 19 Dec 2013 02:30:12 +0000 (11:30 +0900)]
Fix conflict caused by previous commit.

11 years agoFix conflict caused by previous commit.
Tatsuo Ishii [Thu, 19 Dec 2013 02:26:36 +0000 (11:26 +0900)]
Fix conflict caused by previous commit.

11 years agoFix conflict caused by previous commit.
Tatsuo Ishii [Thu, 19 Dec 2013 02:19:26 +0000 (11:19 +0900)]
Fix conflict caused by previous commit.

11 years agoAdd mention about listen queue and how to increase the backlog in the num_init_childr...
Tatsuo Ishii [Thu, 19 Dec 2013 02:06:28 +0000 (11:06 +0900)]
Add mention about listen queue and how to increase the backlog in the num_init_children section.

11 years agoFix typo V3_1_10
Nozomi Anzai [Fri, 6 Dec 2013 05:18:51 +0000 (14:18 +0900)]
Fix typo

11 years agoPrepare 3.1.10
Nozomi Anzai [Wed, 4 Dec 2013 08:50:04 +0000 (17:50 +0900)]
Prepare 3.1.10

11 years agoFix resource leak in make_persistent_db_connection.
Tatsuo Ishii [Tue, 26 Nov 2013 07:30:51 +0000 (16:30 +0900)]
Fix resource leak in make_persistent_db_connection.

For this pupose, new static function
free_persisten_db_connection_memory is added.
Per Coverity report #1111468.

11 years agoFix strftime() usage in pool_pools().
Tatsuo Ishii [Fri, 22 Nov 2013 13:04:02 +0000 (22:04 +0900)]
Fix strftime() usage in pool_pools().

The buffer is not large enough as expected by the second parameter.
This is not harmless because the format string will not produce longer
result string than the buffer.

Per Coverity report 1111426 "Out-of-bounds access".

11 years agoFix pool_send_severity_message(). Message buffer is 1 byte small.
Tatsuo Ishii [Fri, 22 Nov 2013 11:39:31 +0000 (20:39 +0900)]
Fix pool_send_severity_message(). Message buffer is 1 byte small.

Per Coverity report 1111432 "Out-of-bounds access".

11 years agoFix read_kind_from_backend() possible segfault when all backend down.
Tatsuo Ishii [Fri, 22 Nov 2013 11:24:35 +0000 (20:24 +0900)]
Fix read_kind_from_backend() possible segfault when all backend down.

Per Coverity report 1111414 "Negative array index read".

11 years agoFix buffer overrun when ps string is longer than 1023.
Tatsuo Ishii [Thu, 21 Nov 2013 03:17:03 +0000 (12:17 +0900)]
Fix buffer overrun when ps string is longer than 1023.

In reality this could hardly occur, but bug is a bug.
Per Coverity report 1111427 "Out-of-bounds write".

11 years agoFix uninialized variables when all nodes are down.
Tatsuo Ishii [Thu, 21 Nov 2013 02:33:45 +0000 (11:33 +0900)]
Fix uninialized variables when all nodes are down.

Per Coverity report 1111489 and 1111490.

11 years agoFix possible segfault in CopyDataRaws().
Tatsuo Ishii [Wed, 20 Nov 2013 07:51:03 +0000 (16:51 +0900)]
Fix possible segfault in CopyDataRaws().

Coverity pointed out that if pool_get_id() returns an error,
VALID_BACKEND will access out of array.  Per Coverity report 1111413
"Memory - illegal accesses".

11 years agoFix buffer overrun bug and resource leak bug of parse_copy_data().
Tatsuo Ishii [Tue, 19 Nov 2013 07:18:39 +0000 (16:18 +0900)]
Fix buffer overrun bug and resource leak bug of parse_copy_data().

Per Coverity report 1111427 "Out-of-bounds write" and 1111453
"Resource leak".

11 years agoFix to add node id range check when issue an error message using node id.
Tatsuo Ishii [Tue, 19 Nov 2013 06:25:05 +0000 (15:25 +0900)]
Fix to add node id range check when issue an error message using node id.

Per Coverity report #1111433 "Out-of-bounds read".

11 years agoRemove unused code.
Tatsuo Ishii [Tue, 19 Nov 2013 05:51:18 +0000 (14:51 +0900)]
Remove unused code.

Per Coverity report #1111487 "Uninitialized pointer read".

11 years agoFix uninitialized variable in error case in pool_do_auth().
Tatsuo Ishii [Sun, 17 Nov 2013 04:44:48 +0000 (13:44 +0900)]
Fix uninitialized variable in error case in pool_do_auth().

If there's no valid backend, pgpool will return garbage pid to
frontend in auth phase. Actually because no backend is available,
frontend will be disconnected later on. So this is not harmless.
Per Coverity report "1127331 Uninitialized scalar variable".

11 years agoFix that the script forgets to allow public access to pgpool_catalog.
Tatsuo Ishii [Mon, 11 Nov 2013 22:59:36 +0000 (07:59 +0900)]
Fix that the script forgets to allow public access to pgpool_catalog.

The bug prevents inserting data into user tables if pgpool_catalog is
created in native replication mode.  The bug was there from day 1. I
wonder why nobody noticed until today.  Per [pgpool-general-jp: 1229].

11 years agoDo not set/unset fronted connection info for dead backend.
Tatsuo Ishii [Mon, 11 Nov 2013 11:48:12 +0000 (20:48 +0900)]
Do not set/unset fronted connection info for dead backend.

Per bug #82.

11 years agoFix range check bug of MAX_NUM_BACKENDS in corner case.
Tatsuo Ishii [Wed, 6 Nov 2013 11:37:40 +0000 (20:37 +0900)]
Fix range check bug of MAX_NUM_BACKENDS in corner case.

MAX_NUM_BACKENDS is the allowed max number of DB nodes (128, at this
point). In reality, probably no one ever tried more than 128 DB nodes
and that's the reason why nobody noticed.

Per Coverity report "11114291111430 and 1111431 Out-of-bounds
write".

11 years agoFix target node selection logic when "DEALLOCATE portal|statement".
Tatsuo Ishii [Wed, 6 Nov 2013 11:10:24 +0000 (20:10 +0900)]
Fix target node selection logic when "DEALLOCATE portal|statement".

When "DEALLOCATE portal|statement" is used and last prepared statement
or portal was not found, target node selection map is not
set. Probably this is not actually harmful because prepared statement
or portal was not found is an error case. The bug was there since day
0.

Per Coverity report "1111491 Structurally dead code".

11 years agoFix memory leak when do_query() fails in timestamp rewriting.
Tatsuo Ishii [Sun, 3 Nov 2013 13:07:01 +0000 (22:07 +0900)]
Fix memory leak when do_query() fails in timestamp rewriting.

For this purpose free_select_result() is changed to accept NULL
argument.  Per Coverity report "11114541111455 Resource leak".

11 years agoFix memory leak when SSL is requested.
Tatsuo Ishii [Sat, 2 Nov 2013 03:25:28 +0000 (12:25 +0900)]
Fix memory leak when SSL is requested.

When SSL is requested, pgpool child retries to read start up packet.
However it does not free the memory for previous start up packet.

Per Coverity report "1111443 Resource".

11 years agoFix to check return status of pool_read().
Tatsuo Ishii [Sat, 2 Nov 2013 02:42:52 +0000 (11:42 +0900)]
Fix to check return status of pool_read().

Per Coverity report "1111374 Unchecked return value.

11 years agoFix error message in read_password_packet().
Tatsuo Ishii [Tue, 29 Oct 2013 21:14:53 +0000 (06:14 +0900)]
Fix error message in read_password_packet().

11 years agoFix on_shmem_exit() to not accept too many on exit functions.
Tatsuo Ishii [Sun, 27 Oct 2013 22:58:06 +0000 (07:58 +0900)]
Fix on_shmem_exit() to not accept too many on exit functions.

Actually harmless because we currently do not such that many on exit
functions. But a bug is a bug...

Per Coverity report "1025973 Out-of-bounds write".

11 years agoFix memory leak in certain error case.
Tatsuo Ishii [Sat, 26 Oct 2013 10:00:17 +0000 (19:00 +0900)]
Fix memory leak in certain error case.

Per Coverity report "1111457 Resource leak".

11 years agoFix memory leak when do_query() fails.
Tatsuo Ishii [Sat, 26 Oct 2013 09:09:39 +0000 (18:09 +0900)]
Fix memory leak when do_query() fails.

Per Coverity report "1111444 Resource leak".

11 years agoFix data inconsistency problem with native replication mode + extended protocol case.
Tatsuo Ishii [Tue, 15 Oct 2013 02:27:45 +0000 (11:27 +0900)]
Fix data inconsistency problem with native replication mode + extended protocol case.

It is reported that concurrent INSERT using JDBC driver causes data
difference among database node. This only happens following conditions
are all met:

1) Native replication mode
2) Extended protocol used
3) The portal created by parse message is reused by bind message
4) autocommit is on
5) SERIAL (sequence) is used

Pgpool-II's parse message function knows it has to lock the target
table when INSERT (plus #5) is issued by clients. Unfortunately bind
message function did not know it. Once parse/bind/execute finishes,
pgpool releases the lock obtained by parse because of #4. JDBC wants
to reuse the portal and starts the cycle from bind message, which does
not obtain lock. As as result, lock-free INSERT are floating around
which causes data inconsistency of course.  The solution is, lock the
table in bind phase.

For this bind needs to issue LOCK in extended protocol. This was a
little bit hard because the module (do_command()) to issue internal
SQL command (other than SELECT) does not support extended protocol. To
solve the problem do_query() is modified so that it accepts other than
SELECT because it already accepts extended protocol. The modification
is minimum and is only tested for the case called from insert_lock(). I
do not recommend to replace every occurrence of do_command() with
do_query() at this point.

BTW the reason why the bug is not reported is, most users uses JDBC
with auto commit = off. In this case, the lock obtained by parse
persists until user explicitly issues commit or rollback.

Per bug report by Steve Kuekes in [pgpool-general: 2142].

11 years agoAvoid calling find_primary_node_repeatedly() when standby node goes down.
Tatsuo Ishii [Mon, 7 Oct 2013 01:33:36 +0000 (10:33 +0900)]
Avoid calling find_primary_node_repeatedly() when standby node goes down.

This will reduce the time to failover. Per bug #75, patch modified by
Tatsuo Ishii.

11 years agoModify descriptions about restrictions of parallel mode
Yugo Nagata [Thu, 3 Oct 2013 03:35:54 +0000 (12:35 +0900)]
Modify descriptions about restrictions of parallel mode

Muliple rows INSERT using VALUES are not supported in parallel mode.

12 years agoFix segfault when pgpool.conf does not set log_standby_delay.
Tatsuo Ishii [Wed, 25 Sep 2013 14:14:03 +0000 (23:14 +0900)]
Fix segfault when pgpool.conf does not set log_standby_delay.

This is caused by wrong initialization for log_standby_delay in
pool_config.l. Per bug#74.

12 years agoRemove -lcompat because it confuses FreeBSD per bug#15.
Tatsuo Ishii [Fri, 13 Sep 2013 09:21:17 +0000 (18:21 +0900)]
Remove -lcompat because it confuses FreeBSD per bug#15.

12 years agoReplace pg_config by $(PG_CONFIG) in Makefiles so it can be overridden at build time...
Tatsuo Ishii [Thu, 12 Sep 2013 12:30:17 +0000 (21:30 +0900)]
Replace pg_config by $(PG_CONFIG) in Makefiles so it can be overridden at build time when compiling for different PG major versions.

Patch contributed by Christoph Berg ([pgpool-general: 2127]).

12 years agoFix incorrect time stamp rewriting in replication mode for certain time zones.
Tatsuo Ishii [Wed, 11 Sep 2013 14:21:51 +0000 (23:21 +0900)]
Fix incorrect time stamp rewriting in replication mode for certain time zones.

Time stamp rewriting calls "SELECT now()" to get current
time. Unfortunately the buffer for the current time is too small for
certain time zones such as "02:30". Note that non-30-minutes-time-zone
such as "0900" does not reveal the problem. This explains why we
haven't the bug report until today. Bug reported in [pgpool-general:
2113] and fix provided by Sean Hogan.

12 years agoPrepare 3.1.9 V3_1_9
Yugo Nagata [Fri, 6 Sep 2013 09:18:44 +0000 (18:18 +0900)]
Prepare 3.1.9

12 years agoPrepare 3.1.9
Yugo Nagata [Fri, 6 Sep 2013 06:45:13 +0000 (15:45 +0900)]
Prepare 3.1.9

12 years agoFix a typo of the japanese document
Yugo Nagata [Wed, 14 Aug 2013 08:13:33 +0000 (17:13 +0900)]
Fix a typo of the japanese document

12 years agoFix bug in parsing prepared statements with transaction handling in replication mode...
Tatsuo Ishii [Mon, 29 Jul 2013 14:52:41 +0000 (23:52 +0900)]
Fix bug in parsing prepared statements with transaction handling in replication mode reported in [pgpool-general: 1877].

Parse() automatically starts a transaction for non SELEC query to keep
consistency among nodes in replication mode. But it does not set
allow_close_transaction variable. If wrong query comes in, the
transaction goes into an abort state but pgpool does not close the
transaction. Thus next query causes error because the transaction is
still in abort status.

12 years agoFix mistake in ssh command.
Tatsuo Ishii [Thu, 25 Jul 2013 01:00:27 +0000 (10:00 +0900)]
Fix mistake in ssh command.

12 years agoPrepare 3.1.8 V3_1_8
Yugo Nagata [Wed, 10 Jul 2013 04:33:47 +0000 (13:33 +0900)]
Prepare 3.1.8

12 years agoFix to verify the backend node number in pcp_recovery_node
Yugo Nagata [Mon, 8 Jul 2013 01:23:25 +0000 (10:23 +0900)]
Fix to verify the backend node number in pcp_recovery_node

When an invalid number is used, null value is passed as an arguments
of recovery script, and this causes a malfunction. In especially,
rsync may delete unrelated files in basebackup scripts.

12 years agoAdd ssl_ca_cert and ssl_ca_cert_dir descriptions to the japanese document
Yugo Nagata [Fri, 5 Jul 2013 06:11:46 +0000 (15:11 +0900)]
Add ssl_ca_cert and ssl_ca_cert_dir descriptions to the japanese document

12 years agoMove ssl_ca_cert and ssl_ca_cert_dir descriptions to the SSL section
Yugo Nagata [Thu, 4 Jul 2013 04:15:06 +0000 (13:15 +0900)]
Move ssl_ca_cert and ssl_ca_cert_dir descriptions to the SSL section

12 years agoMerge branch 'V3_1_STABLE' of ssh://git.postgresql.org/pgpool2 into V3_1_STABLE
Yugo Nagata [Tue, 2 Jul 2013 03:04:02 +0000 (12:04 +0900)]
Merge branch 'V3_1_STABLE' of ssh://git.postgresql.org/pgpool2 into V3_1_STABLE

12 years agoFix segmentation fault of child that occurs when startup packet has
Yugo Nagata [Tue, 2 Jul 2013 02:12:20 +0000 (11:12 +0900)]
Fix segmentation fault of child that occurs when startup packet has
no PostgreSQL user information.

When a startup packet has no PostgreSQL user specified, pgpool-II
terminated abnormally. You can reproduce it by

 $ psql -p 9999 -U ''

If enable_pool_hba is on, a child process terminates by segmentation
fault. Otherwise if enable_pool_hba is off, the error message is

 ERROR: pool_discard_cp: cannot get connection pool for user (null) database (null)

In both cases, psql terminates with no message on frontend.

To resolve it, if PostgreSQL user is not specified in startup packet,
the message as following is output to both log and frontend. This is
the same behavior as PostgreSQL.

 FATAL: no PostgreSQL user name specified in startup packet

12 years agoFix pg_md5 command crash.
Tatsuo Ishii [Sat, 29 Jun 2013 09:21:33 +0000 (18:21 +0900)]
Fix pg_md5 command crash.

Fix contributed by Muhammad Usama(from [pgpool-hackers: 302])

While looking at the pgpool-II code I found a potential crash or stack
smash in pg_md5 utility.
The problem is update_pool_passwd() calls pg_md5_encrypt() function to get
the md5 password, and the password format generated by pg_md5_encrypt()
function is
"md5" followed by 32-hex digits, which sums up to 35 characters while the
host variable defined in update_pool_passwd() function to hold this
password can contain maximum 32 characters.

12 years agoRegister pgpool_regclass in pg_catalog schema. This is necessary to
Tatsuo Ishii [Tue, 25 Jun 2013 05:56:34 +0000 (14:56 +0900)]
Register pgpool_regclass in pg_catalog schema.  This is necessary to
deal with clients which restricts schema search path to pg_catalog
only. Postgres_fdw is such a client.

12 years agoUpdate copyright year.
Tatsuo Ishii [Mon, 10 Jun 2013 04:57:54 +0000 (13:57 +0900)]
Update copyright year.

12 years agoFix bug with do_query which causes hung in extended protocol.
Tatsuo Ishii [Thu, 30 May 2013 05:49:05 +0000 (14:49 +0900)]
Fix bug with do_query which causes hung in extended protocol.

When insert lock is enabled and pgpool_catalog.insert_lock exists,
pgpool-II looks for the row which matches the oid of the target
table. If non, pgpool-II will insert the row to obtain a row lock.
The bug was in the process looking for the row. If extended protocol
is used, pgpool-II was waiting for the row data forever which will
never come because there's no such a row in the table. The fix is when
"command complete" received, let pgpool-II regards as if "data row"
received. The bug was introduced when 3.2.1 was released. A
reproducable test case is provided by Karsten Düsterloh.  See
[pgpool-general: 1684] for more details.

12 years agoFix unnecessary degeneration caused by error on commit.
Tatsuo Ishii [Sun, 2 Jun 2013 11:17:23 +0000 (20:17 +0900)]
Fix unnecessary degeneration caused by error on commit.

A commit could fail by certain condition including deferred
triggers. If the trigger is related to DML, only the primary fails
because standbys never gets executed such DML in streaming replication
mode. This lead to "kind mismatch error", which causes failover or
session close. This is reported in bug #60, and the reporter claims
that it should not trigger the failover or the session close, rather
continue the session and just report the error on the primary. I think
his complain is fair since in replication mode, such error does not
cause failover or session close. So I make read_kind_from_backend() a
little smarter to not cause failover or session close if only primary
fails on commit in streaming replication mode.

12 years agoFix do_query() not to hang when PostgreSQL returns an error.
Tatsuo Ishii [Thu, 16 May 2013 04:08:01 +0000 (13:08 +0900)]
Fix do_query() not to hang when PostgreSQL returns an error.

The typical symptom is "I see SELECT is keep on running according to
pg_stat_activity".  To fix this pgpool-II just exits the process and
kill the existig connection.  This is not gentle but at this point I
believe this is the best solution. Here is an excerpt from source
code:
/*
 * This is fatal. Because: If we operate extended
 * query, backend would not accept subsequent commands
 * until "sync" message issued. However, if sync
 * message issued, unnamed statement/unnamed portal
 * will disappear and will cause lots of problems.  If
 * we do not operate extended query, ongoing
 * transaction is aborted, and subsequent query would
 * not accepted.  In summary there's no transparent
 * way for frontend to handle error case. The only way
 * is closing this session.
 */

12 years agoComment out backend1 data. This should have been done before since
Tatsuo Ishii [Tue, 14 May 2013 00:47:53 +0000 (09:47 +0900)]
Comment out backend1 data. This should have been done before since
pgpool.conf.sample has already done this.

12 years agoFix description on SSL.
Tatsuo Ishii [Sat, 11 May 2013 09:12:33 +0000 (18:12 +0900)]
Fix description on SSL.

12 years agoFix %H in trigger_failover() to assign new primary node.
Tatsuo Ishii [Wed, 8 May 2013 08:56:53 +0000 (17:56 +0900)]
Fix %H in trigger_failover() to assign new primary node.

Before it assigns the result of get_next_master_node(), which is not
correct in streaming replication mode, which is not necessarily same
as the primary node id. This causes problem in follow_master_command.
Please note that %m(new master node) properly uses passed new
master(or primary) node id. See [pgpool-hackers: 219] for more
details.

12 years agoConsider timeout waiting for compeletion of failback request in on line recovery.
Tatsuo Ishii [Wed, 8 May 2013 02:33:11 +0000 (11:33 +0900)]
Consider timeout waiting for compeletion of failback request in on line recovery.

This will prevent the recovery operation continues forever and we
cannot even shutdown pgpool main process. This could happen especially
while executing follow master command. At this moment, the timeout is
fixed value(5 seconds). This should be enough for the operation since
it does not imply any I/O or DB operation. Before it waited
forever. Problem is, it is possible that right after failover, the
failback request sent can be lost. In the long run we should fix it
but at this moment I prefer to band aid the problem because the fix
will not be trivial.

12 years agoAdd mention about "-D" option.
Tatsuo Ishii [Wed, 8 May 2013 00:24:22 +0000 (09:24 +0900)]
Add mention about "-D" option.

12 years agoPrepare 3.1.7. V3_1_7
Yugo Nagata [Fri, 26 Apr 2013 05:50:12 +0000 (14:50 +0900)]
Prepare 3.1.7.

12 years agoPrepare 3.1.7
Yugo Nagata [Fri, 26 Apr 2013 03:17:46 +0000 (12:17 +0900)]
Prepare 3.1.7

12 years agoPrepare 3.1.7.
Yugo Nagata [Fri, 26 Apr 2013 03:12:27 +0000 (12:12 +0900)]
Prepare 3.1.7.

12 years agoPrepare 3.1.7.
Yugo Nagata [Fri, 26 Apr 2013 02:52:00 +0000 (11:52 +0900)]
Prepare 3.1.7.