couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnew...@apache.org
Subject [2/2] couch-replicator commit: updated refs/heads/master to 7a2b2b6
Date Wed, 01 Mar 2017 16:09:02 GMT
fix crashes when replicator db is deleted

BugzID: 83663


Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/commit/7a2b2b68
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/tree/7a2b2b68
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/diff/7a2b2b68

Branch: refs/heads/master
Commit: 7a2b2b68bf4afa6d20b56a8ae51361f83981412a
Parents: 1e413b8
Author: Robert Newson <rnewson@apache.org>
Authored: Wed Mar 1 11:14:02 2017 +0000
Committer: Robert Newson <rnewson@apache.org>
Committed: Wed Mar 1 11:15:59 2017 +0000

----------------------------------------------------------------------
 src/couch_replicator_manager.erl | 26 ++++++++++++++++++--------
 1 file changed, 18 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/blob/7a2b2b68/src/couch_replicator_manager.erl
----------------------------------------------------------------------
diff --git a/src/couch_replicator_manager.erl b/src/couch_replicator_manager.erl
index bdc3b8f..c9c0a68 100644
--- a/src/couch_replicator_manager.erl
+++ b/src/couch_replicator_manager.erl
@@ -731,11 +731,15 @@ update_rep_doc(RepDbName, #doc{body = {RepDocBody}} = RepDoc, KVs, _Try)
->
     end.
 
 open_rep_doc(DbName, DocId) ->
-    {ok, Db} = couch_db:open_int(DbName, [?CTX, sys_db]),
-    try
-        couch_db:open_doc(Db, DocId, [ejson_body])
-    after
-        couch_db:close(Db)
+    case couch_db:open_int(DbName, [?CTX, sys_db]) of
+        {ok, Db} ->
+            try
+                couch_db:open_doc(Db, DocId, [ejson_body])
+            after
+                couch_db:close(Db)
+            end;
+        Else ->
+            Else
     end.
 
 save_rep_doc(DbName, Doc) ->
@@ -791,6 +795,9 @@ ensure_rep_ddoc_exists(RepDb) ->
 
 ensure_rep_ddoc_exists(RepDb, DDocId) ->
     case open_rep_doc(RepDb, DDocId) of
+        {not_found, no_db_file} ->
+            %% database was deleted.
+            ok;
         {not_found, _Reason} ->
             {ok, DDoc} = replication_design_doc(DDocId),
             couch_log:notice("creating replicator ddoc", []),
@@ -941,9 +948,12 @@ scan_all_dbs(Server) when is_pid(Server) ->
             true ->
                 ok;
             false ->
-                [gen_server:cast(Server, {resume_scan, ShardName})
-                    || ShardName <- replicator_shards(DbName)],
-                ok
+                try
+                    [gen_server:cast(Server, {resume_scan, ShardName})
+                        || ShardName <- replicator_shards(DbName)]
+                catch error:database_does_not_exist ->
+                    ok
+                end
             end
         end;
         (_, _) -> ok


Mime
View raw message