Giter VIP home page Giter VIP logo

Comments (12)

evanphx avatar evanphx commented on May 4, 2024

Do you have an reproduction you could show me? Perhaps a rails app?

from puma.

sorentwo avatar sorentwo commented on May 4, 2024

The app I was testing this out with is our production app, and I can't share it exactly. I can share the gemspec and environment files though.

https://gist.github.com/2375692

Only the development config is included, but this would happen in all environments.

from puma.

evanphx avatar evanphx commented on May 4, 2024

Any chance you could build a sample rails app that shows the problem? It's quite difficult to derive the situation from just your config files.

from puma.

ezkl avatar ezkl commented on May 4, 2024

@sorentwo Do you still see the issue if you turn off the asset pipeline by setting config.assets.enabled = false in config/application, run RAILS_ENV=development bundle exec rake assets:precompile and then run the server?

from puma.

sorentwo avatar sorentwo commented on May 4, 2024

Truthfully I returned to using Unicorn after running into the issue, so it took me some time to get a free moment to investigate this.

@ezkl Those precise steps don't quite work out, but not because of anything with Puma. With the asset pipeline disabled no precompilation happens at all, and with it enabled no stylesheets are precompiled, making the exercise futile.

@evanphx I'll try to do this soon. Because the image mixup is random on different servers, and we're loading 20+ images on the affected pages I fear it would be difficult to replicate.

from puma.

lukesutton avatar lukesutton commented on May 4, 2024

I've seen the same issue myself. I found Rack Cache seemed to be misbehaving, although I didn't get to diagnose the specific cause.

@sorentwo Are you using Rack Cache? I do know Rails 3 injects it into the middleware stack by default.

from puma.

sorentwo avatar sorentwo commented on May 4, 2024

Yeah, the app is using Rack::Cache. In staging and production it is configured with Memcached/Dalli, nothing is configured in development.

from puma.

jtblin avatar jtblin commented on May 4, 2024

I can repro with Rack::Cache. It is quite simple to repro, just add rack-cache gem, sets config.consider_all_requests_local = true, config.serve_static_assets = true and config.static_cache_control = "public, max-age=2592000" development.rb in a project where you have css, images, etc. Just refresh the pages a few time.

It seems to occur because puma sets env['rack.run_once'] to true and Rack::Cache determines if it's going to make a thread safe request based on this, e.g. /lib/rack/cache/context.rb:48
def call(env)
if env['rack.run_once']
call! env
else
clone.call! env
end
end

Either puma should not set env['rack.run_once'] to true or Rack::Cache should test if env['rack.multithread'] is not true as well, i.e.

if env['rack.run_once'] && !env['rack.multithread']
call! env
else
clone.call! env
end

I'll propose this fix to rack::cache project and let this thread know if they accept my pull request.

from puma.

rtomayko avatar rtomayko commented on May 4, 2024

I just merged @jtblin change in rtomayko/rack-cache#71 so that rack.multithread is checked but puma setting rack.run_once seems pretty wrong here. What's the reasoning behind setting it true in this case?

from puma.

evanphx avatar evanphx commented on May 4, 2024

Puma shouldn't be setting rack.run_once, that's my mistake. I'm finishing up testing of 1.7.0 today and will have it out perhaps shortly and it will include removing setting rack.run_once. I'll also review all the rack options that are set.

from puma.

sorentwo avatar sorentwo commented on May 4, 2024

Thanks @jtblin, @rtomayko and @evanphx. I never got back to trying to work through this and it haunted me a bit. Awesome to see that this got resolved though.

from puma.

jtblin avatar jtblin commented on May 4, 2024

Thanks a ton @rtomayko and @evanphx!

from puma.

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.