rnewson commented on code in PR #5469:
URL: https://github.com/apache/couchdb/pull/5469#discussion_r1990098732


##########
src/nouveau/src/nouveau_api.erl:
##########
@@ -318,15 +318,34 @@ send_if_enabled(Url, Header, Method, Body) ->
 send_if_enabled(Url, Header, Method, Body, Options) ->
     case nouveau:enabled() of
         true ->
-            ibrowse:send_req(Url, Header, Method, Body, Options);
+            retry_if_connection_closes(fun() ->
+                ibrowse:send_req(Url, Header, Method, Body, Options)
+            end);
         false ->
             {error, nouveau_not_enabled}
     end.
 
 send_direct_if_enabled(ConnPid, Url, Header, Method, Body, Options) ->
     case nouveau:enabled() of
         true ->
-            ibrowse:send_req_direct(ConnPid, Url, Header, Method, Body, 
Options);
+            retry_if_connection_closes(fun() ->
+                ibrowse:send_req_direct(ConnPid, Url, Header, Method, Body, 
Options)
+            end);
         false ->
             {error, nouveau_not_enabled}
     end.
+
+retry_if_connection_closes(Fun) ->
+    MaxRetries = max(1, config:get_integer("nouveau", "max_retries", 5)),
+    retry_if_connection_closes(Fun, MaxRetries).
+
+retry_if_connection_closes(_Fun, 0) ->
+    {error, connection_closed};

Review Comment:
   I should also note that for the motivating case where nouveau/dropwizard has 
already closed the connection and we mistakenly send a request anyway, the 
'retry' will actually be the first time we try the index-modifying request as 
the first attempt didn't get processed, so I don't expect to see index updaters 
crashing anyway.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to