Giter VIP home page Giter VIP logo

Comments (5)

sobrinho avatar sobrinho commented on May 30, 2024 1

This is not a elegant solution but I think it will work:

if defined?(PhusionPassenger)
  PhusionPassenger.on_event(:starting_worker_process) do |forked|
    if forked
      ActiveRecord::Base.connection_proxy.instance_variable_get(:@shards).each do |shard, connection_pool|
        connection_pool.disconnect!
      end
    end
  end
end

But I'm using puma these days which not require this kind of configuration.

Closing :)

from octopus.

thiagopradi avatar thiagopradi commented on May 30, 2024

This erro also happens on unicorn, and putting this line on the after_fork seems to fix it:

ActiveRecord::Base.connection_proxy.instance_variable_get(:@shards).each {|k,v| v.clear_reloadable_connections! }

Try putting this on the Passenger config. (I'm not sure how you should do this, but here is my guess):
if defined?(PhusionPassenger)
PhusionPassenger.on_event(:starting_worker_process) do |forked|
if forked
ActiveRecord::Base.connection_proxy.instance_variable_get(:@shards).each {|k,v| v.clear_reloadable_connections! }
end
end
end

from octopus.

jobster avatar jobster commented on May 30, 2024

FWIW, the fix that @tchandy mentioned above seems to be working for me. A similar fix is also in the StackOverflow post that the OP mentioned...look for the post from Jan 30 at the bottom.

If anyone else can confirm this, then this might be closed!

Edit: the fix that is working for me is the one for Passenger, I haven't tried Unicorn at all.

from octopus.

mshibuya avatar mshibuya commented on May 30, 2024

We also have been suffering from intermittent 'Lost connection' and 'ActiveModel::MissingAttributeError' errors.
After applying @sobrinho 's solution, those errors have gone completely.
Thanks so much!

from octopus.

sobrinho avatar sobrinho commented on May 30, 2024

😆

from octopus.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.