FIX: Ensure we dispose of MiniRacer::Context before forking daemons (#28361)

This commit updates `Demon::Base#start` to call `Discourse.before_fork`
before forking. According to the docs in `mini_racer`, we need to
"Dispose manually of all MiniRacer::Context objects prior to forking".

This commit is motivated by a segmentation fault which we are seeing in
production when killing a daemon process. Backtrace of the core dump
includes traces of `mini_racer` so we think this is the cause. Note that
we are not 100% sure if this will fix the issue.
This commit is contained in:
Alan Guo Xiang Tan
2024-08-14 12:45:34 +08:00
committed by GitHub
parent e82e255531
commit 10ff0ee0cc
3 changed files with 18 additions and 9 deletions

View File

@ -154,6 +154,8 @@ class Demon::Base
end
def run
Discourse.before_fork if defined?(Discourse)
@pid =
fork do
Process.setproctitle("discourse #{self.class.prefix}")
@ -161,6 +163,7 @@ class Demon::Base
establish_app
after_fork
end
write_pid_file
end