You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by da...@apache.org on 2014/01/17 22:41:36 UTC
[10/18] git commit: Handle requests that occur when the LRU is down
Handle requests that occur when the LRU is down
We don't want to break things if the ddoc cache LRU disappears for any
reason. I've seen this during the first release upgrade as well as
locally during a dev node boot. Its relatively minor but we should be
thorough here.
Project: http://git-wip-us.apache.org/repos/asf/couchdb-ddoc-cache/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-ddoc-cache/commit/077113e1
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-ddoc-cache/tree/077113e1
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-ddoc-cache/diff/077113e1
Branch: refs/heads/import
Commit: 077113e16efb3208dded09c1e8e57888a2153f6f
Parents: 304b46f
Author: Paul J. Davis <pa...@gmail.com>
Authored: Fri Jan 25 00:12:20 2013 -0600
Committer: Paul J. Davis <pa...@gmail.com>
Committed: Fri Jan 25 00:12:20 2013 -0600
----------------------------------------------------------------------
src/ddoc_cache.erl | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb-ddoc-cache/blob/077113e1/src/ddoc_cache.erl
----------------------------------------------------------------------
diff --git a/src/ddoc_cache.erl b/src/ddoc_cache.erl
index e4e16bd..720f9df 100644
--- a/src/ddoc_cache.erl
+++ b/src/ddoc_cache.erl
@@ -33,7 +33,7 @@ open(DbName, DDocId) when is_binary(DDocId) ->
open(Key) ->
- case ets_lru:lookup_d(?CACHE, Key) of
+ try ets_lru:lookup_d(?CACHE, Key) of
{ok, _} = Resp ->
Resp;
_ ->
@@ -43,6 +43,9 @@ open(Key) ->
Else ->
throw(Else)
end
+ catch
+ error:badarg ->
+ recover(Key)
end.
@@ -50,3 +53,15 @@ evict(ShardDbName, DDocIds) ->
DbName = mem3:dbname(ShardDbName),
gen_server:cast(?OPENER, {evict, DbName, DDocIds}).
+
+recover({DbName, validation_funs}) ->
+ {ok, DDocs} = fabric:design_docs(mem3:dbname(DbName)),
+ Funs = lists:flatmap(fun(DDoc) ->
+ case couch_doc:get_validate_doc_fun(DDoc) of
+ nil -> [];
+ Fun -> [Fun]
+ end
+ end, DDocs),
+ {ok, Funs};
+recover({DbName, DDocId}) ->
+ fabric:open_doc(DbName, DDocId, []).