couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject [08/19] couch-replicator commit: updated refs/heads/COUCHDB-3288-remove-public-db-record to a8ac02d
Date Tue, 04 Apr 2017 21:17:41 GMT
Revert "Restore adding some jitter-ed sleep to shard scanning code."

This reverts commit 45d739af3fcf8b4f8e3ccca152cb3c2d781dc2fc.


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/1e413b8a
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/tree/1e413b8a
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/diff/1e413b8a

Branch: refs/heads/COUCHDB-3288-remove-public-db-record
Commit: 1e413b8afa6eb156eb5293d1dc0d5726cd5063fc
Parents: 45d739a
Author: Robert Newson <rnewson@apache.org>
Authored: Wed Mar 1 11:15:55 2017 +0000
Committer: Robert Newson <rnewson@apache.org>
Committed: Wed Mar 1 11:15:55 2017 +0000

----------------------------------------------------------------------
 src/couch_replicator_manager.erl | 74 +++++++----------------------------
 1 file changed, 14 insertions(+), 60 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/blob/1e413b8a/src/couch_replicator_manager.erl
----------------------------------------------------------------------
diff --git a/src/couch_replicator_manager.erl b/src/couch_replicator_manager.erl
index 4e5073e..bdc3b8f 100644
--- a/src/couch_replicator_manager.erl
+++ b/src/couch_replicator_manager.erl
@@ -934,30 +934,22 @@ scan_all_dbs(Server) when is_pid(Server) ->
     {ok, Db} = mem3_util:ensure_exists(
         config:get("mem3", "shards_db", "_dbs")),
     ChangesFun = couch_changes:handle_changes(#changes_args{}, nil, Db, nil),
-    ChangesFun({fun scan_changes_cb/3, {Server, 1}}),
+    ChangesFun(fun({change, {Change}, _}, _) ->
+        DbName = couch_util:get_value(<<"id">>, Change),
+        case DbName of <<"_design/", _/binary>> -> ok; _Else ->
+            case couch_replicator_utils:is_deleted(Change) of
+            true ->
+                ok;
+            false ->
+                [gen_server:cast(Server, {resume_scan, ShardName})
+                    || ShardName <- replicator_shards(DbName)],
+                ok
+            end
+        end;
+        (_, _) -> ok
+    end),
     couch_db:close(Db).
 
-scan_changes_cb({change, {Change}, _}, _, {Server, AccCount}) ->
-    DbName = couch_util:get_value(<<"id">>, Change),
-    case DbName of <<"_design/", _/binary>> -> {Server, AccCount}; _Else ->
-        case couch_replicator_utils:is_deleted(Change) of
-        true ->
-            {Server, AccCount};
-        false ->
-            UpdatedCount = lists:foldl(fun(ShardName, Count) ->
-                spawn_link(fun() ->
-                    timer:sleep(jitter(Count)),
-                    gen_server:cast(Server, {resume_scan, ShardName})
-                end),
-                Count + 1
-           end, AccCount, replicator_shards(DbName)),
-           {Server, UpdatedCount}
-        end
-    end;
-
-scan_changes_cb(_, _, {Server, AccCount}) ->
-    {Server, AccCount}.
-
 
 replicator_shards(DbName) ->
     case is_replicator_db(DbName) of
@@ -1035,42 +1027,4 @@ t_fail_non_replicator_shard() ->
     end).
 
 
-scan_dbs_test_() ->
-{
-      foreach,
-      fun() -> test_util:start_couch([mem3, fabric]) end,
-      fun(Ctx) -> test_util:stop_couch(Ctx) end,
-      [
-          t_resume_db_shard(),
-          t_sleep_based_on_count()
-     ]
-}.
-
-
-t_resume_db_shard() ->
-    ?_test(begin
-        DbName0 = ?tempdb(),
-        DbName = <<DbName0/binary, "/_replicator">>,
-        ok = fabric:create_db(DbName, [?CTX]),
-        Change = {[{<<"id">>, DbName}]},
-        scan_changes_cb({change, Change, req}, type, {self(), 1}),
-        ResumeMsg = receive Msg -> Msg after 1000 -> timeout end,
-        ?assertMatch({'$gen_cast', {resume_scan, <<"shards/", _/binary>>}}, ResumeMsg),
-        fabric:delete_db(DbName, [?CTX])
-    end).
-
-
-t_sleep_based_on_count() ->
-    ?_test(begin
-        DbName0 = ?tempdb(),
-        DbName = <<DbName0/binary, "/_replicator">>,
-        ok = fabric:create_db(DbName, [?CTX]),
-        Change = {[{<<"id">>, DbName}]},
-        scan_changes_cb({change, Change, req}, type, {self(), 1000}),
-        Timeout = receive Msg -> Msg after 100 -> timeout end,
-        ?assertEqual(timeout, Timeout),
-        fabric:delete_db(DbName, [?CTX])
-    end).
-
-
 -endif.


Mime
View raw message