This is an automated email from the ASF dual-hosted git repository.
vatamane pushed a commit to branch shard-split
in repository https://gitbox.apache.org/repos/asf/couchdb.git
The following commit(s) were added to refs/heads/shard-split by this push:
new b32afdd When retrying initial_copy state, make sure to reset targets
b32afdd is described below
commit b32afdd8b8b7231dc0c4c3b7b907ee0da3d95043
Author: Nick Vatamaniuc <[email protected]>
AuthorDate: Fri Feb 1 16:27:39 2019 -0500
When retrying initial_copy state, make sure to reset targets
reset_targets double-checks that the target does not appear in the
list of active shards before resetting.
---
src/mem3/src/mem3_reshard_httpd_util.erl | 7 ++++---
src/mem3/src/mem3_reshard_job.erl | 6 +++++-
2 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/src/mem3/src/mem3_reshard_httpd_util.erl
b/src/mem3/src/mem3_reshard_httpd_util.erl
index 214e026..4718bd5 100644
--- a/src/mem3/src/mem3_reshard_httpd_util.erl
+++ b/src/mem3/src/mem3_reshard_httpd_util.erl
@@ -127,13 +127,14 @@ create_jobs(Node, Shard, Db, Range, split) ->
pick_shards(undefined, undefined, Db, undefined) ->
mem3:shards(Db);
-pick_shards(Node, undefined, Db, undefined) when is_atom(Node) ->
+pick_shards(Node, undefined, Db, undefined) when is_atom(Node), is_binary(Db)
->
[S || S <- mem3:shards(Db), mem3:node(S) == Node];
-pick_shards(undefined, undefined, Db, [_B, _E] = Range) ->
+pick_shards(undefined, undefined, Db, [_B, _E] = Range) when is_binary(Db) ->
[S || S <- mem3:shards(Db), mem3:range(S) == Range];
-pick_shards(Node, undefined, Db, [_B, _E] = Range) when is_atom(Node) ->
+pick_shards(Node, undefined, Db, [_B, _E] = Range) when is_atom(Node),
+ is_binary(Db) ->
[S || S <- mem3:shards(Db), mem3:node(S) == Node, mem3:range(S) == Range];
pick_shards(undefined, Shard, undefined, undefined) when is_binary(Shard) ->
diff --git a/src/mem3/src/mem3_reshard_job.erl
b/src/mem3/src/mem3_reshard_job.erl
index 1819250..b254405 100644
--- a/src/mem3/src/mem3_reshard_job.erl
+++ b/src/mem3/src/mem3_reshard_job.erl
@@ -103,8 +103,12 @@ handle_cast(Cast, Job) ->
{noreply, Job}.
+handle_info(retry, #job{split_state = initial_copy} = Job) ->
+ % For initial copy before retrying make sure to reset the targets
+ % as initial copy works from newly created copy every time
+ handle_cast(do_state, reset_targets(Job));
+
handle_info(retry, #job{} = Job) ->
- couch_log:notice("~p retry timer expired ~p", [?MODULE, jobfmt(Job)]),
handle_cast(do_state, Job);
handle_info({'EXIT', Pid, Reason}, #job{workers = Workers} = Job) ->