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 2015/09/14 14:26:14 UTC
couch-replicator commit: updated refs/heads/master to b695bb2
Repository: couchdb-couch-replicator
Updated Branches:
refs/heads/master 90d70883e -> b695bb293
Include originating database
Any database whose path ends in /_replicator is considered a
replicator database. Show this name in the active tasks output so that
the doc_id can be easily found in all cases.
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/b695bb29
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/tree/b695bb29
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/diff/b695bb29
Branch: refs/heads/master
Commit: b695bb293aceb2a3157da70138dbf3966f1a64e6
Parents: 90d7088
Author: Robert Newson <rn...@apache.org>
Authored: Sat Sep 12 17:47:13 2015 +0100
Committer: Robert Newson <rn...@apache.org>
Committed: Sun Sep 13 11:18:17 2015 +0100
----------------------------------------------------------------------
src/couch_replicator.erl | 1 +
src/couch_replicator.hrl | 3 ++-
src/couch_replicator_manager.erl | 20 +++++++++-----------
3 files changed, 12 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/blob/b695bb29/src/couch_replicator.erl
----------------------------------------------------------------------
diff --git a/src/couch_replicator.erl b/src/couch_replicator.erl
index f8a3e65..f5055e0 100644
--- a/src/couch_replicator.erl
+++ b/src/couch_replicator.erl
@@ -295,6 +295,7 @@ do_init(#rep{options = Options, id = {BaseId, Ext}, user_ctx=UserCtx} = Rep) ->
{type, replication},
{user, UserCtx#user_ctx.name},
{replication_id, ?l2b(BaseId ++ Ext)},
+ {database, Rep#rep.db_name},
{doc_id, Rep#rep.doc_id},
{source, ?l2b(SourceName)},
{target, ?l2b(TargetName)},
http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/blob/b695bb29/src/couch_replicator.hrl
----------------------------------------------------------------------
diff --git a/src/couch_replicator.hrl b/src/couch_replicator.hrl
index dbb1793..d3485c0 100644
--- a/src/couch_replicator.hrl
+++ b/src/couch_replicator.hrl
@@ -20,5 +20,6 @@
user_ctx,
type = db,
view = nil,
- doc_id
+ doc_id,
+ db_name = null
}).
http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/blob/b695bb29/src/couch_replicator_manager.erl
----------------------------------------------------------------------
diff --git a/src/couch_replicator_manager.erl b/src/couch_replicator_manager.erl
index 972d8ed..c6f7960 100644
--- a/src/couch_replicator_manager.erl
+++ b/src/couch_replicator_manager.erl
@@ -53,7 +53,6 @@
-define(replace(L, K, V), lists:keystore(K, 1, L, {K, V})).
-record(rep_state, {
- dbname,
rep,
starting,
retries_left,
@@ -81,7 +80,7 @@ replication_started(#rep{id = {BaseId, _} = RepId}) ->
case rep_state(RepId) of
nil ->
ok;
- #rep_state{dbname = DbName, rep = #rep{doc_id = DocId}} ->
+ #rep_state{rep = #rep{db_name = DbName, doc_id = DocId}} ->
update_rep_doc(DbName, DocId, [
{<<"_replication_state">>, <<"triggered">>},
{<<"_replication_state_reason">>, undefined},
@@ -97,7 +96,7 @@ replication_completed(#rep{id = RepId}, Stats) ->
case rep_state(RepId) of
nil ->
ok;
- #rep_state{dbname = DbName, rep = #rep{doc_id = DocId}} ->
+ #rep_state{rep = #rep{db_name = DbName, doc_id = DocId}} ->
update_rep_doc(DbName, DocId, [
{<<"_replication_state">>, <<"completed">>},
{<<"_replication_state_reason">>, undefined},
@@ -123,7 +122,7 @@ replication_error(#rep{id = {BaseId, _} = RepId}, Error) ->
case rep_state(RepId) of
nil ->
ok;
- #rep_state{dbname = DbName, rep = #rep{doc_id = DocId}} ->
+ #rep_state{rep = #rep{db_name = DbName, doc_id = DocId}} ->
update_rep_doc(DbName, DocId, [
{<<"_replication_state">>, <<"error">>},
{<<"_replication_state_reason">>, to_binary(error_reason(Error))},
@@ -181,7 +180,7 @@ handle_call({owner, RepId}, _From, State) ->
case rep_state(RepId) of
nil ->
{reply, nonode, State};
- #rep_state{dbname = DbName, rep = #rep{doc_id = DocId}} ->
+ #rep_state{rep = #rep{db_name = DbName, doc_id = DocId}} ->
{reply, owner(DbName, DocId, State#state.live), State}
end;
@@ -475,11 +474,11 @@ rep_user_ctx({RepDoc}) ->
maybe_start_replication(State, DbName, DocId, RepDoc) ->
- #rep{id = {BaseId, _} = RepId} = Rep = parse_rep_doc(RepDoc),
+ #rep{id = {BaseId, _} = RepId} = Rep0 = parse_rep_doc(RepDoc),
+ Rep = Rep0#rep{db_name = DbName},
case rep_state(RepId) of
nil ->
RepState = #rep_state{
- dbname = DbName,
rep = Rep,
starting = true,
retries_left = State#state.max_retries,
@@ -500,12 +499,12 @@ maybe_start_replication(State, DbName, DocId, RepDoc) ->
State#state{rep_start_pids = [Pid | State#state.rep_start_pids]};
#rep_state{rep = #rep{doc_id = DocId}} ->
State;
- #rep_state{starting = false, dbname = DbName, rep = #rep{doc_id = OtherDocId}} ->
+ #rep_state{starting = false, rep = #rep{db_name = DbName, doc_id = OtherDocId}} ->
couch_log:notice("The replication specified by the document `~s` was already"
" triggered by the document `~s`", [DocId, OtherDocId]),
maybe_tag_rep_doc(DbName, DocId, RepDoc, ?l2b(BaseId)),
State;
- #rep_state{starting = true, dbname = DbName, rep = #rep{doc_id = OtherDocId}} ->
+ #rep_state{starting = true, rep = #rep{db_name = DbName, doc_id = OtherDocId}} ->
couch_log:notice("The replication specified by the document `~s` is already"
" being triggered by the document `~s`", [DocId, OtherDocId]),
maybe_tag_rep_doc(DbName, DocId, RepDoc, ?l2b(BaseId)),
@@ -592,8 +591,7 @@ replication_error(State, RepId, Error) ->
maybe_retry_replication(#rep_state{retries_left = 0} = RepState, Error, State) ->
#rep_state{
- dbname = DbName,
- rep = #rep{id = RepId, doc_id = DocId},
+ rep = #rep{id = RepId, doc_id = DocId, db_name = DbName},
max_retries = MaxRetries
} = RepState,
couch_replicator:cancel_replication(RepId),