Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- Fix `TTIN` during a graceful shutdown spawning new workers.
- Prevent `USR1` from restarting the monitor during a graceful shutdown.
- Honor shutdown signals while the server is starting.
- Fix `max_consecutive_spawn_errors` counting a timed out spawn twice.
- Preserve worker spawn deadlines when the mold starts workers.

# 0.18.4
Expand Down
3 changes: 1 addition & 2 deletions lib/pitchfork/http_server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -617,9 +617,8 @@ def murder_lazy_workers
end

def hard_timeout(child)
@consecutive_spawn_errors += 1 unless child.ready?

if child.pid.nil? # Not yet registered, likely never spawned
@consecutive_spawn_errors += 1
logger.error "#{child.to_log} timed out during spawn, abandoning"
@children.abandon(child)
return
Expand Down
21 changes: 20 additions & 1 deletion test/integration/test_boot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def test_max_consecutive_spawn_timeout
pid = spawn_server(app: APP, config: <<~RUBY)
listen "#{addr}:#{port}"
worker_processes 3
max_consecutive_spawn_errors 4
max_consecutive_spawn_errors 2
spawn_timeout 1
after_worker_fork do |_server, worker|
sleep 20 # simulate a stuck worker
Expand All @@ -128,6 +128,25 @@ def test_max_consecutive_spawn_timeout
assert_exited(pid, 1)
end

def test_max_consecutive_spawn_timeout_counts_each_timeout_once
addr, port = unused_port

pid = spawn_server(app: APP, config: <<~RUBY)
listen "#{addr}:#{port}"
worker_processes 1
max_consecutive_spawn_errors 1
spawn_timeout 1
after_worker_fork do |_server, worker|
sleep 20
end
RUBY

assert_stderr(/consecutive failures to spawn children, aborting/, timeout: 6)
assert_exited(pid, 1)
before_abort = read_stderr.split("consecutive failures to spawn children, aborting").first
assert_equal 2, before_abort.scan(/worker=0 gen=0.0 pid=\d+ timed out, killing/).size
end

def test_max_consecutive_spawn_errors
addr, port = unused_port

Expand Down
Loading