You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by rn...@apache.org on 2014/04/25 14:10:55 UTC
[2/8] couch-replicator commit: updated
refs/heads/1843-feature-bigcouch to a8add8b
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/9b72668d
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/tree/9b72668d
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/diff/9b72668d
Branch: refs/heads/1843-feature-bigcouch
Commit: 9b72668d687fd9980ef8fd7820c2cf86681f620d
Parents: 8354f42
Author: Robert Newson <rn...@apache.org>
Authored: Tue Dec 3 11:15:59 2013 +0000
Committer: Robert Newson <rn...@apache.org>
Committed: Thu Apr 24 13:16:10 2014 +0100
----------------------------------------------------------------------
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/9b72668d/src/couch_replicator_manager.erl
----------------------------------------------------------------------
diff --git a/src/couch_replicator_manager.erl b/src/couch_replicator_manager.erl
index 5ec2d33..e47222e 100644
--- a/src/couch_replicator_manager.erl
+++ b/src/couch_replicator_manager.erl
@@ -72,6 +72,7 @@ replication_started(#rep{id = {BaseId, _} = RepId}) ->
#rep_state{dbname = DbName, rep = #rep{doc_id = DocId}} ->
update_rep_doc(DbName, DocId, [
{<<"_replication_state">>, <<"triggered">>},
+ {<<"_replication_state_reason">>, undefined},
{<<"_replication_id">>, ?l2b(BaseId)},
{<<"_replication_stats">>, undefined}]),
ok = gen_server:call(?MODULE, {rep_started, RepId}, infinity),
@@ -87,6 +88,7 @@ replication_completed(#rep{id = RepId}, Stats) ->
#rep_state{dbname = DbName, rep = #rep{doc_id = DocId}} ->
update_rep_doc(DbName, DocId, [
{<<"_replication_state">>, <<"completed">>},
+ {<<"_replication_state_reason">>, undefined},
{<<"_replication_stats">>, {Stats}}]),
ok = gen_server:call(?MODULE, {rep_complete, RepId}, infinity),
couch_log:notice("Replication `~s` finished (triggered by document `~s`)",
@@ -99,9 +101,9 @@ replication_error(#rep{id = {BaseId, _} = RepId}, Error) ->
nil ->
ok;
#rep_state{dbname = DbName, rep = #rep{doc_id = DocId}} ->
- % TODO: maybe add error reason to replication document
update_rep_doc(DbName, 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.
@@ -417,7 +419,8 @@ rep_db_update_error(Error, DbName, DocId) ->
end,
couch_log:error("Replication manager, error processing document `~s`: ~s",
[DocId, Reason]),
- update_rep_doc(DbName, DocId, [{<<"_replication_state">>, <<"error">>}]).
+ update_rep_doc(DbName, DocId, [{<<"_replication_state">>, <<"error">>},
+ {<<"_replication_state_reason">>, Reason}]).
rep_user_ctx({RepDoc}) ->
@@ -752,6 +755,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) ->