DEV: disable async logging in development on broken Ruby

approved
#1

DEV: disable async logging in development on broken Ruby

Ruby 2.5.3 has an upatched issue that crashes unicorn after fork:

https://bugs.ruby-lang.org/issues/14634

This will be patched in 2.5.4 however for now just warn people dev is slower and disable async logging on the older rubies

diff --git a/Gemfile.lock b/Gemfile.lock
index 7b1b28b..f8d5a2e 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -186,7 +186,7 @@ GEM
     logstash-event (1.2.02)
     logstash-logger (0.26.1)
       logstash-event (~> 1.2)
-    logster (2.1.0)
+    logster (2.1.1)
     loofah (2.2.3)
       crass (~> 1.0.2)
       nokogiri (>= 1.5.9)
diff --git a/config/initializers/100-logster.rb b/config/initializers/100-logster.rb
index 1ef50d2..21ef01a 100644
--- a/config/initializers/100-logster.rb
+++ b/config/initializers/100-logster.rb
@@ -1,3 +1,12 @@
+if Rails.env.development? && RUBY_VERSION.match?(/^2\.5\.[23]/)
+  STDERR.puts "WARNING: Discourse development environment runs slower on Ruby 2.5.3 or below"
+  STDERR.puts "We recommend you upgrade to Ruby 2.6.1 for the optimal development performance"
+
+  # we have to used to older and slower version of the logger cause the new one exposes a Ruby bug in
+  # the Queue class which causes segmentation faults
+  Logster::Scheduler.disable
+end
+
 if Rails.env.development? && !Sidekiq.server? && ENV["RAILS_LOGS_STDOUT"] == "1"
   console = ActiveSupport::Logger.new(STDOUT)
   original_logger = Rails.logger.chained.first

GitHub sha: 8745f782

1 Like
#2

This commit has been mentioned on Discourse Meta. There might be relevant details there:

Approved #3
#4

Asking on ruby bugs for help here Misc #15617: Any chance we can ship 2.5.4 sooner rather than later? - Ruby trunk - Ruby Issue Tracking System

1 Like