Ensure that RemoteSubplan is marked parallel unsafe.
authorPavan Deolasee <[email protected]>
Tue, 21 Aug 2018 09:54:13 +0000 (15:24 +0530)
committerPavan Deolasee <[email protected]>
Tue, 21 Aug 2018 10:05:48 +0000 (15:35 +0530)
We can't support multiple backends running RemoteSubplan in parallel. So block
that. In fact, we'd already done so by setting parallel_safe to false while
creating the path, but there is another code path which builds the plan node
directly and we'd missed that.

src/backend/optimizer/plan/createplan.c
src/test/regress/expected/select_parallel.out

index e56144857039fff30fe454127d82e9b851048410..cae36be417db99622a77514d146aefc2e1ef007c 100644 (file)
@@ -5890,6 +5890,9 @@ make_remotesubplan(PlannerInfo *root,
        plan->righttree = NULL;
        copy_plan_costsize(plan, lefttree);
 
+       /* RemoteSubplan is not parallel_safe */
+       plan->parallel_safe = false;
+
        node->cursor = get_internal_cursor();
        node->unique = 0;
        return node;
index 82069afc0f09883c9a845ddc4ce290d511ba5daf..e32bc9b8f15bf9b37246dfc54ce84fb22cbeccb9 100644 (file)
@@ -134,20 +134,17 @@ alter table tenk2 set (parallel_workers = 0);
 explain (costs off)
        select count(*) from tenk1 where (two, four) not in
        (select hundred, thousand from tenk2 where thousand > 100);
-                                     QUERY PLAN                                      
--------------------------------------------------------------------------------------
Finalize Aggregate
+                               QUERY PLAN                                
+-------------------------------------------------------------------------
+ Aggregate
    ->  Remote Subquery Scan on all (datanode_1,datanode_2)
-         ->  Gather
-               Workers Planned: 4
-               ->  Partial Aggregate
-                     ->  Parallel Seq Scan on tenk1
-                           Filter: (NOT (hashed SubPlan 1))
-                           SubPlan 1
-                             ->  Remote Subquery Scan on all (datanode_1,datanode_2)
-                                   ->  Seq Scan on tenk2
-                                         Filter: (thousand > 100)
-(11 rows)
+         ->  Seq Scan on tenk1
+               Filter: (NOT (hashed SubPlan 1))
+               SubPlan 1
+                 ->  Remote Subquery Scan on all (datanode_1,datanode_2)
+                       ->  Seq Scan on tenk2
+                             Filter: (thousand > 100)
+(8 rows)
 
 select count(*) from tenk1 where (two, four) not in
        (select hundred, thousand from tenk2 where thousand > 100);