couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject [1/4] couch-mrview commit: updated refs/heads/master to 853c608
Date Thu, 20 Oct 2016 16:45:44 GMT
Repository: couchdb-couch-mrview
Updated Branches:
  refs/heads/master d4509606f -> 853c60805


Retry failures in couch_mrview_compactor:recompact

Currently, if there's an error in the spawned couch_index_updater:update
process, the receive block will not match the message, and the calling
process will block forever.

This commit changes the receive pattern to match both successful updates
as well as errors, logging the errors, and retrying the recompact a
configurable number of times. If the configured retry count is exceeded,
it logs an error, and returns the original state.

COUCHDB-3184


Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/commit/1d5c6a5d
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/tree/1d5c6a5d
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/diff/1d5c6a5d

Branch: refs/heads/master
Commit: 1d5c6a5d92977308fd94b2b8f43463b9f2bdac71
Parents: d450960
Author: Jay Doane <jay.s.doane@gmail.com>
Authored: Fri Oct 7 13:04:13 2016 -0700
Committer: Jay Doane <jay.s.doane@gmail.com>
Committed: Fri Oct 7 13:04:13 2016 -0700

----------------------------------------------------------------------
 src/couch_mrview_compactor.erl | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/blob/1d5c6a5d/src/couch_mrview_compactor.erl
----------------------------------------------------------------------
diff --git a/src/couch_mrview_compactor.erl b/src/couch_mrview_compactor.erl
index 9dba094..d5ea763 100644
--- a/src/couch_mrview_compactor.erl
+++ b/src/couch_mrview_compactor.erl
@@ -26,6 +26,7 @@
    total_changes
 }).
 
+-define(DEFAULT_RECOMPACT_RETRY_COUNT, 3).
 
 compact(_Db, State, Opts) ->
     case lists:member(recompact, Opts) of
@@ -148,14 +149,30 @@ compact(State) ->
 
 
 recompact(State) ->
+    RetryCount = config:get_integer("view_compaction", "recompact_retry_count",
+        ?DEFAULT_RECOMPACT_RETRY_COUNT),
+    recompact(State, RetryCount).
+
+recompact(State, 0) ->
+    couch_log:error("couch_mrview_compactor:recompact max retries exceeded ~p",
+        [State]),
+    {ok, State};
+recompact(State, Attempt) ->
     link(State#mrst.fd),
     {Pid, Ref} = erlang:spawn_monitor(fun() ->
         couch_index_updater:update(couch_mrview_index, State)
     end),
     receive
-        {'DOWN', Ref, _, _, {updated, Pid, State2}} ->
+        {'DOWN', Ref, _, _, Result} ->
             unlink(State#mrst.fd),
-            {ok, State2}
+            case Result of
+                {updated, Pid, State2} ->
+                    {ok, State2};
+                Error ->
+                    couch_log:info("couch_mrview_compactor:recompact error ~p",
+                        [Error]),
+                    recompact(State, Attempt - 1)
+            end
     end.
 
 compact_log(LogBtree, BufferSize, Acc0) ->


Mime
View raw message