Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cluster.rb - remove worker #dead?, #dead!, @dead #1927

Merged
merged 1 commit into from Aug 24, 2019

Conversation

MSP-Greg
Copy link
Member

@MSP-Greg MSP-Greg commented Aug 24, 2019

While working on PR #1908, I added a Worker method #term? to indicate whether Worker#term had been called. Also, previous code that rejected workers from the @workers array where dead? was true was removed.

At the time, I wondered what dead's purpose was. It was also bothersome that workers contain threads, and alive? is a thread method, and most would consider dead to be the inverse. Also, it's confusing, especially since code and comments in thread_pool.rb refer to dead_workers...

Upon reviewing the code, I cannot see anywhere where the state of Worker#dead? or @dead is used. It is set here on line 510:

puma/lib/puma/cluster.rb

Lines 503 to 512 in 9fb1228

if w = @workers.find { |x| x.pid == pid }
case req
when "b"
w.boot!
log "- Worker #{w.index} (pid: #{pid}) booted, phase: #{w.phase}"
force_check = true
when "t"
w.dead!
force_check = true
when "p"

This PR changes line 510 to 'w.term' and removes the two 'dead' methods. If this seems improper, the PR could be changed to call #term in Cluster#check_workers for any dead workers...

EDIT: This may also help intermittent test_integration.rb failures in macOS builds on Travis, which I've seen in my fork, as I can't test cluster locally..

@nateberkopec
Copy link
Member

This may also help intermittent test_integration.rb failures in macOS builds on Travis, which I've seen in my fork, as I can't test cluster locally..

welp, guess that didn't work

Screen Shot 2019-08-24 at 7 02 43 AM

I've notice the 2.4 one fails more often than the 2.5 one

@nateberkopec
Copy link
Member

Great catch, agreed that this is dead code.

@nateberkopec
Copy link
Member

Looks like it was added here 3fdf0c9 and the delete_if? dead has been removed at some point in the intervening years.

@nateberkopec nateberkopec merged commit 1046165 into puma:master Aug 24, 2019
@MSP-Greg MSP-Greg deleted the worker-remove-dead branch August 28, 2019 00:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants