From 5e0522932b056eef77ef3a955aebbdadf7400a07 Mon Sep 17 00:00:00 2001 From: Adam Kocoloski Date: Thu, 19 Aug 2010 20:58:59 -0400 Subject: tolerate view groups initializing during DB deletion --- apps/couch/src/couch_view.erl | 2 +- apps/couch/src/couch_view_group.erl | 13 +++++++++---- 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, -- cgit v1.2.3