You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ch...@apache.org on 2014/08/28 19:30:08 UTC
[08/50] [abbrv] couch-replicator commit: updated
refs/heads/1963-eunit-bigcouch to 3cf0b13
Fix a non-tail-recursive call that leaks memory
By recursing in the protected body of a try/catch we weren't properly
using tail recursion when restarting the changes feed. This leads to
mailbox accumulation of messages which slowly eats all RAM on the node.
BugzId: 20601
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/44328a6c
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/tree/44328a6c
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/diff/44328a6c
Branch: refs/heads/1963-eunit-bigcouch
Commit: 44328a6cca9686334acc2932b3a46ccc780f2322
Parents: 20b837e
Author: Paul J. Davis <pa...@gmail.com>
Authored: Mon Jul 8 14:49:41 2013 -0500
Committer: Robert Newson <rn...@apache.org>
Committed: Tue Jul 29 13:48:38 2014 +0100
----------------------------------------------------------------------
src/couch_replicator.erl | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/blob/44328a6c/src/couch_replicator.erl
----------------------------------------------------------------------
diff --git a/src/couch_replicator.erl b/src/couch_replicator.erl
index 3ef5e9c..bb81cf0 100644
--- a/src/couch_replicator.erl
+++ b/src/couch_replicator.erl
@@ -665,7 +665,7 @@ read_changes(Parent, StartSeq, Db, ChangesQueue, Options, Ts) ->
ok = gen_server:call(Parent, Msg, infinity)
end,
put(last_seq, Seq),
- read_changes(Parent, Seq, Db, ChangesQueue, Options, Ts + 1);
+ throw(recurse);
_ ->
% This clause is unreachable today, but let's plan ahead
% for the future where we checkpoint against last_seq
@@ -675,7 +675,11 @@ read_changes(Parent, StartSeq, Db, ChangesQueue, Options, Ts) ->
end
end, Options),
couch_work_queue:close(ChangesQueue)
- catch exit:{http_request_failed, _, _, _} = Error ->
+ catch
+ throw:recurse ->
+ LS = get(last_seq),
+ read_changes(Parent, LS, Db, ChangesQueue, Options, Ts+1);
+ exit:{http_request_failed, _, _, _} = Error ->
case get(retries_left) of
N when N > 0 ->
put(retries_left, N - 1),