Revert "Fix pgpool child process segfault when ALWAYS_MASTER is on."
authorTatsuo Ishii <ishii@postgresql.org>
Mon, 26 Feb 2018 08:01:50 +0000 (17:01 +0900)
committerTatsuo Ishii <ishii@postgresql.org>
Mon, 26 Feb 2018 08:01:50 +0000 (17:01 +0900)
This reverts commit 9022ff842fb5dbbe06e2f2f4cf38fadf47b592da.

With the commit, write queries are always sent to node 0 even if the
primary node is not 0 because PRIMARY_NODE_ID macro returns
REAL_MASTER_NODE_ID, which is usually 0. Thus write queries are failed
with:
ERROR:  cannot execute INSERT in a read-only transaction

src/include/pool.h

index 16d03a475c622508da2a9d7000eb2c1fa01a2b75..48cd82909a1faa8952b9cf786a36478b888f2abb 100644 (file)
@@ -333,7 +333,7 @@ extern int my_master_node_id;
  * mode or there's no primary node, this macro returns
  * REAL_MASTER_NODE_ID.
  */
-#define PRIMARY_NODE_ID (Req_info->primary_node_id >=0 && VALID_BACKEND(Req_info->primary_node_id) ? \
+#define PRIMARY_NODE_ID (Req_info->primary_node_id >=0?\
                                                 Req_info->primary_node_id:REAL_MASTER_NODE_ID)
 #define IS_PRIMARY_NODE_ID(node_id)    (node_id == PRIMARY_NODE_ID)