Skip to content

Fix phase check race condition in Puma::Cluster#check_workers#3690

Merged
joshuay03 merged 2 commits intopuma:mainfrom
joshuay03:fix-check-workers-phase-race-condition
Nov 17, 2025
Merged

Fix phase check race condition in Puma::Cluster#check_workers#3690
joshuay03 merged 2 commits intopuma:mainfrom
joshuay03:fix-check-workers-phase-race-condition

Conversation

@joshuay03
Copy link
Copy Markdown
Collaborator

Extracts some code from #3602. Namely:

Comment on lines +495 to +508
def test_application_is_loaded_exactly_once_if_using_fork_worker
cli_server "-w #{workers} --fork-worker test/rackup/write_to_stdout_on_boot.ru"

get_worker_pids
loading_app_count = @server_log.scan("Loading app").length
assert_equal 1, loading_app_count # loaded in worker 0

@server_log.clear
Process.kill :SIGURG, @pid

get_worker_pids 1, workers - 1
loading_app_count = @server_log.scan("Loading app").length
assert_equal 0, loading_app_count
end
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's an intermittent test failure when running this consecutively locally without the patch:

puma [fix-check-workers-phase-race-condition] bundle exec m test/test_integration_cluster.rb:495
Run options: -n "/^(test_application_is_loaded_exactly_once_if_using_fork_worker)$/" --seed 33914

# Running:

.

Fabulous run in 5.410711s, 0.1848 runs/s, 0.5545 assertions/s.

1 runs, 3 assertions, 0 failures, 0 errors, 0 skips

puma [fix-check-workers-phase-race-condition] bundle exec m test/test_integration_cluster.rb:495
Run options: -n "/^(test_application_is_loaded_exactly_once_if_using_fork_worker)$/" --seed 50616

# Running:

.

Fabulous run in 5.389803s, 0.1855 runs/s, 0.5566 assertions/s.

1 runs, 3 assertions, 0 failures, 0 errors, 0 skips

puma [fix-check-workers-phase-race-condition] bundle exec m test/test_integration_cluster.rb:495
Run options: -n "/^(test_application_is_loaded_exactly_once_if_using_fork_worker)$/" --seed 58475

# Running:

F

Fabulous run in 5.397754s, 0.1853 runs/s, 0.5558 assertions/s.
Errors & Failures:

  1) Failure:
TestIntegrationCluster#test_application_is_loaded_exactly_once_if_using_fork_worker [test/test_integration_cluster.rb:507]:
Expected: 0
  Actual: 1

1 runs, 3 assertions, 1 failures, 0 errors, 0 skips

Copy link
Copy Markdown
Collaborator Author

@joshuay03 joshuay03 Aug 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've pushed the patch, we shouldn't see any failures now: https://github.com/puma/puma/actions/runs/16876978063

@joshuay03 joshuay03 marked this pull request as ready for review August 11, 2025 09:59
@joshuay03 joshuay03 moved this to In Progress / Pending Review in Open Source Aug 11, 2025
@joshuay03 joshuay03 moved this from In Progress / Pending Review to Done in Open Source Aug 11, 2025
@joshuay03 joshuay03 moved this from Done to In Progress / Pending Review in Open Source Aug 11, 2025
@github-actions github-actions bot added the waiting-for-review Waiting on review from anyone label Aug 11, 2025
@joshuay03 joshuay03 force-pushed the fix-check-workers-phase-race-condition branch from 280038a to 2e06134 Compare August 11, 2025 10:07
@MSP-Greg MSP-Greg added the bug label Oct 11, 2025
@schneems
Copy link
Copy Markdown
Member

I just swapped the default branch name from master to main, you don't need to do anything for this PR. You'll need to update your local environment accordingly:

$ git fetch && git checkout main

When you rebase in the future, use main instead of master. (posting this to all open PRs)

@joshuay03 joshuay03 removed the waiting-for-review Waiting on review from anyone label Nov 17, 2025
@joshuay03 joshuay03 force-pushed the fix-check-workers-phase-race-condition branch from 2e06134 to 0211c91 Compare November 17, 2025 15:35
@github-actions github-actions bot added the waiting-for-review Waiting on review from anyone label Nov 17, 2025
@joshuay03 joshuay03 removed the waiting-for-review Waiting on review from anyone label Nov 17, 2025
@joshuay03
Copy link
Copy Markdown
Collaborator Author

Merging as I've been able to validate the fix locally and via CI, both here and in the PR this was extracted from.

@joshuay03 joshuay03 merged commit a03372c into puma:main Nov 17, 2025
142 checks passed
@joshuay03 joshuay03 moved this from In Progress / Pending Review to Done in Open Source Nov 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants