Repository: couchdb-fabric Updated Branches: refs/heads/master c38c692fc -> 7d0787785
Use the correct sequence for shard replacement The call to unpack the since sequence for _changes incorrectly filtered the value for any shard that didn't exist. This means that any shard that was moved ended up requiring a complete rescan which is a bug. This just sets the update sequence to the range of the shard being replaced rather than zero. COUCHDB-3055 Project: http://git-wip-us.apache.org/repos/asf/couchdb-fabric/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb-fabric/commit/5d099596 Tree: http://git-wip-us.apache.org/repos/asf/couchdb-fabric/tree/5d099596 Diff: http://git-wip-us.apache.org/repos/asf/couchdb-fabric/diff/5d099596 Branch: refs/heads/master Commit: 5d0995966c117e3cf946216aff41116c2020c212 Parents: c38c692 Author: Paul J. Davis <paul.joseph.da...@gmail.com> Authored: Tue Feb 10 21:49:40 2015 -0600 Committer: ILYA Khlopotov <iil...@ca.ibm.com> Committed: Mon Jul 11 12:22:19 2016 -0700 ---------------------------------------------------------------------- src/fabric_view_changes.erl | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb-fabric/blob/5d099596/src/fabric_view_changes.erl ---------------------------------------------------------------------- diff --git a/src/fabric_view_changes.erl b/src/fabric_view_changes.erl index 4855989..7e329ac 100644 --- a/src/fabric_view_changes.erl +++ b/src/fabric_view_changes.erl @@ -432,9 +432,30 @@ do_unpack_seqs(Opaque, DbName) -> Ranges = lists:usort(lists:map(Extract, Unpacked)), Filter = fun(S) -> not lists:member(S#shard.range, Ranges) end, Replacements = lists:filter(Filter, mem3:shards(DbName)), - Unpacked ++ [{R, 0} || R <- Replacements] + Unpacked ++ [{R, get_old_seq(R, Deduped)} || R <- Replacements] end. + +get_old_seq(#shard{range=R}, SinceSeqs) -> + case lists:keyfind(R, 2, SinceSeqs) of + {_Node, R, Seq} when is_number(Seq) -> + % Unfortunately we don't have access to the db + % uuid so we can't set a replacememnt here. + 0; + {Node, R, {Seq, Uuid}} -> + % This update seq is using the old format that + % didn't include the node. This information is + % important for replacement. + {Seq, Uuid, Node}; + {_Node, R, {Seq, Uuid, EpochNode}} -> + % This is the newest sequence format that we + % can use for replacement. + {Seq, Uuid, EpochNode}; + _ -> + 0 + end. + + changes_row(Props0) -> Props1 = case couch_util:get_value(deleted, Props0) of true ->