You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by to...@apache.org on 2017/07/17 15:23:58 UTC

[couchdb] branch 3423-add-try-catch-mem3 updated (1aaf1b2 -> 38cc139)

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

tonysun83 pushed a change to branch 3423-add-try-catch-mem3
in repository https://gitbox.apache.org/repos/asf/couchdb.git.


    omit 1aaf1b2  catch database not exist error
     new 38cc139  catch database not exist error

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (1aaf1b2)
            \
             N -- N -- N   refs/heads/3423-add-try-catch-mem3 (38cc139)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:

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

[couchdb] 01/01: catch database not exist error

Posted by to...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

tonysun83 pushed a commit to branch 3423-add-try-catch-mem3
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 38cc13957debe6f34b328b9a3f0cb86a7eff0dfb
Author: Tony Sun <to...@cloudant.com>
AuthorDate: Tue May 23 13:05:15 2017 -0700

    catch database not exist error
    
    If dbs do not exist, we catch the error for mem3_sync_security
    so that it can continue for databases that do exist.
    
    https://github.com/apache/couchdb/pull/538
    
    COUCHDB-3423
---
 src/mem3/src/mem3_sync_security.erl       | 14 ++++++++++++--
 src/mem3/test/mem3_sync_security_test.erl | 29 +++++++++++++++++++++++++++++
 2 files changed, 41 insertions(+), 2 deletions(-)

diff --git a/src/mem3/src/mem3_sync_security.erl b/src/mem3/src/mem3_sync_security.erl
index 9edd0ec..291e4e0 100644
--- a/src/mem3/src/mem3_sync_security.erl
+++ b/src/mem3/src/mem3_sync_security.erl
@@ -44,10 +44,20 @@ maybe_sync_int(#shard{name=Name}=Src, Dst) ->
 
 go() ->
     {ok, Dbs} = fabric:all_dbs(),
-    lists:foreach(fun handle_db/1, Dbs).
+    lists:foreach(fun handle_existing_db/1, Dbs).
 
 go(DbName) when is_binary(DbName) ->
-    handle_db(DbName).
+    handle_existing_db(DbName).
+
+handle_existing_db(DbName) ->
+    try handle_db(DbName) of
+        _ -> ok
+    catch
+        error:database_does_not_exist->
+            couch_log:error("Db was deleted while getting security"
+                " object. DbName: ~p", [DbName]),
+            ok
+    end.
 
 handle_db(DbName) ->
     ShardCount = length(mem3:shards(DbName)),
diff --git a/src/mem3/test/mem3_sync_security_test.erl b/src/mem3/test/mem3_sync_security_test.erl
new file mode 100644
index 0000000..8b6af3c
--- /dev/null
+++ b/src/mem3/test/mem3_sync_security_test.erl
@@ -0,0 +1,29 @@
+% Licensed under the Apache License, Version 2.0 (the "License"); you may not
+% use this file except in compliance with the License. You may obtain a copy of
+% the License at
+%
+%   http://www.apache.org/licenses/LICENSE-2.0
+%
+% Unless required by applicable law or agreed to in writing, software
+% distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+% WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+% License for the specific language governing permissions and limitations under
+% the License.
+
+-module(mem3_sync_security_test).
+
+-include_lib("couch/include/couch_eunit.hrl").
+-include_lib("couch/include/couch_db.hrl").
+-include("mem3.hrl").
+-include_lib("eunit/include/eunit.hrl").
+
+go_test() ->
+    Ctx = test_util:start_couch([fabric, mem3]),
+    ok = meck:new(fabric, [passthrough]),
+    meck:expect(fabric, all_dbs, fun() ->
+        {ok, [<<"NoExistDb1">>, <<"NoExistDb2">>]}
+    end),
+    Result = mem3_sync_security:go(),
+    meck:unload(fabric),
+    test_util:stop_couch(Ctx),
+    ?assertEqual(ok, Result).

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