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/08/01 16:29:43 UTC
[03/23] fabric commit: updated refs/heads/windsor-merge to 4ec3f11
Use smarter replacements for stream_start failures
This patch enhances the StartFun to search the original list of workers
for the sequence from which the worker being replaced had started.
BugzID: 22698
Project: http://git-wip-us.apache.org/repos/asf/couchdb-fabric/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-fabric/commit/3710a6a9
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-fabric/tree/3710a6a9
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-fabric/diff/3710a6a9
Branch: refs/heads/windsor-merge
Commit: 3710a6a9a875ef5a6c5a8b203823d640ce549789
Parents: ef08581
Author: Adam Kocoloski <ad...@cloudant.com>
Authored: Fri Nov 22 22:03:22 2013 -0500
Committer: Robert Newson <rn...@apache.org>
Committed: Fri Aug 1 14:25:00 2014 +0100
----------------------------------------------------------------------
src/fabric_view_changes.erl | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb-fabric/blob/3710a6a9/src/fabric_view_changes.erl
----------------------------------------------------------------------
diff --git a/src/fabric_view_changes.erl b/src/fabric_view_changes.erl
index 4ee87e4..d94870e 100644
--- a/src/fabric_view_changes.erl
+++ b/src/fabric_view_changes.erl
@@ -133,8 +133,20 @@ send_changes(DbName, ChangesArgs, Callback, PackedSeqs, AccIn, Timeout) ->
end, unpack_seqs(PackedSeqs, DbName)),
{Workers0, _} = lists:unzip(Seqs),
Repls = fabric_view:get_shard_replacements(DbName, Workers0),
- StartFun = fun(#shard{name=Name, node=N}=Shard) ->
- Ref = rexi:cast(N, {fabric_rpc, changes, [Name, ChangesArgs, 0]}),
+ StartFun = fun(#shard{name=Name, node=N, range=R0}=Shard) ->
+ %% Find the original shard copy in the Seqs array
+ case lists:dropwhile(fun({S, _}) -> S#shard.range =/= R0 end, Seqs) of
+ [{#shard{node = OldNode}, OldSeq} | _] when is_integer(OldSeq) ->
+ SeqArg = make_replacement_arg(OldNode, OldSeq);
+ _ ->
+ % TODO this clause is probably unreachable in the N>2
+ % case because we compute replacements only if a shard has one
+ % in the original set.
+ twig:log(error, "Streaming ~s from zero while replacing ~p",
+ [Name, PackedSeqs]),
+ SeqArg = 0
+ end,
+ Ref = rexi:cast(N, {fabric_rpc, changes, [Name, ChangesArgs, SeqArg]}),
Shard#shard{ref = Ref}
end,
RexiMon = fabric_util:create_monitors(Workers0),