mirror of
https://github.com/discourse/discourse.git
synced 2024-12-19 07:03:47 +08:00
DEV: Fix duplicated logging of unicorn worker backtraces (#30178)
In 6cafe59c76
, we added a monkey patch to
`Unicorn::HtppServer#murder_lazy_workers` to log a message and send a
`USR2` signal to the Unicorn worker process when they Unicorn worker
process is 2 seconds away from being timed out by the Unicorn master
process. However, we ended up loggging multiple messages and sending
multiple USR2 signal during the 2 seconds before the Unicorn worker
process hit the time out.
To overcome this problem, we will now set an instance variable on the
`Unicorn::Worker` instance and use it to ensure that the log message is
only logged once and USR2 signal to the Unicorn worker process is only
sent one as well.
This commit is contained in:
parent
1670ffe82d
commit
2f65f36cae
|
@ -131,9 +131,12 @@ before_fork do |server, worker|
|
||||||
tmp = @timeout - diff
|
tmp = @timeout - diff
|
||||||
|
|
||||||
# START MONKEY PATCH
|
# START MONKEY PATCH
|
||||||
if tmp < 2
|
if tmp < 2 && !worker.instance_variable_get(:@timing_out_logged)
|
||||||
logger.error "worker=#{worker.nr} PID:#{wpid} running too long " \
|
logger.error do
|
||||||
"(#{diff}s), sending USR2 to dump thread backtraces"
|
"worker=#{worker.nr} PID:#{wpid} running too long (#{diff}s), sending USR2 to dump thread backtraces"
|
||||||
|
end
|
||||||
|
|
||||||
|
worker.instance_variable_set(:@timing_out_logged, true)
|
||||||
kill_worker(:USR2, wpid)
|
kill_worker(:USR2, wpid)
|
||||||
end
|
end
|
||||||
# END MONKEY PATCH
|
# END MONKEY PATCH
|
||||||
|
|
Loading…
Reference in New Issue
Block a user