Merge branch 'mediaproxy-decode' into 'develop'
[akkoma] / lib / pleroma / application_requirements.ex
index b977257a388ec40fe0560e770451c067492a077a..6ef65b263e7d5e542c4fe5c8c1a9b282ee828a59 100644 (file)
@@ -1,5 +1,5 @@
 # Pleroma: A lightweight social networking server
-# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
+# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
 # SPDX-License-Identifier: AGPL-3.0-only
 
 defmodule Pleroma.ApplicationRequirements do
@@ -24,6 +24,7 @@ defmodule Pleroma.ApplicationRequirements do
     |> check_migrations_applied!()
     |> check_welcome_message_config!()
     |> check_rum!()
+    |> check_repo_pool_size!()
     |> handle_result()
   end
 
@@ -188,6 +189,30 @@ defmodule Pleroma.ApplicationRequirements do
 
   defp check_system_commands!(result), do: result
 
+  defp check_repo_pool_size!(:ok) do
+    if Pleroma.Config.get([Pleroma.Repo, :pool_size], 10) != 10 and
+         not Pleroma.Config.get([:dangerzone, :override_repo_pool_size], false) do
+      Logger.error("""
+      !!!CONFIG WARNING!!!
+
+      The database pool size has been altered from the recommended value of 10.
+
+      Please revert or ensure your database is tuned appropriately and then set
+      `config :pleroma, :dangerzone, override_repo_pool_size: true`.
+
+      If you are experiencing database timeouts, please check the "Optimizing
+      your PostgreSQL performance" section in the documentation. If you still
+      encounter issues after that, please open an issue on the tracker.
+      """)
+
+      {:error, "Repo.pool_size different than recommended value."}
+    else
+      :ok
+    end
+  end
+
+  defp check_repo_pool_size!(result), do: result
+
   defp check_filter(filter, command_required) do
     filters = Config.get([Pleroma.Upload, :filters])