Fix pgpool main process segfault when PostgreSQL 9.5. is used.
authorTatsuo Ishii <ishii@postgresql.org>
Thu, 24 May 2018 04:31:04 +0000 (13:31 +0900)
committerTatsuo Ishii <ishii@postgresql.org>
Thu, 24 May 2018 04:31:04 +0000 (13:31 +0900)
pgpool_setup -n 3 (or greater) triggers the bug. While recovering node
2, pgpool main process tried to retrieve version info from backend #2
even if it's not running. This causes the sefault because connection
was not established yet. The reason why PostgreSQL 9.6 or later was not
suffered from the bug was, PostgreSQL exited the loop as soon as the
server version is higher than 9.5. To fix this, call to VALID_BACKEND
macro was added.

src/main/pgpool_main.c

index 74508e1c164e3c9fee6ce5d01eeeec61881e0717..8074b938c91dfa4e5fb2ee328b44f6c1e7f27a54 100644 (file)
@@ -2962,6 +2962,9 @@ verify_backend_node_status(POOL_CONNECTION_POOL_SLOT **slots)
                 */
                for (i=0;i<NUM_BACKENDS;i++)
                {
+                       if (!VALID_BACKEND(i))
+                               continue;
+
                        if (get_server_version(slots, i) >= 90600)
                        {
                                check_connectivity = true;
@@ -2982,6 +2985,9 @@ verify_backend_node_status(POOL_CONNECTION_POOL_SLOT **slots)
                {
                        primary[i] = 0;
 
+                       if (!VALID_BACKEND(i))
+                               continue;
+
                        if (pool_node_status[i] == POOL_NODE_STATUS_PRIMARY)
                        {
                                ereport(DEBUG1,