summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorfloatingghost <hannah@coffee-and-dreams.uk>2022-07-14 13:35:33 +0200
committerIlja <ilja@ilja.space>2022-07-14 13:50:44 +0200
commit28626eafc174e6707ab4020f72a5550446730da9 (patch)
tree6723009b48275050d70ff1ec2153530df1c6a60e /lib
parent3fb9171694936e10114ba69a728256f5de792ecb (diff)
downloadpleroma-28626eafc174e6707ab4020f72a5550446730da9.tar.gz
pleroma-28626eafc174e6707ab4020f72a5550446730da9.zip
Allow higher amount of restarts for Pleroma.Repo during testing
This was done by floatingghost as part of a bigger commit in Akkoma. See <https://akkoma.dev/AkkomaGang/akkoma/src/commit/37ae047e1652c4089934434ec79f393c4c839122/lib/pleroma/application.ex#L83>. As explained in <https://ihatebeinga.live/objects/860d23e1-dc64-4b07-8b4d-020b9c56cff6> > there are so many caches that clearing them all can nuke the supervisor, which by default will become an hero if it gets more than 3 restarts in <5 seconds And further down the thread > essentially we've got like 11 caches (https://akkoma.dev/AkkomaGang/akkoma/src/commit/37ae047e1652c4089934434ec79f393c4c839122/lib/pleroma/application.ex#L165) > then in test we fetch them all (https://akkoma.dev/AkkomaGang/akkoma/src/branch/develop/test/support/data_case.ex#L50) and call clear on them > so if this clear fails on any 3 of them, the pleroma supervisor itself will die How it fails? > idk maybe cachex dies, maybe :ets does a weird thing > it doesn't log anything, it just consistently dies during cache clearing so i figured it had to be that > honestly my best bet is locksmith and queuing > https://github.com/whitfin/cachex/blob/master/lib/cachex/actions/clear.ex#L26 > clear is thrown into a locksmith transaction > locksmith says > >If the process is already in a transactional context, the provided function will be executed immediately. Otherwise the required keys will be locked until the provided function has finished executing. > so if we get 2 clears too close together, maybe it locks, then doesn't like the next clear?
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/application.ex12
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/pleroma/application.ex b/lib/pleroma/application.ex
index d808bc732..ae3ef9738 100644
--- a/lib/pleroma/application.ex
+++ b/lib/pleroma/application.ex
@@ -112,7 +112,17 @@ defmodule Pleroma.Application do
# See http://elixir-lang.org/docs/stable/elixir/Supervisor.html
# for other strategies and supported options
- opts = [strategy: :one_for_one, name: Pleroma.Supervisor]
+ # If we have a lot of caches, default max_restarts can cause test
+ # resets to fail.
+ # Go for the default 3 unless we're in test
+ max_restarts =
+ if @mix_env == :test do
+ 100
+ else
+ 3
+ end
+
+ opts = [strategy: :one_for_one, name: Pleroma.Supervisor, max_restarts: max_restarts]
result = Supervisor.start_link(children, opts)
set_postgres_server_version()