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 2017/06/19 21:59:25 UTC

[couchdb] 01/05: Fix bug when ddoc_cache hasn't been started

This is an automated email from the ASF dual-hosted git repository.

davisp pushed a commit to branch optimize-ddoc-cache
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 713559984b164a5c9fd6aa6cb7e0413ca1ce23bc
Author: Paul J. Davis <pa...@gmail.com>
AuthorDate: Mon Jun 19 09:08:39 2017 -0500

    Fix bug when ddoc_cache hasn't been started
---
 src/ddoc_cache/src/ddoc_cache_opener.erl | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/ddoc_cache/src/ddoc_cache_opener.erl b/src/ddoc_cache/src/ddoc_cache_opener.erl
index 654a98a..904c36f 100644
--- a/src/ddoc_cache/src/ddoc_cache_opener.erl
+++ b/src/ddoc_cache/src/ddoc_cache_opener.erl
@@ -50,16 +50,16 @@ start_link() ->
 
 
 open(Key) ->
-    case ets:lookup(?CACHE, Key) of
-        [#entry{val = Val}] ->
-            couch_stats:increment_counter([ddoc_cache, hit]),
-            ddoc_cache_lru:accessed(Key),
-            {ok, Val};
+    try ets:lookup(?CACHE, Key) of
         [] ->
             couch_stats:increment_counter([ddoc_cache, miss]),
             Resp = gen_server:call(?MODULE, {open, Key}, infinity),
             ddoc_cache_entry:handle_resp(Resp);
-        recover ->
+        [#entry{val = Val}] ->
+            couch_stats:increment_counter([ddoc_cache, hit]),
+            ddoc_cache_lru:accessed(Key),
+            {ok, Val}
+    catch _:_ ->
             couch_stats:increment_counter([ddoc_cache, recovery]),
             ddoc_cache_entry:open(Key)
     end.

-- 
To stop receiving notification emails like this one, please contact
"commits@couchdb.apache.org" <co...@couchdb.apache.org>.