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 2016/06/03 15:17:50 UTC
[26/30] couch-replicator commit: updated
refs/heads/63012-scheduler-dont-start-immediately to 6a913dc
Better handling for duplicate replication docs.
Duplicate replication docs are documents which specify the same replication.
Handle 3 cases:
1) Documents are in same database, but potentially differen shards.
2) Documents are in two different replicator databases. For example in
`a/_replicator` and `b/_replicator`. Handle this case better with a warning
instead of crashing inside the case clause.
3) Handle the case when existing replication is transient, in other words,
started from the `_replicate` endpoint.
A case that is not handled directly is replications which are from different
databases, different docs and different nodes. In that case they will collide
and contend on global registration of scheduler jobs.
Also fixed indentation in process_update.
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/c79861e0
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/tree/c79861e0
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/diff/c79861e0
Branch: refs/heads/63012-scheduler-dont-start-immediately
Commit: c79861e0265db70f941a4988c41ac801c999ef78
Parents: 4dfa279
Author: Nick Vatamaniuc <va...@gmail.com>
Authored: Thu Jun 2 16:57:32 2016 -0400
Committer: Nick Vatamaniuc <va...@gmail.com>
Committed: Thu Jun 2 16:57:32 2016 -0400
----------------------------------------------------------------------
src/couch_replicator_doc_processor.erl | 22 +++++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/blob/c79861e0/src/couch_replicator_doc_processor.erl
----------------------------------------------------------------------
diff --git a/src/couch_replicator_doc_processor.erl b/src/couch_replicator_doc_processor.erl
index 0de88d9..2ea34ea 100644
--- a/src/couch_replicator_doc_processor.erl
+++ b/src/couch_replicator_doc_processor.erl
@@ -78,8 +78,8 @@ process_update(DbName, {Change}) ->
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])
+ {Owner, false} ->
+ couch_log:notice("Not starting '~s' as owner is ~s.", [DocId, Owner])
end,
ok.
@@ -102,9 +102,21 @@ maybe_start_replication(DbName, DocId, RepDoc) ->
ok;
#rep{doc_id = DocId} ->
ok;
- #rep{db_name = DbName, doc_id = OtherDocId} ->
- couch_log:notice("The replication specified by the document `~s` already started"
- " triggered by the document `~s`", [DocId, OtherDocId]),
+ #rep{doc_id = null} ->
+ couch_log:warning("Replication `~s` specified by document `~s`"
+ " already running as a transient replication, started via `_replicate`"
+ " API endpoint", [pp_rep_id(RepId), DocId]);
+ #rep{db_name = OtherDbName, doc_id = OtherDocId} ->
+ case mem3:dbname(OtherDbName) =:= mem3:dbname(DbName) of
+ true ->
+ couch_log:notice("Replication `~s` specified by document `~s`"
+ " already started, triggered by document `~s` from the same"
+ " database", [pp_rep_id(RepId), DocId, OtherDocId]);
+ false ->
+ couch_log:warning("Replication `~s` specified by document `~s`"
+ " already started triggered by document `~s` from a different"
+ " database", [pp_rep_id(RepId), DocId, OtherDocId])
+ end,
maybe_tag_rep_doc(DbName, DocId, RepDoc, ?l2b(BaseId))
end,
ok.