couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vatam...@apache.org
Subject [46/50] couch-replicator commit: updated refs/heads/63012-scheduler to 27a5eae
Date Tue, 14 Mar 2017 19:26:41 GMT
Forward-port "Fix crashes when replicator db is deleted" from master

This is port of commit: 7a2b2b68bf4afa6d20b56a8ae51361f83981412a from master.

That commit was made to couch_replicator_manager so it had to be ported by
hand.

Most of the logic for replicator document handling is now in
couch_replicator_docs.erl module. The scanner part is in couch_multidb_changes.


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/5bebb8a6
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/tree/5bebb8a6
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/diff/5bebb8a6

Branch: refs/heads/63012-scheduler
Commit: 5bebb8a61a70cc783eedf430b46155409099d11e
Parents: 38c9405
Author: Nick Vatamaniuc <vatamane@apache.org>
Authored: Fri Mar 3 13:55:13 2017 -0500
Committer: Nick Vatamaniuc <vatamane@apache.org>
Committed: Fri Mar 3 13:55:13 2017 -0500

----------------------------------------------------------------------
 src/couch_multidb_changes.erl |  7 ++++++-
 src/couch_replicator_docs.erl | 17 ++++++++++++-----
 2 files changed, 18 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/blob/5bebb8a6/src/couch_multidb_changes.erl
----------------------------------------------------------------------
diff --git a/src/couch_multidb_changes.erl b/src/couch_multidb_changes.erl
index d5016b6..9c0b7cf 100644
--- a/src/couch_multidb_changes.erl
+++ b/src/couch_multidb_changes.erl
@@ -276,7 +276,12 @@ filter_shards(DbName, DbSuffix) ->
     false ->
         [];
     true ->
-        [ShardName || #shard{name = ShardName} <- mem3:local_shards(DbName)]
+        try
+            [ShardName || #shard{name = ShardName} <- mem3:local_shards(DbName)]
+        catch
+            error:database_does_not_exist ->
+                []
+        end
     end.
 
 

http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/blob/5bebb8a6/src/couch_replicator_docs.erl
----------------------------------------------------------------------
diff --git a/src/couch_replicator_docs.erl b/src/couch_replicator_docs.erl
index 204cb39..1bc852e 100644
--- a/src/couch_replicator_docs.erl
+++ b/src/couch_replicator_docs.erl
@@ -147,6 +147,9 @@ ensure_rep_ddoc_exists(RepDb) ->
 -spec ensure_rep_ddoc_exists(binary(), binary()) -> ok.
 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} ->
             DocProps = replication_design_doc_props(DDocId),
             DDoc = couch_doc:from_json_obj({DocProps}),
@@ -350,11 +353,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) ->


Mime
View raw message