0

I have jruby-9.0.5.0 setup and i try to do some parallel processing using sidekiq. Everything works fine, except that if i use more than 12 sidekiq threads, i keep getting the following error message:

WARN: I18n::InvalidLocaleData: can not load translations from /Users/geroldboehler/.rvm/gems/jruby-9.0.5.0/gems/rails-i18n-4.0.5/lib/rails_i18n/../../rails/locale/ne.yml: java.lang.ArrayIndexOutOfBoundsException
WARN: /Users/geroldboehler/.rvm/gems/jruby-9.0.5.0/gems/i18n-0.7.0/lib/i18n/backend/base.rb:184:in `load_yml'

The line that causes this is the following:

  I18n.t(".") unless I18n.backend.initialized?
  display_names = I18n.backend.send(:translations)[:de][:shoptwist][:display_names]

I need to load the values stored in the translation yml and the second line causes the exception to occur. I have absolutely no clue why this is happening, it probably has to do something with simultaneous access / some weird multithreading problem.

Update

I should mention that this worked when i was using MRI ruby, the problem started when i switched to jruby.

Gerold
  • 29
  • 4

1 Answers1

0

Put this line in an initializer and see if it solves the problem, it should eager load the translations before multiple threads start up:

I18n.t(".")
Mike Perham
  • 21,300
  • 6
  • 59
  • 61
  • I did try that actually, but strangely I18n.backend.initialized? still returns false when i call I18n.t(".") in an initializer – Gerold Feb 03 '16 at 19:26
  • It probably has to do with jruby because it worked when i was using MRI. And thanks for sidekiq btw ;-) – Gerold Feb 03 '16 at 19:33
  • I managed to make it "work" now. I assume it has to do with the lazy loading of the I18n backend. To make it work i created a sidekiq worker that just does I18n.t(".") and after that, i can start as many workers as i like and the exception doesn't occur. – Gerold Feb 06 '16 at 21:52