{"action":"created","issue":{"url":"https://api.github.com/repos/mperham/sidekiq/issues/789","repository_url":"https://api.github.com/repos/mperham/sidekiq","labels_url":"https://api.github.com/repos/mperham/sidekiq/issues/789/labels{/name}","comments_url":"https://api.github.com/repos/mperham/sidekiq/issues/789/comments","events_url":"https://api.github.com/repos/mperham/sidekiq/issues/789/events","html_url":"https://github.com/mperham/sidekiq/issues/789","id":12302571,"node_id":"MDU6SXNzdWUxMjMwMjU3MQ==","number":789,"title":"Sidekiq error Uninitialized Constant","user":{"login":"juand","id":1178903,"node_id":"MDQ6VXNlcjExNzg5MDM=","avatar_url":"https://avatars2.githubusercontent.com/u/1178903?v=4","gravatar_id":"","url":"https://api.github.com/users/juand","html_url":"https://github.com/juand","followers_url":"https://api.github.com/users/juand/followers","following_url":"https://api.github.com/users/juand/following{/other_user}","gists_url":"https://api.github.com/users/juand/gists{/gist_id}","starred_url":"https://api.github.com/users/juand/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/juand/subscriptions","organizations_url":"https://api.github.com/users/juand/orgs","repos_url":"https://api.github.com/users/juand/repos","events_url":"https://api.github.com/users/juand/events{/privacy}","received_events_url":"https://api.github.com/users/juand/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":17,"created_at":"2013-03-22T01:00:49Z","updated_at":"2018-11-02T18:17:58Z","closed_at":"2013-03-22T04:43:44Z","author_association":"NONE","body":"I'm having an issue with sidekiq. Basically we're getting NameError: uninitialized constant on our sidekiq setup which is causing a large number of jobs to fail.\n\nThe error log says:\n\n```\nNameError: uninitialized constant GameUser::Lock /data/@myapp/releases/20130321230952/app/models/game_user.rb:71:in `node_calls_base_get_user' \n/data/@myapp/shared/bundled_gems/ruby/1.9.1/gems/sidekiq-2.8.0/lib/sidekiq/processor.rb:45:in `block (3 levels) in process' \n/data/@myapp/shared/bundled_gems/ruby/1.9.1/gems/sidekiq-2.8.0/lib/sidekiq/middleware/chain.rb:109:in `call'\n```\n\nThe code is here:\n\n```\n# app/models/game_user.rb\ndef self.node_calls_base_get_user(serial, game_name)\n  if Lock.get(\"user:#{id}\") # Set up lock to prevent multiple users to be created      \n    Lock.delete(\"user:#{id}\")\n  end\n  return false\nend\n```\n\nLock is defined in a library:\n\n```\n# lib/lock.rb\nclass Lock\n  def self.get(key)\n    lock = CACHE.add(\"lock:#{key}\", 1, 5) # Let lock autoexpire after 5 seconds\n    return true\n  end\nend\n```\n\nAnd the lib/ folder is automatically loaded with the rest of the configurations.\n\n```\nmodule Myapp\n  class Application < Rails::Application\n    ...\n    # Custom directories with classes and modules you want to be autoloadable.\n    config.autoload_paths += %W(#{config.root}/lib)\n    ...    \n  end\nend\n```\n\nI have no idea why this is happening. It seems to happen more frequently when we deploy, but it seems to happen often enough otherwise.\n\nI've been following the following thread: https://github.com/mperham/sidekiq/issues/331 but it doesn't seem to offer a solution besides adding the lib folder to the autoload_paths.\n\nI'm using:\n\n```\ngem 'rails', '3.2.13' \ngem 'sidekiq', '>= 2.7.5'\n```\n\nAny help would be greatly apreciated.\n"},"comment":{"url":"https://api.github.com/repos/mperham/sidekiq/issues/comments/435465932","html_url":"https://github.com/mperham/sidekiq/issues/789#issuecomment-435465932","issue_url":"https://api.github.com/repos/mperham/sidekiq/issues/789","id":435465932,"node_id":"MDEyOklzc3VlQ29tbWVudDQzNTQ2NTkzMg==","user":{"login":"pokrovskyy","id":1635058,"node_id":"MDQ6VXNlcjE2MzUwNTg=","avatar_url":"https://avatars3.githubusercontent.com/u/1635058?v=4","gravatar_id":"","url":"https://api.github.com/users/pokrovskyy","html_url":"https://github.com/pokrovskyy","followers_url":"https://api.github.com/users/pokrovskyy/followers","following_url":"https://api.github.com/users/pokrovskyy/following{/other_user}","gists_url":"https://api.github.com/users/pokrovskyy/gists{/gist_id}","starred_url":"https://api.github.com/users/pokrovskyy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pokrovskyy/subscriptions","organizations_url":"https://api.github.com/users/pokrovskyy/orgs","repos_url":"https://api.github.com/users/pokrovskyy/repos","events_url":"https://api.github.com/users/pokrovskyy/events{/privacy}","received_events_url":"https://api.github.com/users/pokrovskyy/received_events","type":"User","site_admin":false},"created_at":"2018-11-02T18:17:58Z","updated_at":"2018-11-02T18:17:58Z","author_association":"NONE","body":"I'm having this kind of error popping up spontaneously on my production workers. I would say rather rarely. It only sometimes happens upon worker boot-up. Missing classes differ much:\r\n\r\nuninitialized constant ActiveRecord::Associations::BelongsToAssociation\r\nuninitialized constant ActiveRecord::Associations::HasManyAssociation\r\nuninitialized constant ActiveRecord::Associations::Preloader::BelongsTo\r\nuninitialized constant ActiveRecord::Core::LegacyYamlAdapter\r\nuninitialized constant ActiveRecord::Associations::HasManyThroughAssociation\r\nuninitialized constant ActiveRecord::Associations::JoinDependency::JoinBase\r\netc.\r\n\r\nIt really seems like the worker has not yet fully loaded all the requirements, but Sidekiq part already is and starting pulling up jobs and throwing them into the threads. Not sure if it's Sidekiq issue or not, but it really seems like it starts working a little too early, like it should just wait for the requirements to load up. Could not reproduce this in dev env, only happens in high-load production. Any thoughts? "}}
{"actor":{"display_login":"pokrovskyy"}}