couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnew...@apache.org
Subject [14/23] couch-replicator commit: updated refs/heads/1843-feature-bigcouch to 4965655
Date Thu, 01 May 2014 14:07:01 GMT
Include reason for replication failure in _replicator doc

closes COUCHDB-1647


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

Branch: refs/heads/1843-feature-bigcouch
Commit: 2b666093dc7292c8a437a5f5f8151a06261b15c8
Parents: ee27edf
Author: Robert Newson <rnewson@apache.org>
Authored: Tue Dec 3 11:15:59 2013 +0000
Committer: Robert Newson <rnewson@apache.org>
Committed: Tue Dec 3 13:10:49 2013 +0000

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


http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/blob/2b666093/src/couch_replicator_manager.erl
----------------------------------------------------------------------
diff --git a/src/couch_replicator_manager.erl b/src/couch_replicator_manager.erl
index bbb0e11..4891c4c 100644
--- a/src/couch_replicator_manager.erl
+++ b/src/couch_replicator_manager.erl
@@ -68,6 +68,7 @@ replication_started(#rep{id = {BaseId, _} = RepId}) ->
     #rep_state{rep = #rep{doc_id = DocId}} ->
         update_rep_doc(DocId, [
             {<<"_replication_state">>, <<"triggered">>},
+            {<<"_replication_state_reason">>, undefined},
             {<<"_replication_id">>, ?l2b(BaseId)},
             {<<"_replication_stats">>, undefined}]),
         ok = gen_server:call(?MODULE, {rep_started, RepId}, infinity),
@@ -83,6 +84,7 @@ replication_completed(#rep{id = RepId}, Stats) ->
     #rep_state{rep = #rep{doc_id = DocId}} ->
         update_rep_doc(DocId, [
             {<<"_replication_state">>, <<"completed">>},
+            {<<"_replication_state_reason">>, undefined},
             {<<"_replication_stats">>, {Stats}}]),
         ok = gen_server:call(?MODULE, {rep_complete, RepId}, infinity),
         ?LOG_INFO("Replication `~s` finished (triggered by document `~s`)",
@@ -95,9 +97,9 @@ replication_error(#rep{id = {BaseId, _} = RepId}, Error) ->
     nil ->
         ok;
     #rep_state{rep = #rep{doc_id = DocId}} ->
-        % TODO: maybe add error reason to replication document
         update_rep_doc(DocId, [
             {<<"_replication_state">>, <<"error">>},
+            {<<"_replication_state_reason">>, to_binary(error_reason(Error))},
             {<<"_replication_id">>, ?l2b(BaseId)}]),
         ok = gen_server:call(?MODULE, {rep_error, RepId, Error}, infinity)
     end.
@@ -344,7 +346,8 @@ rep_db_update_error(Error, DocId) ->
     end,
     ?LOG_ERROR("Replication manager, error processing document `~s`: ~s",
         [DocId, Reason]),
-    update_rep_doc(DocId, [{<<"_replication_state">>, <<"error">>}]).
+    update_rep_doc(DocId, [{<<"_replication_state">>, <<"error">>},
+                           {<<"_replication_state_reason">>, Reason}]).
 
 
 rep_user_ctx({RepDoc}) ->
@@ -619,6 +622,9 @@ rep_state(RepId) ->
     end.
 
 
+error_reason({error, {Error, Reason}})
+  when is_atom(Error), is_binary(Reason) ->
+    io_lib:format("~s: ~s", [Error, Reason]);
 error_reason({error, Reason}) ->
     Reason;
 error_reason(Reason) ->


Mime
View raw message