Repository: couchdb-cassim Updated Branches: refs/heads/2657-fix-cassim-fabric-calls 3f15959eb -> c6581f8e8 (forced update)
Add get_security retry logic for handling conflicts Project: http://git-wip-us.apache.org/repos/asf/couchdb-cassim/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb-cassim/commit/ea38f7d5 Tree: http://git-wip-us.apache.org/repos/asf/couchdb-cassim/tree/ea38f7d5 Diff: http://git-wip-us.apache.org/repos/asf/couchdb-cassim/diff/ea38f7d5 Branch: refs/heads/2657-fix-cassim-fabric-calls Commit: ea38f7d58aed8855a34f9dedcd211639d9da7e0e Parents: e67d7ee Author: Russell Branca <[email protected]> Authored: Thu Apr 23 23:50:18 2015 +0000 Committer: Russell Branca <[email protected]> Committed: Thu May 21 21:07:47 2015 +0000 ---------------------------------------------------------------------- src/cassim_security.erl | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb-cassim/blob/ea38f7d5/src/cassim_security.erl ---------------------------------------------------------------------- diff --git a/src/cassim_security.erl b/src/cassim_security.erl index 796cd67..9d616f7 100644 --- a/src/cassim_security.erl +++ b/src/cassim_security.erl @@ -52,14 +52,28 @@ get_security(DbName, Options) -> end. -get_security_doc(DbName0) when is_binary(DbName0) -> +get_security_doc(DbName) when is_binary(DbName) -> + RetryCnt = config:get_integer("cassim", "get_security_retries", 3), + get_security_doc(DbName, RetryCnt). + + +get_security_doc(DbName, RetryCnt) when RetryCnt =< 0 -> + couch_log:error( + "Exhausted retry limit loading security doc for db ~s", [DbName] + ), + throw({retries_limit_exhaused, "Exhaused security doc retry limit"}); +get_security_doc(DbName0, RetryCnt) -> DbName = mem3:dbname(DbName0), MetaId = cassim_metadata_cache:security_meta_id(DbName), case cassim_metadata_cache:load_meta(MetaId) of undefined -> SecProps = fabric:get_security(DbName), - {ok, SecDoc} = migrate_security_props(DbName, SecProps), - SecDoc; + try migrate_security_props(DbName, SecProps) of + {ok, SecDoc} -> + SecDoc + catch conflict -> + get_security_doc(DbName0, RetryCnt-1) + end; {error, Error} -> throw(Error); SecProps ->
