This is an automated email from the ASF dual-hosted git repository. iilyak pushed a commit to branch retry-on-noproc-errors in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit 87efd9c5cd02be6d6ef69394987d5807da874543 Author: ILYA Khlopotov <[email protected]> AuthorDate: Wed Sep 10 10:54:42 2025 -0700 Retry call to dreyfus index on noproc errors --- src/dreyfus/src/dreyfus_rpc.erl | 44 ++++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/src/dreyfus/src/dreyfus_rpc.erl b/src/dreyfus/src/dreyfus_rpc.erl index 2ebc5ffe5..6638b0e51 100644 --- a/src/dreyfus/src/dreyfus_rpc.erl +++ b/src/dreyfus/src/dreyfus_rpc.erl @@ -46,29 +46,37 @@ call(Fun, DbName, DDoc, IndexName, QueryArgs0) -> {_LastSeq, MinSeq} = calculate_seqs(Db, Stale), case dreyfus_index:design_doc_to_index(DDoc, IndexName) of {ok, Index} -> - case dreyfus_index_manager:get_index(DbName, Index) of - {ok, Pid} -> - case dreyfus_index:await(Pid, MinSeq) of - {ok, IndexPid, _Seq} -> - Result = dreyfus_index:Fun(IndexPid, QueryArgs), - rexi:reply(Result); - % obsolete clauses, remove after upgrade - ok -> - Result = dreyfus_index:Fun(Pid, QueryArgs), - rexi:reply(Result); - {ok, _Seq} -> - Result = dreyfus_index:Fun(Pid, QueryArgs), - rexi:reply(Result); - Error -> - rexi:reply(Error) - end; - Error -> - rexi:reply(Error) + try + rexi:reply(index_call(Fun, DbName, Index, QueryArgs, MinSeq)) + catch + exit:{noproc, _} -> + couch_log:error("Got NOPROC, re-trying", []), + %% try one more time to handle the case when Clouseau's LRU + %% closed the index in the middle of our call + rexi:reply(index_call(Fun, DbName, Index, QueryArgs, MinSeq)) end; Error -> rexi:reply(Error) end. +index_call(Fun, DbName, Index, QueryArgs, MinSeq) -> + case dreyfus_index_manager:get_index(DbName, Index) of + {ok, Pid} -> + case dreyfus_index:await(Pid, MinSeq) of + {ok, IndexPid, _Seq} -> + dreyfus_index:Fun(IndexPid, QueryArgs); + % obsolete clauses, remove after upgrade + ok -> + dreyfus_index:Fun(Pid, QueryArgs); + {ok, _Seq} -> + dreyfus_index:Fun(Pid, QueryArgs); + Error -> + Error + end; + Error -> + Error + end. + info(DbName, DDoc, IndexName) -> MFA = {?MODULE, info_int, [DbName, DDoc, IndexName]}, dreyfus_util:time([rpc, info], MFA).
