summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Kocoloski <adam@cloudant.com>2010-08-19 20:58:59 -0400
committerAdam Kocoloski <adam@cloudant.com>2010-08-27 16:34:31 -0400
commit5e0522932b056eef77ef3a955aebbdadf7400a07 (patch)
tree825990518028a8e71a2f2f104ef5e8e260965e44
parent0f257eb59352fd14f85c98a172388e2afab8fd3a (diff)
tolerate view groups initializing during DB deletion
-rw-r--r--apps/couch/src/couch_view.erl2
-rw-r--r--apps/couch/src/couch_view_group.erl13
2 files changed, 10 insertions, 5 deletions
diff --git a/apps/couch/src/couch_view.erl b/apps/couch/src/couch_view.erl
index 72facd27..8615ea35 100644
--- a/apps/couch/src/couch_view.erl
+++ b/apps/couch/src/couch_view.erl
@@ -321,7 +321,7 @@ do_reset_indexes(DbName, Root) ->
handle_info({'EXIT', FromPid, Reason}, Server) ->
case ets:lookup(couch_groups_by_updater, FromPid) of
[] ->
- if Reason /= normal ->
+ if Reason =/= normal, Reason =/= no_db_file ->
% non-updater linked process died, we propagate the error
?LOG_ERROR("Exit on non-updater process: ~p", [Reason]),
exit(Reason);
diff --git a/apps/couch/src/couch_view_group.erl b/apps/couch/src/couch_view_group.erl
index f11bb54d..8b79af63 100644
--- a/apps/couch/src/couch_view_group.erl
+++ b/apps/couch/src/couch_view_group.erl
@@ -540,10 +540,15 @@ delete_index_file(RootDir, DbName, GroupSig) ->
couch_file:delete(RootDir, index_file_name(RootDir, DbName, GroupSig)).
init_group(Fd, #group{dbname=DbName, views=Views}=Group, nil) ->
- {ok, Db} = couch_db:open(DbName, []),
- PurgeSeq = try couch_db:get_purge_seq(Db) after couch_db:close(Db) end,
- Header = #index_header{purge_seq=PurgeSeq, view_states=[nil || _ <- Views]},
- init_group(Fd, Group, Header);
+ case couch_db:open(DbName, []) of
+ {ok, Db} ->
+ PurgeSeq = try couch_db:get_purge_seq(Db) after couch_db:close(Db) end,
+ Header = #index_header{purge_seq=PurgeSeq, view_states=[nil || _ <- Views]},
+ init_group(Fd, Group, Header);
+ {not_found, no_db_file} ->
+ ?LOG_ERROR("~p no_db_file ~p", [?MODULE, DbName]),
+ exit(no_db_file)
+ end;
init_group(Fd, #group{def_lang=Lang,views=Views}=Group, IndexHeader) ->
#index_header{seq=Seq, purge_seq=PurgeSeq,
id_btree_state=IdBtreeState, view_states=ViewStates} = IndexHeader,