Fix occasional query hang while processing DEALLOCATE.
authorTatsuo Ishii <ishii@sraoss.co.jp>
Mon, 16 Sep 2019 00:24:08 +0000 (09:24 +0900)
committerTatsuo Ishii <ishii@sraoss.co.jp>
Mon, 16 Sep 2019 01:22:35 +0000 (10:22 +0900)
When DEALLOCATE tries to remove a named statement, it inherits
where_to_send map of the named statement in
where_to_send_deallocate(). However it forgot to copy the load balance
node id in the query context of the named statement. This made sending
query to backend not happen: if the target node id is different from
query_context->load_balance_node_id nor primary node id,
pool_virtual_master_db_node_id (it is called as MASTER_NODE_ID)
returns primary node id, and pool_send_and_wait(MASTER_NODE_ID)
ignores the request because VALID_BACKEND returns false in this case
(MASTER_NODE_ID = primary node id is not in the where_to_send map). As
a result, following check_error() waits for response from backend in
vain.

Fix is, let where_to_send_deallocate() copy load balance node id from
the query context of the previous named statement.

Per bug 546.

src/context/pool_query_context.c

index 1b0c1db78e33dd11665b11e39bac8be674b8dc62..b82e43870a2c79f6afd1ebb7a53a0cf20973683f 100644 (file)
@@ -1272,10 +1272,13 @@ void where_to_send_deallocate(POOL_QUERY_CONTEXT *query_context, Node *node)
                        /* Inherit same map from PREPARE or PARSE */
                        pool_copy_prep_where(msg->query_context->where_to_send,
                                                                 query_context->where_to_send);
-                       return;
+
+                       /* copy load balance node id as well */
+                       query_context->load_balance_node_id = msg->query_context->load_balance_node_id;
                }
-               /* prepared statement was not found */
-               pool_setall_node_to_be_sent(query_context);
+               else
+                       /* prepared statement was not found */
+                       pool_setall_node_to_be_sent(query_context);
        }
 }