after_fork_parent method waits for all child processes to stop

Đang mở
#1,099 3 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
45/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
ruby
Lĩnh vực
devtools

Hướng nghiên cứu

Start at lib/debug/local.rb lines 106-107 and inspect after_fork_parent, then reproduce the behavior with the Gemfile and test_daemon.rb example using daemons. Confirm the forked worker behavior from the issue's ps output; done means child processes other than debug no longer remain blocked waiting to stop.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Your environment

  • ruby -v: ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-linux]
  • rdbg -v: rdbg 1.9.2

Describe the bug

I'm using delayed_job.
When I tried to increase the number of workers, the number of workers did not increase because the child process did not stop.

The problem was due to Process.waitpid below.

https://github.com/ruby/debug/blob/master/lib/debug/local.rb#L106-L107

To Reproduce

delayed_job uses daemons.

Script:

Gemfile

# frozen_string_literal: true

source "https://rubygems.org"

gem "debug", platforms: %i[ mri windows ]
gem "daemons"

test_daemon.rb

#!/usr/bin/env ruby

require 'bundler/setup'
Bundler.setup
require 'debug'
require 'daemons'

2.times do |i|
  Daemons.run_proc("test_daemon.#{i}") do
    loop do
    end
  end
end

Terminal:

$ test_daemon.rb start

Child processes do not stop and workers do not increase.

$ ps aux
--snip--
sada     14719  1.8  0.2 177232 37168 pts/6    Sl+  17:01   0:00 ruby ./test_daemon.rb start
sada     14735  0.0  0.2 177232 33832 ?        Ssl  17:01   0:00 ruby ./test_daemon.rb start
sada     14737 94.6  0.2 180308 37540 ?        Rl   17:01   0:08 test_daemon.0

The following fork operations are no longer possible.

  1. Forks another child process and exits first child. This prevents the potential of acquiring a controlling terminal.

https://github.com/thuehlinger/daemons/blob/a0e84bcebe8b872ff59e1e0aa10e1f1718a933b1/lib/daemons.rb#L43-L51

Also, in Rails development, debug is loaded by default, When starting delayed_job, unexpected block is caused by this issue.

https://github.com/rails/rails/blob/5e0c7388a378f4beb5368217a8f57f3c1bfbfabe/railties/lib/rails/generators/rails/app/templates/Gemfile.tt#L36

Expected behavior

Child processes other than debug do not wait to stop.

Ngôn ngữ chính
Ruby
Star
1.3k
Fork
146
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của ruby/debug

Tất cả issue của ruby/debug

Issue tương tự

Thêm issue về Ruby

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.