diff options
author | Eric Avdey <eiri@eiri.ca> | 2017-04-03 15:05:07 -0300 |
---|---|---|
committer | Jay Doane <jay.s.doane@gmail.com> | 2017-04-19 11:23:16 -0700 |
commit | 80963ca3e4469e65bbc12d917c3e6dd8b5e32e1d (patch) | |
tree | 6e516c49b411973e434ae793a93704a1555ca232 | |
parent | 778738b1b61dbb559a0ecc2acdd8720a02cc7ec8 (diff) | |
download | couchdb-80963ca3e4469e65bbc12d917c3e6dd8b5e32e1d.tar.gz |
Don't crash compactor when compacting process fails
-rw-r--r-- | src/couch_index/src/couch_index.erl | 12 | ||||
-rw-r--r-- | src/couch_index/src/couch_index_compactor.erl | 8 |
2 files changed, 19 insertions, 1 deletions
diff --git a/src/couch_index/src/couch_index.erl b/src/couch_index/src/couch_index.erl index b339010a6..c86f5e122 100644 --- a/src/couch_index/src/couch_index.erl +++ b/src/couch_index/src/couch_index.erl @@ -192,7 +192,17 @@ handle_call({compacted, NewIdxState}, _From, State) -> end; false -> {reply, ok, commit_compacted(NewIdxState, State)} - end. + end; +handle_call({compaction_failed, Reason}, _From, State) -> + #st{ + mod = Mod, + idx_state = OldIdxState, + waiters = Waiters + } = State, + send_all(Waiters, Reason), + {ok, NewIdxState} = Mod:remove_compacted(OldIdxState), + NewState = State#st{idx_state = NewIdxState, waiters = []}, + {reply, {ok, NewIdxState}, NewState}. handle_cast({trigger_update, UpdateSeq}, State) -> #st{ diff --git a/src/couch_index/src/couch_index_compactor.erl b/src/couch_index/src/couch_index_compactor.erl index b5db058a5..106a02b33 100644 --- a/src/couch_index/src/couch_index_compactor.erl +++ b/src/couch_index/src/couch_index_compactor.erl @@ -81,6 +81,14 @@ handle_cast(_Mesg, State) -> handle_info({'EXIT', Pid, normal}, #st{pid=Pid}=State) -> {noreply, State#st{pid=undefined}}; +handle_info({'EXIT', Pid, Reason}, #st{pid = Pid} = State) -> + #st{idx = Idx, mod = Mod} = State, + {ok, IdxState} = gen_server:call(Idx, {compaction_failed, Reason}), + DbName = Mod:get(db_name, IdxState), + IdxName = Mod:get(idx_name, IdxState), + Args = [DbName, IdxName, Reason], + couch_log:error("Compaction failed for db: ~s idx: ~s reason: ~p", Args), + {noreply, State#st{pid = undefined}}; handle_info({'EXIT', _Pid, normal}, State) -> {noreply, State}; handle_info({'EXIT', Pid, _Reason}, #st{idx=Pid}=State) -> |