couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnew...@apache.org
Subject [02/37] couch-replicator commit: updated refs/heads/master to aafb5f9
Date Thu, 28 Aug 2014 12:15:33 GMT
Send message asynchronusly from event manager

The replicator_manager was blocking for too long responding to
resume_scan events and causing general breakage.

BugzID: 17907


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

Branch: refs/heads/master
Commit: 8d03f0c59b4302ebd7765c3d8e899bf3ef150dc5
Parents: d809436
Author: Adam Kocoloski <adam@cloudant.com>
Authored: Thu Mar 7 16:48:29 2013 -0500
Committer: Robert Newson <rnewson@apache.org>
Committed: Tue Jul 29 12:38:39 2014 +0100

----------------------------------------------------------------------
 src/couch_replicator_manager.erl | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/blob/8d03f0c5/src/couch_replicator_manager.erl
----------------------------------------------------------------------
diff --git a/src/couch_replicator_manager.erl b/src/couch_replicator_manager.erl
index 949ceef..6afddd8 100644
--- a/src/couch_replicator_manager.erl
+++ b/src/couch_replicator_manager.erl
@@ -177,16 +177,6 @@ handle_call({rep_complete, RepId}, _From, State) ->
 handle_call({rep_error, RepId, Error}, _From, State) ->
     {reply, ok, replication_error(State, RepId, Error)};
 
-handle_call({resume_scan, DbName}, _From, State) ->
-    Since = case ets:lookup(?DB_TO_SEQ, DbName) of
-        [] -> 0;
-        [{DbName, EndSeq}] -> EndSeq
-    end,
-    ensure_rep_ddoc_exists(DbName),
-    Pid = changes_feed_loop(DbName, Since),
-    couch_log:debug("Scanning ~s from update_seq ~p", [DbName, Since]),
-    {reply, ok, State#state{rep_start_pids = [Pid | State#state.rep_start_pids]}};
-
 handle_call({rep_db_checkpoint, DbName, EndSeq}, _From, State) ->
     true = ets:insert(?DB_TO_SEQ, {DbName, EndSeq}),
     {reply, ok, State};
@@ -199,6 +189,16 @@ handle_call(Msg, From, State) ->
         [Msg, From]),
     {stop, {error, {unexpected_call, Msg}}, State}.
 
+handle_cast({resume_scan, DbName}, State) ->
+    Since = case ets:lookup(?DB_TO_SEQ, DbName) of
+        [] -> 0;
+        [{DbName, EndSeq}] -> EndSeq
+    end,
+    ensure_rep_ddoc_exists(DbName),
+    Pid = changes_feed_loop(DbName, Since),
+    couch_log:debug("Scanning ~s from update_seq ~p", [DbName, Since]),
+    {noreply, State#state{rep_start_pids = [Pid | State#state.rep_start_pids]}};
+
 handle_cast({set_max_retries, MaxRetries}, State) ->
     {noreply, State#state{max_retries = MaxRetries}};
 
@@ -320,7 +320,7 @@ db_update_notifier() ->
                     ensure_rep_ddoc_exists(DbName);
                 updated when IsRepDb ->
                     Msg = {resume_scan, DbName},
-                    ok = gen_server:call(Server, Msg, infinity);
+                    ok = gen_server:cast(Server, Msg);
                 deleted when IsRepDb ->
                     clean_up_replications(DbName);
                 _ ->
@@ -800,7 +800,7 @@ scan_all_dbs(Server) when is_pid(Server) ->
                 RelativeFilename -> ok
             end,
             DbName = ?l2b(filename:rootname(RelativeFilename, ".couch")),
-	    gen_server:call(Server, {resume_scan, DbName}),
+	    gen_server:cast(Server, {resume_scan, DbName}),
 	    ok
 	end, ok).
 


Mime
View raw message