couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chewbra...@apache.org
Subject [1/5] couchdb-cassim git commit: Move fabric:open_doc calls outside of gen_server
Date Thu, 21 May 2015 21:32:48 GMT
Repository: couchdb-cassim
Updated Branches:
  refs/heads/master 4c3179365 -> c6581f8e8


Move fabric:open_doc calls outside of gen_server

COUCHDB-2657


Project: http://git-wip-us.apache.org/repos/asf/couchdb-cassim/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-cassim/commit/0c3f0450
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-cassim/tree/0c3f0450
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-cassim/diff/0c3f0450

Branch: refs/heads/master
Commit: 0c3f04509f1a2e298c037f82850f6b7b3d08d35c
Parents: 4c31793
Author: Russell Branca <chewbranca@apache.org>
Authored: Fri Apr 17 23:11:18 2015 +0000
Committer: Russell Branca <chewbranca@apache.org>
Committed: Tue Apr 21 19:28:32 2015 +0000

----------------------------------------------------------------------
 src/cassim_metadata_cache.erl | 33 +++++++++++++++++++++++++--------
 src/cassim_security.erl       |  2 ++
 2 files changed, 27 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-cassim/blob/0c3f0450/src/cassim_metadata_cache.erl
----------------------------------------------------------------------
diff --git a/src/cassim_metadata_cache.erl b/src/cassim_metadata_cache.erl
index 1e43dce..b6ad486 100644
--- a/src/cassim_metadata_cache.erl
+++ b/src/cassim_metadata_cache.erl
@@ -40,6 +40,10 @@
     security_meta_id/1
 ]).
 
+-export([
+    cache_timeout/0
+]).
+
 
 -record(st, {
     changes_pid,
@@ -59,6 +63,13 @@ metadata_db() ->
     config:get("couchdb", "metadata_db", "_metadata").
 
 
+cache_timeout() ->
+    case config:get("cassim", "cache_timeout", "5000") of
+        "infinity" -> infinity;
+        N -> list_to_integer(N)
+    end.
+
+
 metadata_db_exists() ->
     try mem3:shards(metadata_db()) of
         _Shards ->
@@ -181,15 +192,21 @@ changes_callback({error, _}, EndSeq) ->
 
 
 load_meta_from_db(DbName, MetaId) ->
-    try fabric:open_doc(DbName, MetaId, []) of
-        {ok, Doc} ->
+    Args = [DbName, MetaId, []],
+    Timeout = cache_timeout(),
+    case couch_util:with_proc(fabric, open_doc, Args, Timeout) of
+        {ok, {ok, Doc}} ->
             couch_doc:to_json_obj(Doc, []);
-        _Else ->
-            couch_log:warning("no record of meta ~s", [MetaId]),
-            undefined
-    catch error:database_does_not_exist ->
-        undefined
-    end.
+        {ok, {not_found, missing}} ->
+            undefined;
+        {error, {database_does_not_exist, _}} ->
+            undefined;
+        {error, timeout} ->
+            couch_log:notice("timeout retrieving metadata doc ~s", [MetaId]),
+            {error, timeout};
+        {error, Error} ->
+            {error, Error}
+     end.
 
 
 load_meta(MetaId) ->

http://git-wip-us.apache.org/repos/asf/couchdb-cassim/blob/0c3f0450/src/cassim_security.erl
----------------------------------------------------------------------
diff --git a/src/cassim_security.erl b/src/cassim_security.erl
index fea7cb6..796cd67 100644
--- a/src/cassim_security.erl
+++ b/src/cassim_security.erl
@@ -60,6 +60,8 @@ get_security_doc(DbName0) when is_binary(DbName0) ->
             SecProps = fabric:get_security(DbName),
             {ok, SecDoc} = migrate_security_props(DbName, SecProps),
             SecDoc;
+        {error, Error} ->
+            throw(Error);
         SecProps ->
             couch_doc:from_json_obj(SecProps)
     end.


Mime
View raw message