Add utility function to return infinite timeout for SQL transactions if we detect...
authorMark Felder <feld@feld.me>
Tue, 20 Apr 2021 16:10:39 +0000 (11:10 -0500)
committerMark Felder <feld@feld.me>
Thu, 22 Apr 2021 15:15:50 +0000 (10:15 -0500)
lib/pleroma/utils.ex

index bc0c953322338b347316b5414f4d3f36b78cfffb..5e2fa8bf7d27d1b88783e602e9057aba4ffeaedb 100644 (file)
@@ -63,4 +63,13 @@ defmodule Pleroma.Utils do
   end
 
   def posix_error_message(_), do: ""
+
+  def query_timeout do
+    {parent, _, _, _} = Process.info(self(), :current_stacktrace) |> elem(1) |> Enum.fetch!(2)
+
+    cond do
+      parent |> to_string |> String.starts_with?("Elixir.Mix.Task") -> [timeout: :infinity]
+      true -> [timeout: 15_000]
+    end
+  end
 end