Skip to content
This repository
Browse code

Merge pull request #52 from cloudant/14007-fix-fabric-reduce

Fix unnecessary OS process acquisition

BugzID: 14007
  • Loading branch information...
commit 4ff8e698c0b5e9fb7454e08cd7c2e697c53a2f33 2 parents ab8d4f1 + 3b83754
Adam Kocoloski kocolosk authored

Showing 1 changed file with 13 additions and 2 deletions. Show diff stats Hide diff stats

  1. +13 2 src/fabric_view_reduce.erl
15 src/fabric_view_reduce.erl
@@ -36,6 +36,10 @@ go(DbName, DDoc, VName, Args, Callback, Acc0) ->
36 36 RexiMon = fabric_util:create_monitors(Workers),
37 37 BufferSize = couch_config:get("fabric", "reduce_buffer_size", "20"),
38 38 #view_query_args{limit = Limit, skip = Skip} = Args,
  39 + OsProc = case os_proc_needed(RedSrc) of
  40 + true -> couch_query_servers:get_os_process(Lang);
  41 + _ -> nil
  42 + end,
39 43 State = #collector{
40 44 db_name = DbName,
41 45 query_args = Args,
@@ -46,7 +50,7 @@ go(DbName, DDoc, VName, Args, Callback, Acc0) ->
46 50 skip = Skip,
47 51 limit = Limit,
48 52 lang = Group#group.def_lang,
49   - os_proc = couch_query_servers:get_os_process(Lang),
  53 + os_proc = OsProc,
50 54 reducer = RedSrc,
51 55 rows = dict:new(),
52 56 user_acc = Acc0
@@ -62,7 +66,10 @@ go(DbName, DDoc, VName, Args, Callback, Acc0) ->
62 66 after
63 67 rexi_monitor:stop(RexiMon),
64 68 fabric_util:cleanup(Workers),
65   - catch couch_query_servers:ret_os_process(State#collector.os_proc)
  69 + case State#collector.os_proc of
  70 + nil -> ok;
  71 + OsProc -> catch couch_query_servers:ret_os_process(OsProc)
  72 + end
66 73 end.
67 74
68 75 handle_message({rexi_DOWN, _, {_, NodeRef}, _}, _, State) ->
@@ -117,3 +124,7 @@ complete_worker_test() ->
117 124 State = #collector{counters=fabric_dict:init(Workers,0)},
118 125 {ok, NewState} = handle_message(complete, lists:nth(2,Workers), State),
119 126 ?assertEqual(orddict:size(NewState#collector.counters),length(Workers) - 2).
  127 +
  128 +os_proc_needed(<<"_", _/binary>>) -> false;
  129 +os_proc_needed(_) -> true.
  130 +

0 comments on commit 4ff8e69

Please sign in to comment.
Something went wrong with that request. Please try again.