From ab65f7b8add60ac0a6f9baac25d770ca8297a7a5 Mon Sep 17 00:00:00 2001 From: Robert Dionne Date: Mon, 22 Nov 2010 19:48:29 -0500 Subject: Support per-shard view compaction w/ non-local design docs, closes #16 --- apps/couch/src/couch_view.erl | 3 +-- apps/couch/src/couch_view_group.erl | 18 +++++++----------- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/apps/couch/src/couch_view.erl b/apps/couch/src/couch_view.erl index 8615ea35..9de86b82 100644 --- a/apps/couch/src/couch_view.erl +++ b/apps/couch/src/couch_view.erl @@ -44,8 +44,7 @@ get_temp_updater(DbName, Language, DesignOptions, MapSrc, RedSrc) -> get_group_server(DbName, GroupId) -> % get signature for group case couch_view_group:open_db_group(DbName, GroupId) of - % do we need to close this db? - {ok, _Db, Group} -> + {ok, Group} -> case gen_server:call(couch_view, {get_group_server, DbName, Group}) of {ok, Pid} -> Pid; diff --git a/apps/couch/src/couch_view_group.erl b/apps/couch/src/couch_view_group.erl index 8b79af63..377e7516 100644 --- a/apps/couch/src/couch_view_group.erl +++ b/apps/couch/src/couch_view_group.erl @@ -440,17 +440,13 @@ set_view_sig(#group{ G#group{sig=couch_util:md5(term_to_binary({Views, Language, DesignOptions}))}. open_db_group(DbName, GroupId) -> - case couch_db:open_int(DbName, []) of - {ok, Db} -> - case couch_db:open_doc(Db, GroupId) of - {ok, Doc} -> - {ok, Db, design_doc_to_view_group(Doc)}; - Else -> - couch_db:close(Db), - Else - end; - Else -> - Else + {Pid, Ref} = spawn_monitor(fun() -> + exit(fabric:open_doc(mem3:dbname(DbName), GroupId, [])) + end), + receive {'DOWN', Ref, process, Pid, {ok, Doc}} -> + {ok, design_doc_to_view_group(Doc)}; + {'DOWN', Ref, process, Pid, Error} -> + Error end. get_group_info(State) -> -- cgit v1.2.3