more info in Connections.checkin timout errors
[akkoma] / lib / pleroma / http / adapter / gun.ex
index ec6475e96aaa0ceecbebd0bb2e06f9070730242c..fc40b324a748b2b23942c4bf6e9df1857ba41ea7 100644 (file)
@@ -15,7 +15,7 @@ defmodule Pleroma.HTTP.Adapter.Gun do
     connect_timeout: 20_000,
     domain_lookup_timeout: 5_000,
     tls_handshake_timeout: 5_000,
-    retry_timeout: 100,
+    retry0,
     await_up_timeout: 5_000
   ]
 
@@ -89,7 +89,7 @@ defmodule Pleroma.HTTP.Adapter.Gun do
     try do
       case Connections.checkin(uri, :gun_connections) do
         nil ->
-          Logger.info(
+          Logger.debug(
             "Gun connections pool checkin was not successful. Trying to open conn for next request."
           )
 
@@ -97,7 +97,9 @@ defmodule Pleroma.HTTP.Adapter.Gun do
           opts
 
         conn when is_pid(conn) ->
-          Logger.debug("received conn #{inspect(conn)} #{Connections.compose_uri(uri)}")
+          Logger.debug(
+            "received conn #{inspect(conn)} #{uri.scheme}://#{Connections.compose_uri(uri)}"
+          )
 
           opts
           |> Keyword.put(:conn, conn)
@@ -105,18 +107,35 @@ defmodule Pleroma.HTTP.Adapter.Gun do
       end
     rescue
       error ->
-        Logger.warn("Gun connections pool checkin caused error #{inspect(error)}")
+        Logger.warn(
+          "Gun connections pool checkin caused error #{uri.scheme}://#{
+            Connections.compose_uri(uri)
+          } #{inspect(error)}"
+        )
+
         opts
     catch
-      :exit, {:timeout, _} ->
-        Logger.info(
-          "Gun connections pool checkin with timeout error #{Connections.compose_uri(uri)}"
+      :exit, {:timeout, {_, operation, [_, {method, _}, _]}} ->
+        messages_len =
+          :gun_connections
+          |> Process.whereis()
+          |> Process.info(:message_queue_len)
+
+        Logger.warn(
+          "Gun connections pool checkin with timeout error for #{operation} #{method} #{
+            uri.scheme
+          }://#{Connections.compose_uri(uri)}. Messages length: #{messages_len}"
         )
 
         opts
 
       :exit, error ->
-        Logger.warn("Gun pool checkin exited with error #{inspect(error)}")
+        Logger.warn(
+          "Gun pool checkin exited with error #{uri.scheme}://#{Connections.compose_uri(uri)} #{
+            inspect(error)
+          }"
+        )
+
         opts
     end
   end