couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnew...@apache.org
Subject [24/44] couch-replicator commit: updated refs/heads/63012-defensive to 1afa5ea
Date Tue, 07 Jun 2016 11:05:28 GMT
Handle error in replication documents

Retry on  <<"error">> state. Those are documents updated by the older
replicator code. Some of those errors were transient.

Introduce <<"failed">> state for documents which fail to parse as valid
replicator #rep{} records and can't even be submitted as jobs to job
scheduler. On this state, don't attempt to start replication.


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

Branch: refs/heads/63012-defensive
Commit: 0be18f75af9cf578007c57ccb06cb9316436ef68
Parents: a309e8d
Author: Nick Vatamaniuc <vatamane@gmail.com>
Authored: Thu Jun 2 15:28:04 2016 -0400
Committer: Nick Vatamaniuc <vatamane@gmail.com>
Committed: Thu Jun 2 15:28:04 2016 -0400

----------------------------------------------------------------------
 src/couch_replicator_doc_processor.erl | 10 +++++++++-
 src/couch_replicator_docs.erl          |  2 +-
 2 files changed, 10 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/blob/0be18f75/src/couch_replicator_doc_processor.erl
----------------------------------------------------------------------
diff --git a/src/couch_replicator_doc_processor.erl b/src/couch_replicator_doc_processor.erl
index ddaa2b0..0de88d9 100644
--- a/src/couch_replicator_doc_processor.erl
+++ b/src/couch_replicator_doc_processor.erl
@@ -68,7 +68,15 @@ process_update(DbName, {Change}) ->
         <<"triggered">> ->
             maybe_start_replication(DbName, DocId, JsonRepDoc);
         <<"completed">> ->
-            couch_log:notice("Replication '~s' marked as completed", [DocId])
+            couch_log:notice("Replication '~s' marked as completed", [DocId]);
+        <<"error">> ->
+            % Handle replications started from older versions of replicator
+            % which wrote transient errors to replication docs
+            maybe_start_replication(DbName, DocId, JsonRepDoc);
+        <<"failed">> ->
+            Reason = get_json_value(<<"_replication_state_reason">>, RepProps),
+            Msg = "Replication '~s' marked as failed with reason '~s'",
+            couch_log:warning(Msg, [DocId, Reason])
         end;
      {Owner, false} ->
          couch_log:notice("Not starting '~s' as owner is ~s.", [DocId, Owner])

http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/blob/0be18f75/src/couch_replicator_docs.erl
----------------------------------------------------------------------
diff --git a/src/couch_replicator_docs.erl b/src/couch_replicator_docs.erl
index 6c71f66..e9128df 100644
--- a/src/couch_replicator_docs.erl
+++ b/src/couch_replicator_docs.erl
@@ -76,7 +76,7 @@ update_doc_process_error(DbName, DocId, Error) ->
     end,
     couch_log:error("Error processing replication doc `~s`: ~s", [DocId, Reason]),
     update_rep_doc(DbName, DocId, [
-        {<<"_replication_state">>, <<"error">>},
+        {<<"_replication_state">>, <<"failed">>},
         {<<"_replication_state_reason">>, Reason}]).
 
 


Mime
View raw message