Tatsuo Ishii [Tue, 29 Aug 2017 06:28:35 +0000 (15:28 +0900)]
Fix ancient bug of stream write modules.
- Fix bug with pool_write_noerror() when requested length exceeds
remaining write buffer size. This could lead to a buffer overrun
problem, which has not been reported in the field as far as I know
though.
- When write buffer is full, pool_flush_it() is called, which could
write data to socket in the middle of message. I found this by using
following pgproto data. To fix the problem directly write requested
data if the write buffer is going to be full.
'P' "" "SELECT * FROM pgbench_accounts LIMIT 100" 0
'B' "" "" 0 0 0
'E' "" 0
'S'
'Y'
'X'
- Enhance performance of pool_unread(). When retrieving large number
of rows in streaming replication and extended query, pool_unread is
very slow because it needs to memmove large number of bytes in the
read buffer. This happens in read_kind_from_backend() since it uses
pool_unread() to check 'A' packet. To optimize the situation, modify
pool_unread(). If there's enough room in front of cp->po, copies the
data there to avoid memmove.
Muhammad Usama [Thu, 24 Aug 2017 18:21:46 +0000 (23:21 +0500)]
Some miscellanies small fixes in regression test scripts
Yugo Nagata [Thu, 24 Aug 2017 09:31:44 +0000 (18:31 +0900)]
Fix documentation about load-balancing
pengbo [Mon, 21 Aug 2017 03:52:07 +0000 (12:52 +0900)]
Change Makefile to copy figure files to tarball.
pengbo [Mon, 21 Aug 2017 01:37:39 +0000 (10:37 +0900)]
Add figures for document.
pengbo [Mon, 21 Aug 2017 01:35:29 +0000 (10:35 +0900)]
Add new document of "Pgpoo-II + Watchdog Setup Example".
Tatsuo Ishii [Thu, 17 Aug 2017 08:26:20 +0000 (17:26 +0900)]
Update pgpool_setup manual.
Logical replication mode is supported.
Tatsuo Ishii [Thu, 17 Aug 2017 07:10:24 +0000 (16:10 +0900)]
Fist cut patch to deal with logical replication.
Tatsuo Ishii [Wed, 16 Aug 2017 05:54:44 +0000 (14:54 +0900)]
Fix infinite loop while resetting connection.
If there was an error, bogus sent_message is registered and it causes
an infinite loop because removing the bogus list does not work in the
current implementation. Solution is, not to register bogus sent
message in the error case.
Tatsuo Ishii [Wed, 16 Aug 2017 04:40:46 +0000 (13:40 +0900)]
Fix core dump and mishandling of temp tables.
Fix two issues:
1) Protect pool_remove_sent_message() and pool_get_sent_message()
against null parameters.
2) Fix bug while determining if the created table is temporary or not.
Tatsuo Ishii [Tue, 15 Aug 2017 23:13:58 +0000 (08:13 +0900)]
Fix failing "make dist".
doc.ja/src/Makefile seemed to be broken.
Tatsuo Ishii [Tue, 15 Aug 2017 01:25:35 +0000 (10:25 +0900)]
Fix ancient bug of pool_unread.
When realloc() is called in pool_unread(), it did not update the
buffer size. This could cause variety of memory corruption and
unexpected data reading from backend. The reason why we did not found
that is, probably recently Pgpool-II starts extensively to use
pool_unread().
Tatsuo Ishii [Sun, 13 Aug 2017 07:16:02 +0000 (16:16 +0900)]
Fix handling of empty queries.
When empty query (empty string or all comment query) is sent, command
complete message was returned to frontend. This is not correct. An
empty query response should be returned to frontend.
Per bug328.
Tatsuo Ishii [Wed, 9 Aug 2017 07:23:57 +0000 (16:23 +0900)]
Fix query cache bug with streaming replication mode and extended query case.
- Commit cache upon receiving a command complete message, rather than
upon receiving a "ready for query" message, except in an explicit
transaction. Doing it upon the receiving ready for query message had
serious problem with streaming replication mode and extended query
case, because it is possible that multiple selects get executed
before the ready for query message arrives. The older way cannot
handle it because it only looked at the last command before the
ready for query message.
- When query cache hits, do not forward cached messages to frontend in
Execute(). Instead "inject" cached messages into the backend
buffer. This is better than older way since it respects the pending
messages and necessary treatment while receiving messages including
parse complete and bind complete. Note that now the cached messages
are returned only after a flush or a sync message sent. Before they
are returned immediately while executing execute message. The newer
behavior more resembles to the ordinary messages (no cached message).
To avoid adding cache by the injected messages twice,
"skip_cache_commit" flags is introduced in query context. The flag
is set to true in Execute() if the injection
happens. handle_query_cache() checks the flag and skips registering
query results to the query cache if the flag is true. The flags is
set to false if cache is not hit.
- Introduce new function pool_at_command_success() which were the code
fragments in ReadyForQuery() to take care misc treatments including
unsettling writing transaction flags in CommandComplete() as
well. Also ReadyForQuery() now calls it.
- Fix memory leak. If a close request is not issued (this is typically
the case when unnamed statements/portals used), temp cache buffer
remains until the session end (at the session end, the memory for
the buffer will be freed because they are in the session context
memory. Thus only long running sessions hit the bug). Before we
prepared new buffer when query cache committed. Now do not create
new buffer there. Rather create a buffer when memqcache_register
gets called if the temp buffer is not allocated yet.
Tatsuo Ishii [Thu, 3 Aug 2017 08:03:12 +0000 (17:03 +0900)]
Fix memory leak with streaming replication mode/extended query case.
When Close Complete message arrives, Pgpool-II did not remove sent
message because at this point the pending message, which includes info
to remove the sent message, has been already removed by
read_kind_from_backend(). To fix the problem read_kind_from_backend()
does not remove the pending message for Close Complete and let
CloseComplete() to extract and remove the pending message to remove
the sent message data.
Per bug#324.
Tatsuo Ishii [Thu, 3 Aug 2017 03:41:40 +0000 (12:41 +0900)]
Fix Java program in 005.regression test.
The program forgot issue commit and always ended up with ABORT. This
does not affect the test result itself, it would be better to finish
the test with commit, rather than ABORT.
Tatsuo Ishii [Thu, 3 Aug 2017 02:52:24 +0000 (11:52 +0900)]
Fix bug #303.
When failover is triggered by worker process, it is possible that
wrong DB node could failover. This is due to the db_node_id member in
the POLL_CONNECTION structure is not initialized in the process (in
child process the member is properly initialized). To solve the
problem, add new function pool_set_db_node_id() to set the structure
member variable and call it inside
make_persistent_db_connection(). For this purpose also the new
parameter "db_node_id" is added to make_persistent_db_connection and
friends.
Tatsuo Ishii [Mon, 31 Jul 2017 08:29:27 +0000 (17:29 +0900)]
Fix starting unnecessary transaction when SET command is issued.
In streaming replication mode, there's no point to start internal
transaction when SET command is issued. The existing behavior is
harmless but waste of CPU cycle.
Tatsuo Ishii [Fri, 28 Jul 2017 08:24:13 +0000 (17:24 +0900)]
Fix bug with memory leak tests and add new memory leak test.
They did not correctly detect the memory leak.
Also add new memory leak test for extended query/query cache.
Tatsuo Ishii [Wed, 26 Jul 2017 23:00:32 +0000 (08:00 +0900)]
Fix Pgpool-II hung up bug or other errors in error case in extended query in replication mode.
In extended query in streaming replication mode, responses supposed to
be returned from backend is managed by the pending messages. However,
if an error response returned from backend, the sequence of returned
message from backend is not what we expect. The mismatch was partially
solved in the code but it turned out they were not sufficient.
The cause of hung is basically when an error response is received from
backend before frontend sends 'S' (sync) message. If backend detects
errors while doing extended query, it does not return any response
until it receives sync message. Of course at this point frontend is
expected to send sync message to Pgpool-II, but it may not reach to
the socket of Pgpool-II. So it is possible that Pgpool-II does not
notice the sync message is coming, and does not forward the sync
message to backend. As a result, nothing goes on and Pgpool-II is
stuck. To fix the problem following modifications are made in this
commit:
- When error response is received from backend, after forwarding the
error response to frontend, remove all pending messages and backend
message buffer data except POOL_SYNC pending message and ready for
query (before we removed all messages including ready for query,
which is apparently wrong). If sync message is not received yet,
call ProcessFrontendResponse() to read data from frontend. This
ensures eliminating the expectation of receiving messages from backend
in normal cases, and receiving the sync message from frontend.
- When 'S' (sync) message is received from frontend, forward it to
backends and wait till "ready for query" message is received from
the backends. This ensures Pgpool-II to receive the read for query
message and goes into the proper sync point.
- It is still possible after receiving the ready for query message,
different messages arrived from each backend. If the numbers of
messages are same, "kind mismatch" error will occur. If the number
of messages are different, it is possible that Pgpool-II is stuck,
because read_kind_from_backend() will wait till a message coming
from backend. To fix this if either load balance node or primary
node returns 'Z' (ready for query), try to skip messages on the
other node. This is done in read_kind_from_backend(). See comments
around in line 3391 of pool_process_query.c for more details.
Other fixes in this commit.
- Do not send intended error query to backend in streaming replication
mode in ErrorResponse3(). This is not necessary in streaming
replication mode.
- Fix pool_virtual_master_db_node_id() to return the
virtual_master_node_id only when query is in progress and query
context exists. Before in progress state was not checked and may
return bogus node id.
pengbo [Wed, 26 Jul 2017 00:31:30 +0000 (09:31 +0900)]
Fix document typo.
pengbo [Tue, 25 Jul 2017 07:51:49 +0000 (16:51 +0900)]
Add Pgpool-II + Watchdog configuration example.
pengbo [Tue, 25 Jul 2017 07:38:31 +0000 (16:38 +0900)]
Fix Pgpool-II document typo.
Yugo Nagata [Thu, 20 Jul 2017 05:55:31 +0000 (14:55 +0900)]
Allow make dist to include pgpool.service
Tatsuo Ishii [Thu, 13 Jul 2017 06:44:41 +0000 (15:44 +0900)]
Add log after health check retrying succeeds.
Previously only health check retry logs were produced. So it was not
clear if the retry succeeded or not in the end.
Tatsuo Ishii [Thu, 13 Jul 2017 05:26:18 +0000 (14:26 +0900)]
Add more settings to Aurora example.
Tatsuo Ishii [Thu, 13 Jul 2017 04:53:41 +0000 (13:53 +0900)]
Add neccessary setting for health check retry in the Aurora example.
Tatsuo Ishii [Wed, 12 Jul 2017 08:35:18 +0000 (17:35 +0900)]
Add Aurora setting documentation in Japanese.
Tatsuo Ishii [Wed, 12 Jul 2017 08:01:17 +0000 (17:01 +0900)]
Add Aurora setting example.
Tatsuo Ishii [Wed, 12 Jul 2017 07:20:30 +0000 (16:20 +0900)]
Add description about "ALWAYS_MASTER" flag.
Tatsuo Ishii [Wed, 12 Jul 2017 07:12:16 +0000 (16:12 +0900)]
Fix indentation.
Tatsuo Ishii [Wed, 12 Jul 2017 06:36:59 +0000 (15:36 +0900)]
Support AWS Aurora.
Add new backend flag "ALWAYS_MASTER" to control the primary node
detecting logic. Since we cannot use pg_is_in_recovery() in Aurora, we
assign the new flag to a backend which is specified as "writer" in
Aurora. Since Aurora always use the same hostname for the master (it's
called "writer"), find_primary_node() just returns the node id which
has ALWAYS_MASTER flag on.
Other than that, user can use the streaming replication mode with
Aurora. Notice that replication delay cannot be performed in Aurora,
sr_check_period should be always 0.
pengbo [Mon, 10 Jul 2017 07:19:07 +0000 (16:19 +0900)]
Add 3.6.5 - 3.2.21 release-notes.
Muhammad Usama [Thu, 6 Jul 2017 19:21:19 +0000 (00:21 +0500)]
Fix for [pgpool-hackers: 2400] Garbage output
Mostly the log messages fixes and few code cleanups.
Muhammad Usama [Thu, 29 Jun 2017 15:30:59 +0000 (20:30 +0500)]
Importing the latest changes in the MemoryManager API from PostgreSQL code.
Pgpool-II has borrowed the MemoryManager from PostgreSQL source and recently
there have been some performance updates made to the PostgreSQL's
memory manager, from which Pgpool-II can also benefit from.
This need was identified by the reporter of issue: "315: High CPU usage when
commiting large transactions and using in (shared) memory cache"
Muhammad Usama [Sat, 24 Jun 2017 18:04:52 +0000 (23:04 +0500)]
Fixing
0000306: Pgpool steals back MASTER status
This is next in the series of the patches, and hopefully the last one to fix
bug where the unworthy master node gets its way while the watchdog cluster
recovers from the split - brain syndrome. It's a relatively small patch that
makes a little tweak in the area which handles the split-brain when the
split-brain is detected by one of the standby node.
Muhammad Usama [Wed, 21 Jun 2017 12:54:04 +0000 (17:54 +0500)]
Fixing: [pgpool-hackers: 2390] Problems with the relative paths in daemon mode
Pgpool-II does all the path related calculations based on CWD
(current working directory) which only works as expected and intended
until the CWD does not change.
But in daemon mode the first thing Pgpool-II do after becoming the daemon
process is, it changes it's CWD to system root ("/") and after that all the
relative paths becomes invalid.
This means in daemon mode if the pgpool.conf file is specified as an argument
using the relative path, Pgpool-II will not be able to find the pool_passwd
or other required file whose location depends on the location of pgpool.conf
file, and will eventually fail to start, or even worst may read/write
some wrong file.
The solution to this is to convert the relative path of the pgpool.conf and
all file paths provided in the argument list to the Pgpool-II to the absolute
paths at the startup and later use those absolute paths for all path related
calculations.
Apart from using the absolute paths for pgpool.conf, pcp.conf and pool_hba.conf
files, The commit also modifies the behaviour of pid_file_name configuration
parameter, when the relative path is used for this config in pgpool.conf,
that relative path is considered with relative to the pgpool.conf path,
instead of the current working directory.
Tatsuo Ishii [Mon, 19 Jun 2017 07:40:06 +0000 (16:40 +0900)]
Adjust function name change in PostgreSQL 10 dev head.
pg_current_wal_location -> pg_current_wal_lsn
pg_last_wal_replay_location -> pg_last_wal_replay_lsn
Yugo Nagata [Fri, 9 Jun 2017 01:47:44 +0000 (10:47 +0900)]
Fix a posible hang with streaming replication and extended protocol
This hang occured under a certain condition. The following is an example.
- pgpool.conf is configured so that all read queries are sent to the standby.
- First, issue a writing query in a transaction block
- After commiting the transaction, issue a select query.
- When processing the query, send Describe (statement) message just after Parse.
Without using JDBC, we can reproduce the problem by pgproto with the followeing messages.
--------------------------------------------
'Q' "DROP TABLE IF EXISTS test_tbl"
'Y'
'Q' "CREATE TABLE test_tbl(i int)"
'Y'
'Q' "INSERT INTO test_tbl VALUES(1)"
'Y'
'P' "" "BEGIN" 0
'B' "" "" 0 0 0
'E' "" 0
'S'
'Y'
'P' "" "INSERT INTO test_tbl VALUES(1)" 0
'B' "" "" 0 0 0
'E' "" 0
'S'
'Y'
'P' "" "COMMIT" 0
'B' "" "" 0 0 0
'E' "" 0
'S'
'Y'
'P' "S_1" "SELECT * FROM test_tbl" 0
'D' 'S' "S_1"
'B' "C_1" "S_1" 0 0 0
'E' "C_1" 0
'S'
'Y'
'X'
---------------------------------------------
In practice, such Describe message can be sent by JDBC when executing PreparedStatement
with a parameter of timestamp type more than prepare_threshold times. In addition,
queries can be issued outside of a transaction block when autocommit is enabled.
When a writing query is issued in a transaction block, writing_transaction flag
is set, but after commiting the transaction this flag is not unset. The problem
is that parse_before_bind() is always called when writing_transaction is set.
Alhough Parse of the select and Describe following are sent to standby
due to load balancing, another Parse and Bind, Execute are to be sent to
primary due to parse_before_bind.
In this situation, Pgpool-II waits for the responces of Describe from
standby forever because any messages after Describe is not sent to the
standby and any responce is not returned.
To fix it, parse_before_bind() should be called only if we are in a transaction
block so that we can send Bind and Execute to the right backend.
Muhammad Usama [Wed, 7 Jun 2017 10:00:47 +0000 (15:00 +0500)]
Remove unnecessary log messages.
See [pgpool-hackers: 2378] Debug log
Tatsuo Ishii [Wed, 7 Jun 2017 08:27:54 +0000 (17:27 +0900)]
Fix Pgpool-II hang when used by erlang applications.
Erlang client sends "Describe" message followed by "Flush". So the
backend returns "Row description." However Pgpool-II forgets to reset
the query in progress flag upon receiving "Row description" message,
then Pgpool-II keeps on waiting for response from backend. This is the
cause of erlang client hanging.
Fix is, just reset the query in progress flag upon receiving "Row
description" message. Same thing can be said to "no data" message.
Discussion: [pgpool-general: 5555]
http://www.pgpool.net/pipermail/pgpool-general/2017-June/005613.html
Tatsuo Ishii [Wed, 7 Jun 2017 04:53:13 +0000 (13:53 +0900)]
Fix bug with sending bind message to wrong target node.
When a close portal message received, Pgpool-II forwards it to both
primary and load balance node in streaming replication mode. Later on
a close complete message returned from backend, and
read_kind_from_backend gets called, then it calls
pool_pending_message_query_context_dest_set, which rewrites
where_to_send map in the current query context accordingly. If a bind
message using the same query is received, it will be forwarded to both
primary and load balance node because the where_to_send map was
rewritten so. Unfortunately, the prepared statement might not exist on
primary node, if the query was parsed only on the load balance
node. So we get an error.
Fix is, restoring the where_to_send map after processing the close
complete message. For this sake, where_to_send map back up area is
added to session context. Also new flag need_to_restore_where_to_send
is added. Those new data is handled inside
pool_pending_message_query_context_dest_set. The where_to_send map is
restored in pool_unset_query_in_progress. There were several places
which do not call pool_unset_query_in_progress. They are also fixed to
call it.
Per bug #314.
https://www.pgpool.net/mantisbt/view.php?id=314
To reproduce the problem, following pgproto data can be used. Also you
need to set the weight parameter on primary to 0 and standby to 1 to reliably
reproduce the problem.
'P' "S_1" "SELECT 1" 0
'B' "C_1" "S_1" 0 0 0
'E' "C_1" 0
'S'
'Y'
'C' 'P' "C_1"
'B' "C_2" "S_1" 0 0 0
'E' "C_2" 0
'S'
'Y'
'X'
Tatsuo Ishii [Wed, 31 May 2017 07:14:46 +0000 (16:14 +0900)]
Allow to fork new health check process when it exits.
Tatsuo Ishii [Wed, 31 May 2017 06:50:54 +0000 (15:50 +0900)]
Add new group "health_check" to PGPOOL SHOW command doc.
Tatsuo Ishii [Wed, 31 May 2017 06:40:07 +0000 (15:40 +0900)]
Add description about per node health check parameters.
Tatsuo Ishii [Wed, 31 May 2017 05:58:51 +0000 (14:58 +0900)]
Fix descriptions of white/black_memcache_table_list.
They are far from actual implementations.
See [pgpool-general: 5479] for more details.
Tatsuo Ishii [Wed, 31 May 2017 01:15:42 +0000 (10:15 +0900)]
Fix query cache hang when used by node.js.
node.js sends a query in following pattern:
Parse
Bind
Describe
Execute
Flush
Sync
Notice the "Flush" message. This is unnecessary message and Pgpool-II
did not prepare for it. Since Pgpool-I supposed that next message to
Execute is "Sync" in pool_fetch_from_memory_cache(), it actually read
the "Flush" message and forwarded to backend, then discarded
subsequent "Ready for query" message, which was actually a "Sync"
message. That results in no "ready for query" message from backend.
Fix is, do not have any assumption regarding messages after Execute,
instead returns to the message processing loop. This way, whatever
messages coming after Execute should be properly processed.
Following is the test data for pgproto.
'Q' "DROP TABLE IF EXISTS pgproto_test1"
'Y'
'Q' "CREATE TABLE pgproto_test1(i INT)"
'Y'
'Q' "INSERT INTO pgproto_test1 VALUES(1)"
'Y'
'P' "S2" "SELECT 1 FROM pgproto_test1" 0
'B' "" "S2" 0 0 0
'D' 'S' "S2"
'E' "" 0
'H'
'C' 'S' "S2"
'S'
'Y'
'P' "S2" "SELECT 1 FROM pgproto_test1" 0
'B' "" "S2" 0 0 0
'D' 'S' "S2"
'E' "" 0
'H'
'C' 'S' "S2"
'S'
'Y'
'X'
Discussion: http://www.pgpool.net/pipermail/pgpool-general/2017-May/005569.html
Tatsuo Ishii [Sun, 28 May 2017 08:38:55 +0000 (17:38 +0900)]
Deal with PostgreSQL 10 in streaming replication delay checking.
From PostgreSQL 10 or later, some built in function names which are
used in streaming replication delay checking are changed. To deal with
this, get server_version_num from backend to change the calling
functions and cache them. Using 'S' message to extract the server
version string while connecting backend could be an idea, but
unfortunately connecting function used in streaming replication delay
checking does not handle 'S' parameter. Also converting from the
server version string to the server_version_num can be backend
dependent, so to extract the server_version_num would be safer.
Tatsuo Ishii [Sat, 27 May 2017 11:28:40 +0000 (20:28 +0900)]
Fix query cache memory leak.
Clearing cache buffers in case of no oid queries (like BEGIN,
CHECKPOINT, VACUUM, etc) should have been done, but it did not.
Patch from Dang Minh Huong.
Tatsuo Ishii [Tue, 23 May 2017 00:06:29 +0000 (09:06 +0900)]
Fix extended query hang in certain case.
While digging into "[pgpool-general: 5487] pgpool and erlang - request hangs",
http://www.pgpool.net/pipermail/pgpool-general/2017-May/005545.html
I found a certain sequence of messages which cause Pgpool-II hang.
errlang PostgreSQL API produces Parse ('P'), Describe ('D'), Flush
('H'), Bind ('B'), and Execute ('E'). Notice the 'H' message (this
does not happen in JDBC. I suspect that's the reason why this problem
is not popular before). After that, Pgpool-II dropped the extended
query mode, it failed to find which backend to read data. Thus
Pgpool-II simply tries to read all of backend which causes hang
because it may have not send a message to some of backends.
Solution is, after receiving the flush message set doing extended
query flag.
For the record, here is the pgproto data to reproduce the problem.
--------------------------------------------------------
'Q' "DROP TABLE IF EXISTS pgproto_test1"
'Y'
'Q' "CREATE TABLE pgproto_test1(i INT)"
'Y'
'Q' "INSERT INTO pgproto_test1 VALUES(1)"
'Y'
'P' "S2" "SELECT 1 FROM pgproto_test1" 0
'D' 'S' "S2"
'H'
'B' "" "S2" 0 0 0
'E' "" 0
'C' 'S' "S2"
'S'
'Y'
'X'
--------------------------------------------------------
Note that the cause of original complain seems to different from this
because it is operated in replication mode. So it needs more
investigation.
Back patched to 3.6 and 3.5 stable branches.
Muhammad Usama [Mon, 22 May 2017 19:53:14 +0000 (00:53 +0500)]
Fix for [pgpool-hackers: 2354] segfault with pg_md5
It was a stupid coding mistake.
Also fixing memory leak issues reported by valgrind in pg_md5 utility.
Tatsuo Ishii [Mon, 22 May 2017 02:59:38 +0000 (11:59 +0900)]
Fix debug print.
The debugging line after an if statement should be included in a curly
brance. Otherwise report wrong information.
Tatsuo Ishii [Fri, 19 May 2017 00:14:34 +0000 (09:14 +0900)]
Revert "Use volatile pointer for Req_info variable."
This reverts commit
a4de4bfc1421d787b53789eb62eb7e9cb26e91c1.
Tatsuo Ishii [Wed, 17 May 2017 08:35:43 +0000 (17:35 +0900)]
Fix descriptions of white/black_memcache_table_list.
They are far from actual implementations.
See [pgpool-general: 5479] for more details.
Tatsuo Ishii [Wed, 17 May 2017 07:07:33 +0000 (16:07 +0900)]
Fix indentation.
Muhammad Usama [Tue, 16 May 2017 18:45:13 +0000 (23:45 +0500)]
Allow to configure health check parameters for each individual node.
This is the next in series patch to implement an infrastructure to support
per-node health check parameters, and enables all health-check related parameter
to be configured for each individual backend nodes. With this commit If the
node-id postfix is used at the end of the health-check parameter name it will
configure the parameter value for specific node-id while the same name parameter
without the node-id can still be used and its value will serve as the default
global value for the individual node parameters where the value is
not explicitly provided.
For example if we have 3 backend nodes and do following configurations.
health_check_period = 10
health_check_period0 = 5
Then will set the health_check_period for node 0 to 5 while
node-id 1 and 2 will get the value 10
Tatsuo Ishii [Tue, 16 May 2017 10:59:56 +0000 (19:59 +0900)]
Use volatile pointer for Req_info variable.
Since Req_info points to shared memory area, using volatile pointer
will allow to fetch the fresh value.
pengbo [Thu, 11 May 2017 09:38:14 +0000 (18:38 +0900)]
Add 3.6.4, 3.5.8 release notes.
Muhammad Usama [Wed, 10 May 2017 16:09:44 +0000 (21:09 +0500)]
Fixing a few corner cases in the failover request handling of the watchdog.
Watchdog keeps track of the failover requests it receives from the local and
remote Pgpool-II nodes, propagate that request to the whole cluster and trigger
the failover on local Pgpool-II. And while that failover is in progress it keep
denying the requests for similar failover (same failover kind and same
backend node) until it receives the finish failover intimation for that
failover from Pgpool-II.
But if due to some reason the failover end command is not received by watchdog,
that failover in progress status gets stuck in forever and watchdog keep
rejecting the similar failover requests until it is restarted.
To solve the failover stuck problem this commit adds the timeout to the
failover requests on watchdog side and automatically marks the failover as
finished if it does not receive the end failover intimation within
the timeout period.
Apart from above there was another issue, The functions for sending the failover
request to Pgpool-II main process had void return type and returns no indication
if the request was successfully registered or not. So that fix is also part of
the commit and now they return boolean value indicating the
request registration status.
Muhammad Usama [Wed, 10 May 2017 14:33:04 +0000 (19:33 +0500)]
Tightening up the watchdog cluster membership criteria.
The watchdog node should only be considered as the part of the cluster either
if it is the Master node or if it is connected to that master node as a standby.
The nodes in the transient states (which are yet in the process of joining the
Mater node) or standby having the different master record should not be
considered the part of the watchdog cluster and should not be counted in the
quorum calculation.
Before this commit every node was considered as the part of the cluster as soon
as it becomes reachable to the master watchdog node, The problem with that
philosophy was, at the time of recovering from network partitioning/split-brain
situation both cluster leaders could have similar number of reachable
nodes and deciding the rightful master becomes difficult.
Tatsuo Ishii [Wed, 10 May 2017 07:49:20 +0000 (16:49 +0900)]
Enhance document for load balancing.
Also fix primary tag in indexterm tags in "SHOW" commands. They were
just "SHOW", which should have been more specific like "SHOW
POOL_NODES".
Tatsuo Ishii [Tue, 9 May 2017 23:30:17 +0000 (08:30 +0900)]
Fix corner case bug in Pgpool-II starting up.
It is possible that a failover request is accepted before primary node
is searched. This leads Pgpool-II to a strange state: there's no
primary node if the failed node was a primary node (even if new
primary node exists as a result of promotion of existing standby).
See [pgpool-hackers: 2321] for more details.
Tatsuo Ishii [Mon, 8 May 2017 08:14:51 +0000 (17:14 +0900)]
Add node 0 failover test.
Previously only node 1 failover test is performed in 003.failover.
Tatsuo Ishii [Thu, 4 May 2017 08:00:02 +0000 (17:00 +0900)]
Fix pgpool child process segfault reported in [pgpool-hackers: 2312].
When MASTER macro calls, pool_virtual_master_db_node_id() which calls
pool_get_preferred_master_node_id() if there's no query context
exists. The segfault happens in deciding the load balance node while
initializing the session context in the child process starting up. The
session context is first initialized with all 0, then
pool_get_preferred_master_node_id() returns 0 as the preferred node
id. This is fine as long as node 0 is healthy. However if node 0 goes
down and failover happens, this is not fine any more since the
connection slot 0 is empty and it causes the segfault.
Fix it by removing preferred_master_node_id staffs since it seems it
is not used anymore.
pengbo [Mon, 1 May 2017 00:37:31 +0000 (09:37 +0900)]
Fix compile error.
Tatsuo Ishii [Sun, 30 Apr 2017 08:04:00 +0000 (17:04 +0900)]
Enable AM_MAINTAINER_MODE.
This allows to automatically create bison/flex derived files. Should
be reverted once 3.7 beta released.
pengbo [Fri, 28 Apr 2017 06:25:58 +0000 (15:25 +0900)]
Add release notes.
pengbo [Thu, 27 Apr 2017 09:39:51 +0000 (18:39 +0900)]
Add 3.6.3 - 3.2.20 release note.
Tatsuo Ishii [Wed, 26 Apr 2017 00:27:35 +0000 (09:27 +0900)]
Add per node health check parameters and sample configurations.
This is just adding new data structure.
Tatsuo Ishii [Thu, 20 Apr 2017 00:36:46 +0000 (09:36 +0900)]
Implement infrastructure for supporting per node health check parameters.
Now pgpool main process forks health check process for each DB node.
Also autotools is now updated from 1.14 to 1.15.
TODO:
- Implement per node health check parameters.
Tatsuo Ishii [Tue, 18 Apr 2017 01:27:14 +0000 (10:27 +0900)]
Fix "show pool_cache" segfault when memcached is used.
The problem is reported in:
http://www.pgpool.net/mantisbt/view.php?id=301
pool_get_shmem_storage_stats() was mistakenly modified when 3.6 was
developed.
The bug was introduced in 3.6.0. Previous versions do not have the
problem.
Muhammad Usama [Fri, 14 Apr 2017 15:16:45 +0000 (20:16 +0500)]
Fix for some more code warnings.
uint64 definition was not uniform across the code.
Muhammad Usama [Fri, 14 Apr 2017 14:34:40 +0000 (19:34 +0500)]
Fixing some annoying compiler warnings.
Muhammad Usama [Fri, 14 Apr 2017 13:10:29 +0000 (18:10 +0500)]
Removing the function defined but not used warnings from pool_config_vatiable.c
Muhammad Usama [Fri, 14 Apr 2017 12:46:37 +0000 (17:46 +0500)]
Removing the references of obsolete debug_level configuration parameter.
configuration parameter 'debug_level' has given way to
'log_min_messages' after the adoption of exception manager.
Muhammad Usama [Wed, 12 Apr 2017 15:33:20 +0000 (20:33 +0500)]
Fixing a mistake in the watchdog code.
wrong conditional statement in the get_wd_command_from_reply() function was
making the watchdog to not reliably identify the internal command responses,
and in one case the completed watchdog internal command were not getting
cleaned up.
commit also adds some debug messages in the watchdog code.
Muhammad Usama [Wed, 12 Apr 2017 14:02:03 +0000 (19:02 +0500)]
Fix for
0000299: Errors on the reloading of configuration
Pgpool-II should load the hba_file after evaluating all the
command line options at startup.
It is wrong to load hba file before evaluating all the command line arguments,
because when the Pgpool-II is invoked with reload or stop options, all it needs
to do is to signal the running Pgpool-II and exit, So loading hba file for
Pgpool reload/stop is not only unnecessary but it also emits the misleading
WARNING message of "failed while loading hba configuration" when alternative
path for hba file was used.
Tatsuo Ishii [Wed, 12 Apr 2017 08:32:31 +0000 (17:32 +0900)]
Remove old html docs and related files.
Tatsuo Ishii [Wed, 12 Apr 2017 08:18:32 +0000 (17:18 +0900)]
Add pgpool_adm Japanese docs.
Also fix some pgpool_adm English docs.
Tatsuo Ishii [Tue, 11 Apr 2017 08:16:11 +0000 (17:16 +0900)]
Add installation procedure of pgpool_adm.
Tatsuo Ishii [Tue, 11 Apr 2017 08:01:17 +0000 (17:01 +0900)]
Add missing pgpool_adm manuals.
They were missing while migrating to SGML. Still Japanese docs need to
be updated.
Tatsuo Ishii [Tue, 11 Apr 2017 05:43:28 +0000 (14:43 +0900)]
Fix indentation.
Muhammad Usama [Mon, 10 Apr 2017 19:53:59 +0000 (00:53 +0500)]
Fix for
0000289: Inconsistent backend state
Pgpool-II syncs the backend node states at the time of startup which works fine
for almost all cases except when the watchdog cluster becomes partitioned
(because of some network problem) and after recovering from it the Pgpool-II
nodes (that are already up and serving) joins back the cluster. At that time the
backend node status among different nodes can become In-sync among the Pgpool-II
nodes, if the backend node status on the newly joined Pgpool-II is different
from the status on existing watchdog cluster nodes.
Now with this commit, every time the Pgpool-II node joins the watchdog cluster
as a standby either at startup or after some problem recovery, it realigns its
backend node statuses with the cluster leader, by fetching the statuses from
the master/coordinator and updating the local statuses of each backend.
The patch also borrows the logic of smart restarting of Pgpool-II children
from the failover() function to minimise the chances of session disconnection
when the backend node statuses are updated from the master/coordinator Pgpool-II.
Tatsuo Ishii [Fri, 7 Apr 2017 04:24:57 +0000 (13:24 +0900)]
Fix compiler warnings.
Also remove unused code.
Tatsuo Ishii [Thu, 6 Apr 2017 07:58:28 +0000 (16:58 +0900)]
Comment out unsupported Java method in new JDBC drivers to prevent regression failure.
That is this: Driver.setLogLevel(2);
Tatsuo Ishii [Wed, 5 Apr 2017 08:21:23 +0000 (17:21 +0900)]
Downgrade parse before bind log message to debug1.
This was mistakenly left at debugging. Patch provided by Sergey Kim.
Muhammad Usama [Tue, 4 Apr 2017 11:30:21 +0000 (16:30 +0500)]
Fix coverity warning CID#
1373258 "Uninitialized scalar variable"
Muhammad Usama [Tue, 4 Apr 2017 11:03:52 +0000 (16:03 +0500)]
Fix coverity reported issues of buffer overrun.
Per coverity CID#
1332216, CID#
1332218, CID#
1373253, CID#
1373254 and CID#
1373255
Tatsuo Ishii [Mon, 3 Apr 2017 05:57:25 +0000 (14:57 +0900)]
Fix coverity warnings.
Muhammad Usama [Fri, 31 Mar 2017 15:15:22 +0000 (20:15 +0500)]
Fix for [pgpool-general: 5396] pam ldap failure
Do not use Palloc and friends to allocate memory for pam_response in the
PAM conversation function, Since that memory is freed by PAM library who
knows nothing about our MemoryManager and can cause the segmentation fault.
Tatsuo Ishii [Fri, 31 Mar 2017 04:28:24 +0000 (13:28 +0900)]
Mention that SQL type commands cannot be used in extended query mode.
Tatsuo Ishii [Fri, 31 Mar 2017 03:49:59 +0000 (12:49 +0900)]
Consider SHOW command as kind of a read query.
In streaming replication mode, if SHOW is issued then subsequent
SELECTs are sent to the primary node in an explicit transaction. This
is not a reasonable and unnecessary limitation.
Also fix hang when parse command returns error.
Tatsuo Ishii [Thu, 30 Mar 2017 00:20:32 +0000 (09:20 +0900)]
Fix memory leak problem caused by commit
adcb636.
Commit
adcb636 introduces "pending message queue". When a message
arrives, the info is added to the queue and a copy of object is
created at the same time, but forgoto free the object. Fix is,
creating a new function pool_pending_message_free_pending_message()
and call it after pool_pending_message_add(),
pool_pending_message_get() and pool_pending_message_pull_out().
Problem reported by Sergey Kim.
Muhammad Usama [Wed, 29 Mar 2017 21:00:49 +0000 (02:00 +0500)]
Enhancing the handling of split-brain scenario by the watchdog.
Previously, the watchdog cluster was used to call for re-election of the
master/coordinator node whenever the split-brain situation was detected. And
consequently every node was required to rejoin the watchdog network, Which was
essentially similar to the re-booting of the whole watchdog cluster.
Although the technique of calling for re-election at split-brain is good enough
to tackle the situation, but it is very inefficient and prone to the service
disruption for the time when the cluster is rebooting. Also in some cases, like
when the split-brain happens because of temporary network partitioning the new
elections could elect master that has the outdated or invalid backend states.
Now with this enhancement when the cluster detects the split-brain, instead of
blindly calling for new master node election and rebooting every node,
The watchdog nodes try to solve the master/coordinator node contention by
choosing the best candidate.
The candidate for the master/coordinator node is selected on the following criteria.
1-- When two watchdog nodes are claiming to be the cluster master, the master
node that has performed the escalation keeps the master status and the other
node is asked to step down.
2-- If the conflict could not be resolved by the escalation status of the nodes,
The node which holds the quorum remains the master/coordinator.
3-- If the quorum status of both contenders is also same. The node with higher
number of connected alive nodes get the preference.
4-- Finally, if all above three yields no winner, the older master (The node
that has the coordinator status for longer duration) remains the master.
Tatsuo Ishii [Wed, 29 Mar 2017 06:27:19 +0000 (15:27 +0900)]
Mega patch to fix "kind mismatch" (or derived) errors in streaming replication mode.
The errors are caused by wrong prediction in which (or both) database
node will send response to Pgpool-II. Previous implementation using
"sync map" are weak and sometimes fail in the prediction.
This patch introduces new implementation using "pending message
queue", which records all sent message to backends. The element of the
queue stores info regarding messages types
(parse/bind/execute/describe/close/sync), to which database node the
message was sent and so on. It's a simple FIFO queue. When a message
arrives from backend, by looking at the head of the "pending message
queue", it is possible to reliably predict what kind of message and
from which database node it will arrive. After receiving the message,
the element is removed from the queue.
I would like to thank to Sergey Kim, who has been helping me in
testing series of patches.
See bug 271:
http://www.pgpool.net/mantisbt/view.php?id=271
and discussion in pgpool-hackers mailing list [pgpool-hackers: 2043]
and [pgpool-hackers: 2140] for more details.
Tatsuo Ishii [Wed, 29 Mar 2017 04:13:15 +0000 (13:13 +0900)]
Add new regression test "069.memory_leak_extended".
This is almost same as 060.memory_leak" but it uses extended query
protocol.
Muhammad Usama [Thu, 23 Mar 2017 21:17:36 +0000 (02:17 +0500)]
Fix for
0000296: PGPool v3.6.2 terminated by systemd because the service Type
has been set to 'forking'
Removing the "-n" value assigned to OPTS variable in pgpool.sysconfig.
The problem was the systemd service with Type=forking expects the parent process
to exit after the startup is complete, but because the -n command line option
disables the daemon mode and systemd keeps on waiting for the Pgpool-II's parent
process to exit after startup, which never happens and eventually systemd
terminate the Pgpool-II after timeout.
As part of this commit I have also added a new variable STOP_OPTS which is
passed to ExecStop and can be used to pass extra command line options to
Pgpool-II stop command.
Muhammad Usama [Mon, 20 Mar 2017 21:49:03 +0000 (02:49 +0500)]
Enhancing the watchdog internal command mechanism to handle
multiple concurrent commands.
pengbo [Fri, 17 Mar 2017 09:32:57 +0000 (18:32 +0900)]
Add release-notes 3.6.2-3.2.19.
Yugo Nagata [Thu, 9 Mar 2017 02:34:12 +0000 (11:34 +0900)]
Fix pcp_promote_node bug that fails promoting node 0
The master node could not be promoted by pcp_promote_node with
the following error;
FATAL: invalid pgpool mode for process recovery request
DETAIL: specified node is already primary node, can't promote node id 0
In streaming replication mode, there is a case that Pgpool-II
regards the status of primary node as "standby" for some reasons,
for example, when pg_ctl promote is executed manually during
Pgpool-II is running, in which case, it seems to Pgpool-II
that the primary node doesn't exist.
This status mismatch should be fixe by pcp_promote_node, but when the node
is the master node (the first alive node), it fails as mentioned above.
The reason is as following. before changing the status, pcp_promote_node
checks if the specified node is already primary or not by comparing the
node id with PRIMARY_NODE_ID. However, if the primary doesn't exist from
Pgpool-II's view, PRIMARY_NODE_ID is set to 0, which is same as MASTER_NODE_ID.
Hence, when the master node is specified to be promoted, pcp_promote_node
is confused that this node is already primary and doesn't have to be
promoted, and it exits with the error.
To fix this, pcp_promote_node should check the node id by using
REAL_PRIMARY_NODE_ID, which is set -1 when the primary doesn't exist,
rather than PRIMARY_NODE_ID.