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


The following commit(s) were added to refs/heads/retry-on-noproc-errors by this 
push:
     new a09f56de8 Retry call to dreyfus index on noproc errors
a09f56de8 is described below

commit a09f56de8f022f45fca5f96be4f9cd40c1153d47
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 | 43 ++++++++++++++++++++++++-----------------
 1 file changed, 25 insertions(+), 18 deletions(-)

diff --git a/src/dreyfus/src/dreyfus_rpc.erl b/src/dreyfus/src/dreyfus_rpc.erl
index 2ebc5ffe5..8caede38c 100644
--- a/src/dreyfus/src/dreyfus_rpc.erl
+++ b/src/dreyfus/src/dreyfus_rpc.erl
@@ -46,29 +46,36 @@ 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).

Reply via email to