Ruby Forking and TLVs
The thread objects stay the "same" as the parent memory is copied down to the forked child, so watch out for bad TLVs values.
See:
- https://bugs.ruby-lang.org/issues/17795
- https://github.com/rails/rails/blob/main/activesupport/lib/active_support/fork_tracker.rb
- https://github.com/typhoeus/typhoeus/blob/a345545e5e4ac0522b883fe0cf19e5e2e807b4b0/lib/typhoeus/pool.rb#L34-L42
- https://github.com/Shopify/rails/blob/411ccbdab2608c62aabdb320d52cb02d446bb39c/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb#L946
- http://sequel.jeremyevans.net/rdoc/files/doc/fork_safety_rdoc.html
Puma
before_fork do
Sequel::DATABASES.each(&:disconnect)
end
Parallel
If you’re using the Parallel gem with processes, you should disconnect before calling it:
Sequel::DATABASES.each(&:disconnect)
Parallel.map(['a','b','c'], in_processes: 3) { |one_letter| }
Please
register
or
sign in
to comment