Github user davisp commented on the issue:

    https://github.com/apache/couchdb-couch-mrview/pull/58
  
    That's the general idea, though there was a bit I wanted to add using the 
update/3 so that we know if the updater is making progress between failures. I 
typed up a quick thing but haven't tried compiling it or anything crazy like 
that.
    
    ```diff
    diff --git a/src/couch_mrview_compactor.erl b/src/couch_mrview_compactor.erl
    index 9dba094..3271103 100644
    --- a/src/couch_mrview_compactor.erl
    +++ b/src/couch_mrview_compactor.erl
    @@ -148,14 +148,31 @@ compact(State) ->
     
     
     recompact(State) ->
    +    recompact(State, recompact_retry_count()).
    +
    +recompact(State, 0) ->
    +    erlang:error(exceeded_recompact_retry_count);
    +
    +recompact(State, RetryCount) ->
    +    Self = self(),
         link(State#mrst.fd),
         {Pid, Ref} = erlang:spawn_monitor(fun() ->
    -        couch_index_updater:update(couch_mrview_index, State)
    +        couch_index_updater:update(Self, couch_mrview_index, State)
         end),
    +    recompact_loop(State, RetryCount).
    +
    +recompact_loop(State, RetryCount) ->
         receive
    +        {'$gen_cast', {new_state, State}} ->
    +            % We've made progress so reset RetryCount
    +            recompact_loop(State, recompact_retry_count());
             {'DOWN', Ref, _, _, {updated, Pid, State2}} ->
                 unlink(State#mrst.fd),
    -            {ok, State2}
    +            {ok, State2};
    +        {'DOWN', Ref, _, _, Reason} ->
    +            unlink(State#mrst.fd),
    +            couch_log:warning("Error durring recompaction: ~r", [Reason]),
    +            recompact(State, RetryCount - 1)
         end.
     
     compact_log(LogBtree, BufferSize, Acc0) ->
    @@ -265,3 +282,11 @@ swap_compacted(OldState, NewState) ->
         erlang:demonitor(OldState#mrst.fd_monitor, [flush]),
         
         {ok, NewState#mrst{fd_monitor=Ref}}.
    +
    +
    +recompact_retry_count() ->
    +    config:get_integer(
    +        "view_compaction",
    +        "recompact_retry_count",
    +        ?DEFAULT_RECOMPACT_RETRY_COUNT
    +    ).
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to