Comments (12)
Do you have an reproduction you could show me? Perhaps a rails app?
from puma.
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.
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.
@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.
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.
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.
Yeah, the app is using Rack::Cache. In staging and production it is configured with Memcached/Dalli, nothing is configured in development.
from puma.
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.
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.
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.
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.
Thanks a ton @rtomayko and @evanphx!
from puma.
Related Issues (20)
- Puma and Puma Dev Linux issue
- Phased-Restart Causes Action Cable Connection Loss on Rails App Restart HOT 3
- Add a hook for "before shutdown" HOT 6
- Systemd watchdog kills puma during hot restart. HOT 4
- NoMethodError: undefined method `release' for Rack:Module error at "rails s" initialization time HOT 5
- Staging environment, request.ENV['HTTP_HOST'] displays 2 urls when it should be a single url HOT 1
- HttpParserError raised when body (chunk) exceeds 4096 bytes does not end with "\r\n" HOT 4
- undefined method `log_writer' for #<Puma::Launcher on usin plugin :solid_queue in puma HOT 1
- `TestWorkerGemIndependence#test_changing_nio4r_version_during_phased_restart` fails in head builds
- Option to restrict cipher suites for TLS1.3
- Requests with a caret (`<` or `>`) in a query parameter raise a `Puma::HttpParserError` HOT 10
- Random freezes in dev mode
- Puma doesn't start the Rails app after run
- "undefined method `on_booted` for nil:NilClass" on "pumactl start" HOT 2
- Large number of workers are booting too long or not booting the first time HOT 4
- What options are not available when using `rails s`? HOT 1
- MAX_CHUNK_HEADER_SIZE = 4096 is too small for podman HOT 6
- Puma config get evaluated twice with pumactl HOT 3
- question about puma architecture
- Windows - Puma compiled without ssl support HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from puma.