[pgpool-committers: 3354] pgpool: Replace "MAJOR" macro to prevent occasional failure.

Tatsuo Ishii ishii at postgresql.org
Wed Jul 27 17:01:19 JST 2016

Replace "MAJOR" macro to prevent occasional failure.

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

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



Modified Files
src/context/pool_session_context.c                 | 46 ++++++++++++++++++++++
src/include/context/pool_session_context.h         |  9 +++++
src/include/pool.h                                 |  2 +-
src/protocol/child.c                               |  6 +++
src/rewrite/pool_timestamp.c                       |  4 +-
.../tests/010.rewrite_timestamp/timestamp/main.c   |  5 +++
6 files changed, 70 insertions(+), 2 deletions(-)

More information about the pgpool-committers mailing list