pgpool2.git
6 years agoRemove .sgml file to not used.
Takuma Hoshiai [Wed, 24 Apr 2019 02:32:50 +0000 (11:32 +0900)]
Remove .sgml file to not used.

basic-config-example.sgml written by English exists doc.ja directory only,
and don't used document.

6 years agoAvoid exit/fork storm of pool_worker_child process.
Tatsuo Ishii [Sun, 21 Apr 2019 06:57:22 +0000 (15:57 +0900)]
Avoid exit/fork storm of pool_worker_child process.

pool_worker_child issues query to get WAL position using do_query(),
which could throws FATAL error. In this case pool_worker_child process
exits and Pgpool-II parent immediately forks new process. This cycle
indefinitely repeats and gives high load to the system.

This could easily happen. For example if ALWAYS_MASTER flag is
mistakenly set to standby node, it will cause an error:

ERROR:  recovery is in progress
HINT:  WAL control functions cannot be executed during recovery.
STATEMENT:  SELECT pg_current_wal_lsn()

To avoid the exit/fork storm, sleep sr_check_period.

6 years agoFix black_function_list's broken default value.
Tatsuo Ishii [Wed, 17 Apr 2019 22:52:56 +0000 (07:52 +0900)]
Fix black_function_list's broken default value.

I accidentally broke the entry of pgpool.conf.sample when
database_redirect_preference_list and
app_name_redirect_preference_list were introduced.

Also fix mistake of the entry of pgpool.conf.sample-replication as
well.

Issue reported by Sebastiaan Alexander Mannem.

6 years agoFix "not enough space in buffer" error.
Tatsuo Ishii [Wed, 17 Apr 2019 13:11:00 +0000 (22:11 +0900)]
Fix "not enough space in buffer" error.

The error occurred while processing error message returned from
backend and the cause is that the query string in question is too
big. Problem is, the buffer is in fixed size (8192 bytes). From the
programming point of view there's absolutely no need to use fixed size
buffer. So eliminate the fixed size buffer and use palloced buffer
instead. This also saves some memory copy work.

Per bug 499.

6 years agoFix DROP DATABASE failure.
Tatsuo Ishii [Tue, 16 Apr 2019 06:48:44 +0000 (15:48 +0900)]
Fix DROP DATABASE failure.

When DROP DATABASE gets executed, SIGUSR1 is sent to the Pgpool-II
child process being issuing the command. In its SIGUSR1 handler,
MASTER macro is called while closing all idle connections. The MACRO
checks whether we are in failover process surely we are. As a result,
the process exits and DROP DATABASE command never been issued.

Per bug 486. However the reason of segfault in the report is not
clear.  After commit:
https://git.postgresql.org/gitweb/?p=pgpool2.git;a=commit;h=66b5aacfcc045ec1485921a5884b637fcfb6fd73

Things could be different. Let the user test the latest version in the
git repo and see if the problem is solved...

6 years agoDoc: fix typo.
Tatsuo Ishii [Thu, 11 Apr 2019 08:32:19 +0000 (17:32 +0900)]
Doc: fix typo.

6 years agoDoc: add restriction entry
Takuma Hoshiai [Wed, 10 Apr 2019 07:04:22 +0000 (16:04 +0900)]
Doc: add restriction entry

master branch's commit(ea1998b7350de6882bea25fc3634c4f7673adbde) backport to 3.6-4.0.

6 years agoFix to compare wrong variable, when old pgpool_status file read.
Takuma Hoshiai [Wed, 10 Apr 2019 02:55:45 +0000 (11:55 +0900)]
Fix to compare wrong variable, when old pgpool_status file read.

Pgpool-II 3.4 or later, pgpool_status format changed, and format both old and new is supported.
Pgpool might read status in file incorrectly, when old format is reading by Pgpool.

This is rare case, and noproblem if it is happend.

6 years agoDoc: add description about multi-statement queries to restrictions section.
Tatsuo Ishii [Tue, 9 Apr 2019 05:17:57 +0000 (14:17 +0900)]
Doc: add description about multi-statement queries to restrictions section.

6 years agoAdd test/watchdog_setup to EXTRA_DIST.
Bo Peng [Sun, 7 Apr 2019 15:01:50 +0000 (00:01 +0900)]
Add test/watchdog_setup to EXTRA_DIST.
See bug470: https://www.pgpool.net/mantisbt/view.php?id=470

6 years agoDoc: mention that multi-statement queries are sent to primary node only.
Tatsuo Ishii [Sun, 7 Apr 2019 00:42:31 +0000 (09:42 +0900)]
Doc: mention that multi-statement queries are sent to primary node only.

Even if the multi-statement query includes SET command, they should be
sent to primary node only. This is not explicitly mentioned nowhere
in the doc.

Per bug 492.

6 years agoFix occasional regression test failure of 014.watchdog_test_quorum_bypass.
Tatsuo Ishii [Wed, 3 Apr 2019 03:04:58 +0000 (12:04 +0900)]
Fix occasional regression test failure of 014.watchdog_test_quorum_bypass.

The test script does not retry psql while failover happens and
failed. So replace psql with wait_for_pgpool_startup.

6 years agoAbort session if failover/failback is ongoing.
Tatsuo Ishii [Tue, 2 Apr 2019 03:56:01 +0000 (12:56 +0900)]
Abort session if failover/failback is ongoing.

If failover/failback is ongoing, there would be a risk that MASTER
node macro cannot be used. If used, it could raise a segfault because
connection to the master node is NULL or bogus.

There are several reports suspected to be caused by this (see bug 481,
482 for example).

Now the guts of the MASTER* macro (pool_virtual_master_db_node_id())
is modified to check Req_info->switching which is true while
failover/failback is ongoing. If true, emit warning message and exit
the process. There's still a small window I know, but this should
greatly reduce the chance to access bogus MASTER connection without
using any locking.

6 years agoGenerate Makefile.in by automake 1.13.4.
Bo Peng [Tue, 2 Apr 2019 00:21:44 +0000 (09:21 +0900)]
Generate Makefile.in by automake 1.13.4.

6 years agoSuppress useless truncation warnings from gcc 8+.
Tatsuo Ishii [Sat, 30 Mar 2019 12:56:03 +0000 (21:56 +0900)]
Suppress useless truncation warnings from gcc 8+.

For this purpose update c-compiler.m4 (borrowed from PostgreSQL's
config/c-compiler.m4) and add PGAC_PROG_CC_VAR_OPT(NOT_THE_CFLAGS,
[-Wformat-truncation]) to configure.ac to generate -Wformat-truncation
compiler option.

6 years agoSuppress "ar: `u' modifier ignored since `D' is the default (see `U')".
Tatsuo Ishii [Sat, 30 Mar 2019 13:34:45 +0000 (22:34 +0900)]
Suppress "ar: `u' modifier ignored since `D' is the default (see `U')".

This is actually a bug with libtools. To deal with this, add ARFLAGS
to parser's Makefile.am.

6 years agoSuppress compiler warnings.
Tatsuo Ishii [Sat, 30 Mar 2019 12:29:41 +0000 (21:29 +0900)]
Suppress compiler warnings.

Suppress compiler warnings regarding write(2) returns values being
ignored.  Since they are used in signal handlers, it's impossible to
print info about errors. To shut up the warnings, create a static
variable and assign the return values from write().

6 years agoFix wrong usage of volatile declaration.
Tatsuo Ishii [Sat, 30 Mar 2019 01:33:58 +0000 (10:33 +0900)]
Fix wrong usage of volatile declaration.

From a PostgreSQL commit message:
     Variables used after a longjmp() need to be declared volatile.  In
     case of a pointer, it's the pointer itself that needs to be declared
     volatile, not the pointed-to value.

Same thing can be said to:
     volatile StartupPacket *sp;

This should have been:
     StartupPacket *volatile sp;

This also suppresses a compiler warning.

6 years agoFix memory leak in "batch" mode in extended query.
Tatsuo Ishii [Thu, 28 Mar 2019 04:58:27 +0000 (13:58 +0900)]
Fix memory leak in "batch" mode in extended query.

In "batch" mode, not for every execute message, a sync message is
followed.  Unfortunately Pgpool-II only discard memory of query
context for the last execute message while processing the ready for
query message. For example if 3 execute messages are sent before the
sync message, 2 of query context memory will not be freed and this
leads to serious memory leak.

To fix the problem, now the query context memory is possibly discarded
when a command complete message is returned from backend if the query
context is not referenced either by sent messages or pending messages.
If it is not referenced at all, we can discard the query context.

Also even if it is referenced, it is ok to discard the query context
if it is either an unnamed statement or an unnamed portal because it
will be discarded anyway when next unnamed statement or portal is
created.

Per bug 468.

6 years agoChange pgpool.spec. V3_7_9 V3_7_9_RPM
Bo Peng [Thu, 28 Mar 2019 11:56:35 +0000 (20:56 +0900)]
Change pgpool.spec.

6 years agoUpdate pgpool_socket_dir.patch file.
Bo Peng [Thu, 28 Mar 2019 11:29:36 +0000 (20:29 +0900)]
Update pgpool_socket_dir.patch file.

6 years agoPrepare 3.7.9.
Bo Peng [Thu, 28 Mar 2019 09:30:54 +0000 (18:30 +0900)]
Prepare 3.7.9.

6 years agoDoc: Update docs version.
Bo Peng [Thu, 28 Mar 2019 09:24:32 +0000 (18:24 +0900)]
Doc: Update docs version.

6 years agoDoc: Add release-notes 4.0.4-3.4.23.
Bo Peng [Thu, 28 Mar 2019 09:18:10 +0000 (18:18 +0900)]
Doc: Add release-notes 4.0.4-3.4.23.

Conflicts:
doc.ja/src/sgml/release-4.0.sgml
doc/src/sgml/release-4.0.sgml

6 years agoDoc: add ssl_prefer_server_ciphers paramter to Japanese doc.
Tatsuo Ishii [Wed, 27 Mar 2019 10:16:49 +0000 (19:16 +0900)]
Doc: add ssl_prefer_server_ciphers paramter to Japanese doc.

6 years agoAdd new configuration option ssl_prefer_server_ciphers
Muhammad Usama [Wed, 27 Mar 2019 07:51:20 +0000 (12:51 +0500)]
Add new configuration option ssl_prefer_server_ciphers

Add the new setting "ssl_prefer_server_ciphers" to let users configure if they
want client's or server's cipher order to take preference.

6 years agoSpecify default value of ssl_ciphers
Yugo Nagata [Wed, 27 Mar 2019 01:08:32 +0000 (10:08 +0900)]
Specify default value of ssl_ciphers

6 years agoAllow to set a client cipher list.
Tatsuo Ishii [Sat, 23 Mar 2019 04:04:21 +0000 (13:04 +0900)]
Allow to set a client cipher list.

For this purpose new parameter "ssl_ciphers" is added. This is already
implemented in PostgreSQL and useful to enhance security when SSL is
enabled.

6 years agoFix unnecessary fsync to pgpool_status file.
Tatsuo Ishii [Mon, 18 Mar 2019 00:45:51 +0000 (09:45 +0900)]
Fix unnecessary fsync to pgpool_status file.

Whenever new connections are created to PostgreSQL backend, fsync()
was issued to pgpool_status file, which could generate excessive I/O
in certain conditions, for example num_init_children is large and
connections to backend have certain life time limit.

So reduce the chance of issuing fsync() so that it is issued only when
backend status is changed from CON_CONNECT_WAIT or others to CON_UP.
If the status is already CON_UP, we don't need to write to
pgpool_status.

Discussion: [pgpool-general: 6436] High I/O Usage on PGPool nodes

6 years agoAdd "tags" to gitignore file.
Bo Peng [Thu, 14 Mar 2019 05:21:59 +0000 (14:21 +0900)]
Add "tags" to gitignore file.

6 years agoFix some mistakes from previous commit.
Bo Peng [Thu, 7 Mar 2019 02:26:17 +0000 (11:26 +0900)]
Fix some mistakes from previous commit.

6 years agoFix indent of pgpool.conf sample files.
Bo Peng [Thu, 7 Mar 2019 01:27:31 +0000 (10:27 +0900)]
Fix indent of pgpool.conf sample files.

6 years agoFix write_status_file()'s signature.
Tatsuo Ishii [Wed, 27 Feb 2019 00:38:15 +0000 (09:38 +0900)]
Fix write_status_file()'s signature.

It was mistakenly declared as write_status_file(). Of course this
should be: write_status_file(void).

6 years agoPrepare 3.7.8. V3_7_8 V3_7_8_RPM
Bo Peng [Thu, 21 Feb 2019 01:01:05 +0000 (10:01 +0900)]
Prepare 3.7.8.

6 years agodoc: update doc version.
Bo Peng [Wed, 20 Feb 2019 11:04:56 +0000 (20:04 +0900)]
doc: update doc version.

6 years agoAdd release-notes 3.7.8-3.4.22.
Bo Peng [Wed, 20 Feb 2019 10:55:21 +0000 (19:55 +0900)]
Add release-notes 3.7.8-3.4.22.

6 years agoFix regression test 068
Takuma Hoshiai [Fri, 15 Feb 2019 07:22:06 +0000 (16:22 +0900)]
Fix regression test 068
It was not working correctly, because a function of old jdbc and some fixed variable were used by this test case.

6 years agoFix configuration change timing regarding memory_cache_enabled.
Tatsuo Ishii [Fri, 15 Feb 2019 05:26:55 +0000 (14:26 +0900)]
Fix configuration change timing regarding memory_cache_enabled.

This parameter must not be changed after Pgpool-II start but it was
possible to change by reloading.

6 years agoFix unwanted recovery timeout in certain cases.
Tatsuo Ishii [Tue, 12 Feb 2019 07:59:35 +0000 (16:59 +0900)]
Fix unwanted recovery timeout in certain cases.

In the second stage of online recovery in replication mode, it is
possible it fails with timeout (message: "wait_connection_closed:
existing connections did not close in %d sec.") if connection counter
is malformed by a child process aborts with SIGKILL, SEGFAULT or etc.
This could be detected by checking if client_idle_limit_in_recovery is
enabled and it has less value than recovery_timeout because all
clients must be kicked out by the time when
client_idle_limit_in_recovery is expired. If so, we should reset
conn_counter to 0 also.

Per bug 431.

6 years agoFix merge conflict in previous commit.
Tatsuo Ishii [Tue, 5 Feb 2019 22:32:19 +0000 (07:32 +0900)]
Fix merge conflict in previous commit.

6 years agoReduce memory usage when large data set is returned from backend.
Tatsuo Ishii [Tue, 5 Feb 2019 11:59:38 +0000 (20:59 +0900)]
Reduce memory usage when large data set is returned from backend.

In commit 8640abfc41ff06b1e6d31315239292f4d3d4191d,
pool_wait_till_ready_for_query() was introduced to retrieve all
messages into buffer from backend until it found a "ready for query"
message when extended query protocol is used in streaming replication
mode. It could hit memory allocation limit of palloc(), which is 1GB.

This could be easily reproduced by using pgbench and pgproto for
example.

    pgbench -s 100

    pgproto data:
    'P'     ""      "SELECT * FROM pgbench_accounts"        0
    'B'     ""      ""      0       0       0
    'E'     ""      0
    'S'
    'Y'

To reduce the memory usage, introduce "suspend_reading_from_frontend"
flag in session context so that Pgpool-II does not read any message
after sync message is received. The flag is turned off when a "ready
for query" message is received from backend. Between this, Pgpool-II
reads messages from backend and forward to frontend as usual. This way
we could eliminate the necessity to store messages from backend in
buffer, thus it reduces the memory foot print.

Per bug 462.

6 years agoFix syntax error in extended query test script.
Tatsuo Ishii [Tue, 5 Feb 2019 09:51:40 +0000 (18:51 +0900)]
Fix syntax error in extended query test script.

Checking "Some process remains" needed double quotes around
a variable.

6 years agoFix corner case bug with strip_quote().
Tatsuo Ishii [Tue, 29 Jan 2019 08:20:41 +0000 (17:20 +0900)]
Fix corner case bug with strip_quote().

strip_quote(), which is called by pattern_compare() did not properly
handle empty query string case. In the worst case it could wipe out
memory after a pointer returned from malloc(), which could cause a
segmentation fault in free() called in pattern_compare().

Per bug 458.

6 years agoMention that schema qualifications cannot be used in white/black_function_list.
Tatsuo Ishii [Sun, 27 Jan 2019 02:03:14 +0000 (11:03 +0900)]
Mention that schema qualifications cannot be used in white/black_function_list.

6 years agoFix typo about wd_priority in watchdog_setup.
Takuma Hoshiai [Wed, 23 Jan 2019 00:28:43 +0000 (09:28 +0900)]
Fix typo about wd_priority in watchdog_setup.

6 years agoFix Pgpool child segfault in a race condition.
Tatsuo Ishii [Thu, 10 Jan 2019 03:20:07 +0000 (12:20 +0900)]
Fix Pgpool child segfault in a race condition.

1) frontend tries to connect to Pgpool-II

2) there's no existing connection cache

3) try to create new backend connections by calling connect_backend()

4) inside connect_backend(), pool_create_cp() gets called

5) pool_create_cp() calls new_connection()

6) failover occurs and the global backend status is set to down, but
   the pgpool main does not send kill signal to the child process yet

7) inside new_connection() after checking VALID_BACKEND, it checks the
   global backend status and finds it is set to down status, so that
   it returns without creating new connection slot

8) connect_backend() continues and accesses the down connection slot
   because local status says it's alive, which results in a segfault.

Since there's already checking for the global status in
new_connection(), a fix could be syncing the local status with the
global status there.

See [pgpool-hackers: 3214] for discussion.

6 years agoDoc: fix typo in logdir description.
Tatsuo Ishii [Thu, 3 Jan 2019 08:30:04 +0000 (17:30 +0900)]
Doc: fix typo in logdir description.

Per bug 453.

6 years agoFix occasional extended query hang.
Tatsuo Ishii [Tue, 11 Dec 2018 22:42:31 +0000 (07:42 +0900)]
Fix occasional extended query hang.

If a client sends a extended query message such as close after sync
message but before next simple query, Pgpool-II could hang.

:
<= BE ParseComplete
<= BE BindComplete
<= BE CommandComplete(COMMIT)
<= BE ReadyForQuery(I)
FE=> Close(stmt="S2")
FE=> Close(stmt="S1")
FE=> Query (query="BEGIN") [0]
<= BE CloseComplete [1]
<= BE CloseComplete [1]
<= BE CommandComplete(BEGIN) [2]

Because of [1], query in progress flag was reset, then [2] hangs
trying to read from backend which did not receive message from
Pgpool-II because it does not refer to the query context set by [0].

Sending close after sync is not recommended according to the official
document but some sloppy drivers seem to do it. To deal with the
problem, check the doing extended query message flag before resetting
the query in progress flag.

Problem reported by Muhammad Usama.
Discussion: https://www.pgpool.net/pipermail/pgpool-hackers/2018-December/003164.html

6 years agoDeal with "terminating connection due to idle-in-transaction timeout" error.
Tatsuo Ishii [Thu, 6 Dec 2018 08:20:32 +0000 (17:20 +0900)]
Deal with "terminating connection due to idle-in-transaction timeout" error.

If idle_in_transaction_session_timeout parameter is set to reasonably
short in postgresql.conf, the fatal error easily occurs and the
connection from Pgpool-II to backend is terminated. This leads to
Pgpool-II either hang (if only one of PostgreSQL equips equips the
parameter) or unwanted failover (if all PostgreSQL equips with the
parameter), and both are not good. So intercept the message and send
the same message to frontend then exit to terminate the connection to
frontend. This is similar treatment as the error "connection was
terminated due to conflict with recovery, User was holding a relation
lock for too long."

Per bug 448.

6 years agodoc: Fix Japanese document typo in pcp_common_options.
Bo Peng [Wed, 5 Dec 2018 05:55:55 +0000 (14:55 +0900)]
doc: Fix Japanese document typo in pcp_common_options.

6 years agoPrepare 3.7.7. V3_7_7 V3_7_7_RPM
Bo Peng [Wed, 21 Nov 2018 08:44:33 +0000 (17:44 +0900)]
Prepare 3.7.7.

6 years agoChange sort algorism buble sort to quick sort.
Takuma Hoshiai [Wed, 21 Nov 2018 08:32:38 +0000 (17:32 +0900)]
Change sort algorism buble sort to quick sort.

This is used to sort startup packet's parameters.

6 years agoAdd release notes.
Bo Peng [Wed, 21 Nov 2018 08:22:23 +0000 (17:22 +0900)]
Add release notes.

6 years agoFix to sort startup packet's parameters sent by client.
Takuma Hoshiai [Wed, 21 Nov 2018 02:45:17 +0000 (11:45 +0900)]
Fix to sort startup packet's parameters sent by client.

If order of startup packet's  parameters differ between cached connection pools and connection request, did't use connection pool ,and created new connection pool.
Per bug 444.

6 years agoFix memory leak found by Coverity,
Tatsuo Ishii [Thu, 15 Nov 2018 00:21:30 +0000 (09:21 +0900)]
Fix memory leak found by Coverity,

This is actually harmless since in the situation pgpool child process
exits and the leaked memory is gone anyway.  I just want to shut off
Coverity's complain.

6 years agoFix segmentation fault occurs when a certain Bind message is sent in native replicati...
Bo Peng [Tue, 13 Nov 2018 01:52:57 +0000 (10:52 +0900)]
Fix segmentation fault occurs when a certain Bind message is sent in native replication mode.

If the number of parameter format codes is specified to one, but the number of the original query's
parameter is zero, bind_rewrite_timestamp() will call memcpy with a negative value for size_t.
This causes segmentation fault.

Patch is provided by Yugo Nagata.
Per bug 443.

6 years agoFix a query passed to relcache so that it uses schema qualified table name.
Tatsuo Ishii [Thu, 8 Nov 2018 05:37:18 +0000 (14:37 +0900)]
Fix a query passed to relcache so that it uses schema qualified table name.

This should have been done for all similar queries to follow PostgreSQL's schema usage pattern.
However there was one missed at that time.

6 years agoFix query cache invalidation bug.
Tatsuo Ishii [Mon, 5 Nov 2018 12:43:01 +0000 (21:43 +0900)]
Fix query cache invalidation bug.

When a DML is executed in an explicit transaction, the table oid
buffer is wiped out by pool_reset_memqcache_buffer() and query cache
is not invalidated at the commit time because there's no DML oid
exists to invalidate query cache any more. To fix this, add new bool
parameter to pool_reset_memqcache_buffer() to specify whether to reset
table oid buffer or not. When a DML is executed in an explicit
transaction, call pool_reset_memqcache_buffer(false) to preserve the
table oid buffer.

Issue reported at https://github.com/pgpool/pgpool2/issues/19.

6 years agoFix segfault in extended query + query cache case.
Tatsuo Ishii [Sat, 3 Nov 2018 13:07:31 +0000 (22:07 +0900)]
Fix segfault in extended query + query cache case.

If extended query is used when query cache enabled, Pgpool-II could
crash in certain case.

- parse before bind fires.

- a bind message is sent with previously parsed named statement and
  unnamed portal.

- an explicit transaction is used.

When parse before bind fires, a new sent message corresponding to the
re-parsed message was not created.

When a bind message is sent from frontend using previously parsed
message and unnamed portal, Pgpool-II tries to add the unnamed portal
to the sent message list by calling
pool_add_sent_message(). pool_add_sent_message() removes the old
unnamed portal and add the new unnamed portal. Also it tries to remove
corresponding query context if it's not used by 2 or more sent
messages. Usually a query context is used by a named statement and an
unnamed portal and the query context will not moved.

However because when parse before bind fires a new sent message
corresponding to the re-parsed message was not created, the reference
count is 1, which cause the query context gets removed.

When the transaction ends, temporary buffer for query cache needed to
be removed. Unfortunately since the pointer to the temporary buffer
for query cache is stored in the query context which was just removed,
the pointer to the buffer points to a random address, and segfault
occurs.

Because of the the reason if query cache is not enabled, the segfalt
does not occurs.

Note that this bug is easily reproduced by using "pgbench -M
prepared".  ("pgbench -M extended" does not trigger the bug because it
does not use named statements.)

Fix is, When parse before bind fires, add a new sent message
corresponding to the re-parsed message.

6 years agoFix memory leak in extended query + query cache enabled.
Tatsuo Ishii [Thu, 1 Nov 2018 00:22:46 +0000 (09:22 +0900)]
Fix memory leak in extended query + query cache enabled.

If a bind message is sent again to an existing prepared statement, it
is possible that the previously allocated bind parameter string
remains and newly allocated bind parameter string's pointer is set to
there, which leads to a memory leak.

Note that if a statement is parsed again in usual way, the parameter
string will be freed along with the old query context. So the leak
does not happen.

I suspect the use case for the memory leak (bind, execute is repeated
against a same prepared statement) is actually rare in the
field. Probably that's why the problem has not been reported until
today although the leak had existed since day 0.

The leak case can be easily reproduced by "pgbench -M prepared" by the
way.

6 years agoChange pgpool.spec. V3_7_6 V3_7_6_RPM
Bo Peng [Wed, 31 Oct 2018 04:40:41 +0000 (13:40 +0900)]
Change pgpool.spec.

6 years agoChange spec file to include pgpool_recovery--1.0.sql and pgpool_recovery--1.0--1...
Bo Peng [Wed, 31 Oct 2018 03:39:34 +0000 (12:39 +0900)]
Change spec file to include pgpool_recovery--1.0.sql and pgpool_recovery--1.0--1.1.sql.

6 years agoAdd pgpool_recovery--1.0.sql and pgpool_recovery--1.0--1.1.sql to tar ball.
Bo Peng [Wed, 31 Oct 2018 03:11:40 +0000 (12:11 +0900)]
Add pgpool_recovery--1.0.sql and pgpool_recovery--1.0--1.1.sql to tar ball.

6 years agoPrepare 3.7.6.
Bo Peng [Wed, 31 Oct 2018 02:13:07 +0000 (11:13 +0900)]
Prepare 3.7.6.

6 years agodoc: change release notes.
Bo Peng [Wed, 31 Oct 2018 01:11:46 +0000 (10:11 +0900)]
doc: change release notes.

6 years agoAllow PCP[attach/detach/promote] commands during failover.
Muhammad Usama [Tue, 30 Oct 2018 11:35:10 +0000 (16:35 +0500)]
Allow PCP[attach/detach/promote] commands during failover.

We have made the Pgpool-II to handle the multiple failover/failback/promote
node requests by adding the request queue a long time ago. But somehow we were
still not accepting the pcp_[attach/detach/promote] requests during the failover.

This commit removes this unwanted restriction and allow queuing of node operation
requests from PCP client during the failover.

6 years agodoc: Add release-note.
Bo Peng [Tue, 30 Oct 2018 01:32:37 +0000 (10:32 +0900)]
doc: Add release-note.

6 years agoFix typo in child_max_connections description.
Tatsuo Ishii [Thu, 25 Oct 2018 10:58:34 +0000 (19:58 +0900)]
Fix typo in child_max_connections description.

Patch provided by Phil Ramirez.

6 years agoFix segmentation fault, when client send sync message in native replication mode.
Takuma Hoshiai [Mon, 22 Oct 2018 08:24:18 +0000 (17:24 +0900)]
Fix segmentation fault, when client send sync message in native replication mode.

When the query to be executed does not exist, if client sent 'Sync' messages to Pgpool-II which in native replication mode, occurred segmentation fault.

See:
https://www.pgpool.net/mantisbt/view.php?id=434
for more details.

6 years agoFix syntax error in native replication, when queries including now() etc. and "IN...
Bo Peng [Thu, 18 Oct 2018 09:12:24 +0000 (18:12 +0900)]
Fix syntax error in native replication, when queries including now() etc. and "IN (SELECT ...)" in WHERE clause.

In native replication, queries including now() etc. are rewritten to a timestamp constant value.
However, Pgpool-II didn't support queries including now() etc. and "IN (SELECT ...)" in WHERE clause.

Per bug433.

6 years ago Change pgpool.spec file to install extension to server which supports LLVM JIT.
Bo Peng [Thu, 18 Oct 2018 08:51:13 +0000 (17:51 +0900)]
 Change pgpool.spec file to install extension to server which supports LLVM JIT.

6 years agoFix occasional less data returned to frontend.
Tatsuo Ishii [Fri, 12 Oct 2018 04:52:57 +0000 (13:52 +0900)]
Fix occasional less data returned to frontend.

While piggy-packing queries to system catalog data,
pool_push_pending_data() is responsible for pushing response from
backend. To judge whether pending data remains or not, it checks
socket fd of backend and dummy close message response (close
complete). Problem is, if the socket is not ready and accidentally
actual (non dummy) close message response is returned,
pool_push_pending_data() believes that there's no pending data any
more. As a result, some of pending data is not recovered after
returning to normal process.

The idea for fix is, use pending message data list. It records
messages from frontend, and it is expected that we will receive same
number of messages (or more -- e.g. execute message). So we can use
the data to make above judgment more robust for the case described
above.

Initial patch is created by Yugo Nagata. Fix to the patch for certain
cases by me.

See:
https://www.pgpool.net/mantisbt/view.php?id=432
for more details.

6 years agoFix memory leak when query cache enabled in streaming replication mode + extended...
Tatsuo Ishii [Thu, 11 Oct 2018 08:52:57 +0000 (17:52 +0900)]
Fix memory leak when query cache enabled in streaming replication mode + extended query case.

If BEGIN is executed in extended protocol, allocated temp buffer for
the command never discarded.  This is because in streaming replication
mode + extended query case, when handle_query_cache gets called at the
command complete timing, the reference counter to query context is not
0, which in turn prevents from calling
pool_discard_temp_query_cache().

In reality, we don't need to care about the query context here, so
let's proceed in streaming replication mode + extended query case.

Note that the memory leak case can be easily reproduced by "pgbench -M
extended" command (standard TPC-B).

6 years agodoc: add note to online recovery doc.
Tatsuo Ishii [Wed, 10 Oct 2018 04:05:39 +0000 (13:05 +0900)]
doc: add note to online recovery doc.

This warns that client_idle_limit_in_recovery must be smaller than
recovery_timeout.

6 years agoFix memory leak pointed out by Coverity.
Tatsuo Ishii [Tue, 9 Oct 2018 08:37:25 +0000 (17:37 +0900)]
Fix memory leak pointed out by Coverity.

6 years agoFix memory leak in trigger_failover_command.
Tatsuo Ishii [Tue, 9 Oct 2018 04:49:49 +0000 (13:49 +0900)]
Fix memory leak in trigger_failover_command.

Pointed out by Coverity.

6 years agoFix memory leak when memory_cache_enabled = on and write SQLs are sent.
Bo Peng [Tue, 9 Oct 2018 00:22:31 +0000 (09:22 +0900)]
Fix memory leak when memory_cache_enabled = on and write SQLs are sent.

In a explicit transaction, we the SELECT results are cached in temporary buffer.
If a write SQL is sent which modifies the table, the temporary buffe should be reset.

6 years agoFix occasional failure in regression 065.bug152.
Tatsuo Ishii [Mon, 8 Oct 2018 22:50:03 +0000 (07:50 +0900)]
Fix occasional failure in regression 065.bug152.

In the test first create a table with some data, then query
it. However sometimes it seems replication delay causes the table
still not ready in standby. Since there's no reason we need to a
standby or slave for this particular test, let the test have only
primary/master.

7 years agoFix to add execution permission.
Tatsuo Ishii [Mon, 24 Sep 2018 07:25:06 +0000 (16:25 +0900)]
Fix to add execution permission.

The regression 071 script lacked execution permission.

7 years agoAdd EXECUTE/DEALLOCATE regression test.
Bo Peng [Fri, 21 Sep 2018 08:32:30 +0000 (17:32 +0900)]
Add EXECUTE/DEALLOCATE regression test.

Patch created by Takuma Hoshiai.

7 years agoAdd missing pgpool_recovery--1.0--1.1.sql file to update pgpool_recovery() function...
Bo Peng [Wed, 19 Sep 2018 00:25:31 +0000 (09:25 +0900)]
Add missing pgpool_recovery--1.0--1.1.sql file to update pgpool_recovery() function version to 1.1.

7 years agoFix kind mismatch error when DEALLOCATE statement is issued.
Bo Peng [Thu, 13 Sep 2018 08:30:58 +0000 (17:30 +0900)]
Fix kind mismatch error when DEALLOCATE statement is issued.

PREPARE should be add to pool_add_sent_message, so that EXECUTE and DEALLOCATE
can be sent to the same node as PREPARE.

See [pgpool-general: 6226] for more details.

7 years agoAdd regression test for SSL connection.
Tatsuo Ishii [Wed, 29 Aug 2018 02:58:36 +0000 (11:58 +0900)]
Add regression test for SSL connection.

This tests SSL connection between frontend <--> Pgpool-II and
Pgpool-II <--> backend.

7 years agoDo not update pgpool_passwd if the password length is incorrect.
Tatsuo Ishii [Mon, 27 Aug 2018 06:16:17 +0000 (15:16 +0900)]
Do not update pgpool_passwd if the password length is incorrect.

For Pgpool-II 3.7 or before, the password stored in pool_passwd is MD5
password only.  So check the correctness of pool_passwd by scanning
entire file.

Patch created by Takuma Hoshiai. Minor error message tweak by me.
See bug425 for more details.

7 years agoUpdate copyright year.
Tatsuo Ishii [Wed, 22 Aug 2018 07:09:19 +0000 (16:09 +0900)]
Update copyright year.

7 years agoAdd notes regarding failover script.
Tatsuo Ishii [Wed, 22 Aug 2018 07:01:21 +0000 (16:01 +0900)]
Add notes regarding failover script.

It's not recommended to access against Pgpool-II itself from
failover/failback scripts.

7 years agoAdd .gitignore to doc and doc.ja.
Bo Peng [Mon, 20 Aug 2018 04:49:44 +0000 (13:49 +0900)]
Add .gitignore to doc and doc.ja.

7 years agoChange follow_master_command description new master -> new primary.
Bo Peng [Mon, 20 Aug 2018 05:13:29 +0000 (14:13 +0900)]
Change follow_master_command description new master -> new primary.

7 years agoMerge branch 'V3_7_STABLE' of ssh://git.postgresql.org/pgpool2 into V3_7_STABLE
Tatsuo Ishii [Fri, 17 Aug 2018 03:12:36 +0000 (12:12 +0900)]
Merge branch 'V3_7_STABLE' of ssh://git.postgresql.org/pgpool2 into V3_7_STABLE

7 years agoFix test directory name typos.
Bo Peng [Fri, 17 Aug 2018 03:06:38 +0000 (12:06 +0900)]
Fix test directory name typos.

7 years agoFix too small buffer size in some configuration file process.
Tatsuo Ishii [Thu, 16 Aug 2018 06:38:33 +0000 (15:38 +0900)]
Fix too small buffer size in some configuration file process.

This was found by newer version of gcc warnings.

pool_config_variables.c: In function ‘BackendFlagsShowFunc’:
pool_config_variables.c:3809:57: warning: ‘__builtin_snprintf’ output truncated before the last format character [-Wformat-truncation=]
   snprintf(buffer, sizeof(buffer), "DISALLOW_TO_FAILOVER");
                                                         ^
In file included from /usr/include/stdio.h:862:0,
                 from pool_config_variables.c:1:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:64:10: note: ‘__builtin_snprintf’ output 21 bytes into a destination of size 20
   return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        __bos (__s), __fmt, __va_arg_pack ());
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

7 years agoImprove pg_md5 docs and error message.
Bo Peng [Tue, 14 Aug 2018 13:43:49 +0000 (22:43 +0900)]
Improve pg_md5 docs and error message.

Patch provided by Jesper Pedersen and modified by me.

7 years agoRemove some .gitignore files which doesn't belong this branch.
Bo Peng [Sat, 11 Aug 2018 00:06:59 +0000 (09:06 +0900)]
Remove some .gitignore files which doesn't belong this branch.

7 years agoAdd definition of PGLIB in regress.sh.
Bo Peng [Fri, 10 Aug 2018 04:16:02 +0000 (13:16 +0900)]
Add definition of PGLIB in regress.sh.
Patch provided by Jesper Pedersen.

7 years agoUpdate clean.sh which clean up regression test results.
Bo Peng [Fri, 10 Aug 2018 03:40:10 +0000 (12:40 +0900)]
Update clean.sh which clean up regression test results.

Patch provided by Jesper Pedersen.

7 years agoAdd .gitignore files.
Bo Peng [Fri, 10 Aug 2018 03:34:32 +0000 (12:34 +0900)]
Add .gitignore files.

Patch provided by Jesper Pedersen.

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

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

Fix is as follows.

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

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

7 years agoFix typos in documents and scripts.
Tatsuo Ishii [Fri, 3 Aug 2018 02:09:30 +0000 (11:09 +0900)]
Fix typos in documents and scripts.

Patch contributed by Jesper Pedersen.

7 years agoFix document mistakes of "recovery_1st_stage_command" and "recovery_2nd_stage_command".
Bo Peng [Wed, 1 Aug 2018 00:39:36 +0000 (09:39 +0900)]
Fix document mistakes of "recovery_1st_stage_command" and "recovery_2nd_stage_command".

7 years agoPrepare 3.7.5. V3_7_5 V3_7_5_RPM
Bo Peng [Tue, 31 Jul 2018 00:09:51 +0000 (09:09 +0900)]
Prepare 3.7.5.