New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Logging stops after a while (thread safety) #14031
Comments
@nathany could you create an application reproducing this issue? Or maybe you could provide more information. Right now it will be difficult fix your problem if we don't know why it happens. |
I'll keep trying to narrow down the issue. (For example, to see if it still happens if we don't do an ActiveRecord find in log_tags). Just getting this in front of people in case anyone else has ran into it. Also mentioned on the Heroku forums: https://discussion.heroku.com/t/rails-logging-stalls-a-few-minutes-after-boot/455 Might it be related to using a threaded webserver? #9065 |
I tried this with a hard coded log_tag instead of the session query as well as disabling Heroku's |
The behaviour matches what is described here:
LoggerSilence in Rails 4.0.2 could be the problem. #10836 Being likely a threading issue, the unpredictably makes me unsure if it's specific to tagged logging. Though I noticed rails_stdout_logging uses |
So I've been looking through our dependencies for a potential race condition when silencing logs: ack "silence" `bundle show --paths` It doesn't look like LoggerSilence is being used anymore: rails/activerecord-session_store#5
I am seeing an
warn('Digest::Digest is deprecated; use Digest') And in several other places. Might be related. See puma/puma#173 |
Do you still see this issue using the Rails beta or master? |
@schneems We haven't been able to run our app under Rails 4.1 rc yet, currently waiting for this fix: thoughtbot/shoulda-matchers#434 among a number of deprecations to fix (only recently upgraded to Rails 4). We've not reproduced the issue outside of production with real traffic yet, I should look into how to simulate traffic against our app in development. Then I could probably allocate some time to build a minimal Rails app running under Puma to reproduce the issue. |
I do wonder if #12684 |
Our app is now on Rails 4.0.4 and still exhibiting the issue. I am reproducing it in development using a production-like environment: Running abbench with concurrency I see the first few logs and then it quits logging:
Restarting the server and running abbench without concurrency I will see the logs for as long as abbench is running:
I'm now creating a smaller Rails app to see if I can reproduce the problem there. |
Sorry you're seeing this behavior but thanks for the continued feedback ❤️. If we can get a repro demo app it could be huge. |
Here is a sample app to reproduce the issue: https://github.com/GetJobber/logging_example It seems related to activerecord-session_store, pg and rails_12factor under a threaded web server (puma). It is possible that some other ActiveRecord access would cause the same issue as well, but activerecord-session_store is where I first hit it. |
I was able to reproduce given the steps you sent me. However I did notice a problem. You're starting with So what's happening is that rails_12factor is setting your logger to use STDOUT, and then by starting the command with Running via puma directly |
@schneems Thanks for taking a look. We don't actually use I also see the logging stall when starting with Have you tried increasing the number of hits from ab to see if logging stalls before it's done? I see the same problem with Rails Our production Procfile currently contains:
(the 2>&1 is a recent addition since the problem started) |
Fyi, I tried removing In the controller: @users = User.all.to_a Or in production.rb (with a user present in the DB): config.log_tags = [
lambda { |req|
user = User.first
return unless user
"user_id=#{user.login}"
}
] Neither case caused the issue, so it seems be specific to something activerecord-session_store 0.1.0 is doing. Maybe: |
Verified that rails/activerecord-session_store#19 is the issue in my logging example. |
@nathany : Thanks a lot for your quick feedback! |
Just for posterity. I had a similar issue upgrading from Rails 3 to Rails 4. Logging to STDOUT stopped (after one request) because of the obsolete |
We are having an issue where our Rails logs output (to STDOUT) for a few minutes after boot (on Heroku dynos) but then quit. The other Heroku logs continue (router, runtime metrics) so it seems to be a problem in Ruby-land.
This seems to only occur when usinglog_tags
or when enabling thelograge
gem: roidrage/lograge#65MRI 2.1, Rails 4.0.2, Puma 2.7.1 with
8 threads6 threads.Last week we upgraded from Rails 3.2.16 to 4.0.2. We believe that is when the issue surfaced, though a few weeks ago we switched from Unicorn to Puma as well.
Has anyone else ran into an issue like this? Particularly with a threaded web server.
The text was updated successfully, but these errors were encountered: