Open jfahrenkrug opened 2 years ago
try these https://github.com/grosser/parallel#activerecord if that does not work, then no idea 😞
@grosser Thank you for the reply. Maybe it has something to do with the DB adapter we are using in connection with Rails 6 (https://github.com/ibmdb/ruby-ibmdb). What worries me is that it's not simply an error about a missing DB connection, but a low-level memory/stack overflow crash ("stack smashing").
got no idea how this happens, would recommend trying plain threads/forks ... I'd assume it also happens there
Hi,
we have an old-ish Rails application that we are trying to upgrade to Rails 6. We have everything working, but we have a couple of spots where we use
Parallel.map
to iterate over chunks of DB ids so we can execute sub-queries in parallel (it's a complex data model and this was done to speed up the initial generation of a large JSON response that is subsequently cached). This worked fine in Rails 4 with Unicorn, but in Rails 6 we get this error (tried it both with Puma and with Unicorn):The code in our Rails app that is causing this looks like this (slightly modified for clarity):
When I replace
trips_data << Parallel.map(trip_share, in_processes: processcount) do |a_trip|
withtrips_data << trip_share.map do |a_trip|
, everything's fine.Any idea why this could be happening or how to solve this? Just for reference (and unrelated to parallel), someone else ran into a similar error (but without the stack smashing) after upgrading from Rails 4 to 6: https://github.com/rails/rails/issues/40698
Thanks!