You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by fd...@apache.org on 2011/08/29 09:25:15 UTC
svn commit: r1162663 - in /couchdb/trunk/src/couchdb: couch_replicator.erl
couch_replicator_worker.erl
Author: fdmanana
Date: Mon Aug 29 07:25:15 2011
New Revision: 1162663
URL: http://svn.apache.org/viewvc?rev=1162663&view=rev
Log:
Make replicator report_seq_done call synchronous
On environments with an incredibly slow network, this
was making the main gen_server's mailbox very big when
there's a high number of workers (8 or more).
Modified:
couchdb/trunk/src/couchdb/couch_replicator.erl
couchdb/trunk/src/couchdb/couch_replicator_worker.erl
Modified: couchdb/trunk/src/couchdb/couch_replicator.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_replicator.erl?rev=1162663&r1=1162662&r2=1162663&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_replicator.erl (original)
+++ couchdb/trunk/src/couchdb/couch_replicator.erl Mon Aug 29 07:25:15 2011
@@ -336,35 +336,7 @@ handle_info({'EXIT', Pid, Reason}, #rep_
end.
-handle_call(Msg, _From, State) ->
- ?LOG_ERROR("Replicator received an unexpected synchronous call: ~p", [Msg]),
- {stop, unexpected_sync_message, State}.
-
-
-handle_cast({db_compacted, DbName},
- #rep_state{source = #db{name = DbName} = Source} = State) ->
- {ok, NewSource} = couch_db:reopen(Source),
- {noreply, State#rep_state{source = NewSource}};
-
-handle_cast({db_compacted, DbName},
- #rep_state{target = #db{name = DbName} = Target} = State) ->
- {ok, NewTarget} = couch_db:reopen(Target),
- {noreply, State#rep_state{target = NewTarget}};
-
-handle_cast(checkpoint, State) ->
- case do_checkpoint(State) of
- {ok, NewState} ->
- {noreply, NewState#rep_state{timer = start_timer(State)}};
- Error ->
- {stop, Error, State}
- end;
-
-handle_cast({report_seq, Seq},
- #rep_state{seqs_in_progress = SeqsInProgress} = State) ->
- NewSeqsInProgress = ordsets:add_element(Seq, SeqsInProgress),
- {noreply, State#rep_state{seqs_in_progress = NewSeqsInProgress}};
-
-handle_cast({report_seq_done, Seq, StatsInc},
+handle_call({report_seq_done, Seq, StatsInc}, _From,
#rep_state{seqs_in_progress = SeqsInProgress, highest_seq_done = HighestDone,
current_through_seq = ThroughSeq, stats = Stats} = State) ->
{NewThroughSeq0, NewSeqsInProgress} = case SeqsInProgress of
@@ -396,7 +368,35 @@ handle_cast({report_seq_done, Seq, Stats
highest_seq_done = NewHighestDone,
source_seq = SourceCurSeq
},
- {noreply, NewState};
+ {reply, ok, NewState};
+
+handle_call(Msg, _From, State) ->
+ ?LOG_ERROR("Replicator received an unexpected synchronous call: ~p", [Msg]),
+ {stop, unexpected_sync_message, State}.
+
+
+handle_cast({db_compacted, DbName},
+ #rep_state{source = #db{name = DbName} = Source} = State) ->
+ {ok, NewSource} = couch_db:reopen(Source),
+ {noreply, State#rep_state{source = NewSource}};
+
+handle_cast({db_compacted, DbName},
+ #rep_state{target = #db{name = DbName} = Target} = State) ->
+ {ok, NewTarget} = couch_db:reopen(Target),
+ {noreply, State#rep_state{target = NewTarget}};
+
+handle_cast(checkpoint, State) ->
+ case do_checkpoint(State) of
+ {ok, NewState} ->
+ {noreply, NewState#rep_state{timer = start_timer(State)}};
+ Error ->
+ {stop, Error, State}
+ end;
+
+handle_cast({report_seq, Seq},
+ #rep_state{seqs_in_progress = SeqsInProgress} = State) ->
+ NewSeqsInProgress = ordsets:add_element(Seq, SeqsInProgress),
+ {noreply, State#rep_state{seqs_in_progress = NewSeqsInProgress}};
handle_cast({add_stats, StatsInc}, #rep_state{stats = Stats} = State) ->
{noreply, State#rep_state{stats = sum_stats([Stats, StatsInc])}};
Modified: couchdb/trunk/src/couchdb/couch_replicator_worker.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_replicator_worker.erl?rev=1162663&r1=1162662&r2=1162663&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_replicator_worker.erl (original)
+++ couchdb/trunk/src/couchdb/couch_replicator_worker.erl Mon Aug 29 07:25:15 2011
@@ -251,7 +251,7 @@ queue_fetch_loop(Source, Target, Parent,
Stats2 = Stats#rep_stats{
missing_checked = Stats#rep_stats.missing_checked + NotMissingCount
},
- ok = gen_server:cast(Cp, {report_seq_done, ReportSeq, Stats2}),
+ ok = gen_server:call(Cp, {report_seq_done, ReportSeq, Stats2}, infinity),
?LOG_DEBUG("Worker reported completion of seq ~p", [ReportSeq]),
queue_fetch_loop(Source, Target, Parent, Cp, ChangesManager)
end.