couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnew...@apache.org
Subject [33/44] couch-replicator commit: updated refs/heads/63012-defensive to 1afa5ea
Date Tue, 07 Jun 2016 11:05:37 GMT
Remove state fields from triggered/error docs


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

Branch: refs/heads/63012-defensive
Commit: 6579c194fc34a270a9c2f9f20aa31cf5398b3d80
Parents: aa621a8
Author: Robert Newson <rnewson@apache.org>
Authored: Fri Jun 3 11:51:09 2016 +0100
Committer: Robert Newson <rnewson@apache.org>
Committed: Fri Jun 3 16:33:13 2016 +0100

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


http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/blob/6579c194/src/couch_replicator_doc_processor.erl
----------------------------------------------------------------------
diff --git a/src/couch_replicator_doc_processor.erl b/src/couch_replicator_doc_processor.erl
index eff37ff..0546da9 100644
--- a/src/couch_replicator_doc_processor.erl
+++ b/src/couch_replicator_doc_processor.erl
@@ -66,12 +66,14 @@ process_update(DbName, {Change}) ->
         undefined ->
             maybe_start_replication(DbName, DocId, JsonRepDoc);
         <<"triggered">> ->
+            couch_replicator_docs:remove_state_fields(DbName, DocId),
             maybe_start_replication(DbName, DocId, JsonRepDoc);
         <<"completed">> ->
             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
+            couch_replicator_docs:remove_state_fields(DbName, DocId),
             maybe_start_replication(DbName, DocId, JsonRepDoc);
         <<"failed">> ->
             Reason = get_json_value(<<"_replication_state_reason">>, RepProps),

http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/blob/6579c194/src/couch_replicator_docs.erl
----------------------------------------------------------------------
diff --git a/src/couch_replicator_docs.erl b/src/couch_replicator_docs.erl
index e9128df..266f0f6 100644
--- a/src/couch_replicator_docs.erl
+++ b/src/couch_replicator_docs.erl
@@ -16,7 +16,7 @@
 -export([before_doc_update/2, after_doc_read/2]).
 -export([ensure_rep_db_exists/0, ensure_rep_ddoc_exists/1]).
 -export([
-    update_doc_triggered/3,
+    remove_state_fields/2,
     update_doc_completed/3,
     update_doc_replication_id/3,
     update_doc_process_error/3
@@ -49,14 +49,12 @@
 
 -define(replace(L, K, V), lists:keystore(K, 1, L, {K, V})).
 
--spec update_doc_triggered(binary(), binary(), rep_id()) -> any().
-update_doc_triggered(DbName, DocId, {BaseId, _}) ->
+remove_state_fields(DbName, DocId) ->
     update_rep_doc(DbName, DocId, [
-            {<<"_replication_state">>, <<"triggered">>},
-            {<<"_replication_state_reason">>, undefined},
-            {<<"_replication_id">>, ?l2b(BaseId)},
-            {<<"_replication_stats">>, undefined}]).
-
+        {<<"_replication_state">>, undefined},
+        {<<"_replication_state_time">>, undefined},
+        {<<"_replication_state_reason">>, undefined},
+        {<<"_replication_stats">>, undefined}]).
 
 -spec update_doc_completed(binary(), binary(), [_]) -> any().
 update_doc_completed(DbName, DocId, Stats) ->

http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/blob/6579c194/src/couch_replicator_scheduler_job.erl
----------------------------------------------------------------------
diff --git a/src/couch_replicator_scheduler_job.erl b/src/couch_replicator_scheduler_job.erl
index dd9d8f3..94582b7 100644
--- a/src/couch_replicator_scheduler_job.erl
+++ b/src/couch_replicator_scheduler_job.erl
@@ -459,8 +459,7 @@ report_job_error(_Rep, _Error) ->
 -spec doc_update_triggered(#rep{}) -> ok.
 doc_update_triggered(#rep{db_name = null}) ->
     ok;
-doc_update_triggered(#rep{id = RepId, db_name = DbName, doc_id = DocId}) ->
-    couch_replicator_docs:update_doc_triggered(DbName, DocId, RepId),
+doc_update_triggered(#rep{id = RepId, doc_id = DocId}) ->
     couch_log:notice("Document `~s` triggered replication `~s`",
         [DocId, pp_rep_id(RepId)]),
     ok.


Mime
View raw message