You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What has worked for me is calling ActiveRecord::Base.connection.reconnect! inside the block
Parallel.each(items,in_processes: 4)do |item|
# Reconnect to the database in the new process ( or thread )ActiveRecord::Base.connection.reconnect!# do stuff ...end
Hi.
Parallel.map(orders, :in_processes => 6) do |order|
ActiveRecord::Base.establish_connection
# some huge calculation
end
And i get this error:
Mysql::Error: Lost connection to MySQL server during query
or this one:
Mysql::Error: MySQL server has gone away
What i did wrong?
The text was updated successfully, but these errors were encountered: