{"action":"opened","issue":{"url":"https://api.github.com/repos/rightscale/attributor/issues/174","repository_url":"https://api.github.com/repos/rightscale/attributor","labels_url":"https://api.github.com/repos/rightscale/attributor/issues/174/labels{/name}","comments_url":"https://api.github.com/repos/rightscale/attributor/issues/174/comments","events_url":"https://api.github.com/repos/rightscale/attributor/issues/174/events","html_url":"https://github.com/rightscale/attributor/issues/174","id":172593636,"number":174,"title":"Intermittent Attributor::InvalidDefinition when running multi-threaded app under rainbows ","user":{"login":"justingaylor","id":635873,"avatar_url":"https://avatars.githubusercontent.com/u/635873?v=3","gravatar_id":"","url":"https://api.github.com/users/justingaylor","html_url":"https://github.com/justingaylor","followers_url":"https://api.github.com/users/justingaylor/followers","following_url":"https://api.github.com/users/justingaylor/following{/other_user}","gists_url":"https://api.github.com/users/justingaylor/gists{/gist_id}","starred_url":"https://api.github.com/users/justingaylor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/justingaylor/subscriptions","organizations_url":"https://api.github.com/users/justingaylor/orgs","repos_url":"https://api.github.com/users/justingaylor/repos","events_url":"https://api.github.com/users/justingaylor/events{/privacy}","received_events_url":"https://api.github.com/users/justingaylor/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-08-23T01:40:32Z","updated_at":"2016-08-23T01:40:32Z","closed_at":null,"body":"When running under rainbows in multi-threaded mode (50 workers, 2 threads/worker) to investigate another issue, I've encountered the following intermittent errors. \r\n\r\n```\r\nType: Attributor::InvalidDefinition, Message: Structure definition for type #<Class:0x00000004241fb8> is invalid. The following exception has occurred: #<RuntimeError: can't add a new key into hash during iteration>, Backtrace: \r\n  <APP_ROOT>/vendor/bundle/ruby/2.1.0/gems/attributor-5.0.2/lib/attributor/types/hash.rb:84:in `attributes'\r\n  <APP_ROOT>/vendor/bundle/ruby/2.1.0/gems/attributor-5.0.2/lib/attributor/types/model.rb:180:in `method_missing'\r\n  <APP_ROOT>/vendor/bundle/ruby/2.1.0/gems/attributor-5.0.2/lib/attributor/types/model.rb:139:in `block in validate'\r\n  <APP_ROOT>/vendor/bundle/ruby/2.1.0/gems/attributor-5.0.2/lib/attributor/types/model.rb:136:in `each'\r\n  <APP_ROOT>/vendor/bundle/ruby/2.1.0/gems/attributor-5.0.2/lib/attributor/types/model.rb:136:in `validate'\r\n  <APP_ROOT>/vendor/bundle/ruby/2.1.0/gems/attributor-5.0.2/lib/attributor/types/hash.rb:430:in `validate'\r\n  <APP_ROOT>/vendor/bundle/ruby/2.1.0/gems/attributor-5.0.2/lib/attributor/attribute.rb:215:in `validate'\r\n  <APP_ROOT>/vendor/cache/praxis-ca6f964fc155/lib/praxis/request.rb:151:in `validate_params'\r\n  <APP_ROOT>/vendor/cache/praxis-ca6f964fc155/lib/praxis/request_stages/validate_params_and_headers.rb:48:in `execute'\r\n  <APP_ROOT>/vendor/cache/praxis-ca6f964fc155/lib/praxis/request_stages/request_stage.rb:83:in `execute_with_around'\r\n  <APP_ROOT>/vendor/cache/praxis-ca6f964fc155/lib/praxis/request_stages/request_stage.rb:61:in `run'\r\n  <APP_ROOT>/vendor/cache/praxis-ca6f964fc155/lib/praxis/request_stages/request_stage.rb:111:in `block in execute'\r\n  <APP_ROOT>/vendor/cache/praxis-ca6f964fc155/lib/praxis/request_stages/request_stage.rb:110:in `each'\r\n  <APP_ROOT>/vendor/cache/praxis-ca6f964fc155/lib/praxis/request_stages/request_stage.rb:110:in `execute'\r\n  <APP_ROOT>/vendor/cache/praxis-ca6f964fc155/lib/praxis/request_stages/request_stage.rb:83:in `execute_with_around'\r\n  <APP_ROOT>/vendor/cache/praxis-ca6f964fc155/lib/praxis/request_stages/request_stage.rb:61:in `run'\r\n  <APP_ROOT>/vendor/cache/praxis-ca6f964fc155/lib/praxis/dispatcher.rb:87:in `block (2 levels) in dispatch'\r\n  <APP_ROOT>/vendor/cache/praxis-ca6f964fc155/lib/praxis/dispatcher.rb:86:in `each'\r\n  <APP_ROOT>/vendor/cache/praxis-ca6f964fc155/lib/praxis/dispatcher.rb:86:in `block in dispatch'\r\n  <APP_ROOT>/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.7/lib/active_support/notifications.rb:164:in `block in instrument'\r\n  <APP_ROOT>/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.7/lib/active_support/notifications/instrumenter.rb:20:in `instrument'\r\n  <APP_ROOT>/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.7/lib/active_support/notifications.rb:164:in `instrument'\r\n  <APP_ROOT>/vendor/cache/praxis-ca6f964fc155/lib/praxis/notifications.rb:24:in `instrument'\r\n  <APP_ROOT>/vendor/cache/praxis-ca6f964fc155/lib/praxis/dispatcher.rb:81:in `dispatch'\r\n  <APP_ROOT>/vendor/cache/praxis-ca6f964fc155/lib/praxis/bootloader_stages/routing.rb:19:in `call'\r\n  <APP_ROOT>/vendor/cache/praxis-ca6f964fc155/lib/praxis/router.rb:17:in `call'\r\n  <APP_ROOT>/vendor/cache/praxis-ca6f964fc155/lib/praxis/router.rb:35:in `invoke'\r\n  <APP_ROOT>/vendor/cache/praxis-ca6f964fc155/lib/praxis/router/simple.rb:129:in `block (2 levels) in call'\r\n  <APP_ROOT>/vendor/cache/praxis-ca6f964fc155/lib/praxis/router/simple.rb:127:in `catch'\r\n  <APP_ROOT>/vendor/cache/praxis-ca6f964fc155/lib/praxis/router/simple.rb:127:in `block in call'\r\n  <APP_ROOT>/vendor/cache/praxis-ca6f964fc155/lib/praxis/router/simple.rb:126:in `each'\r\n  <APP_ROOT>/vendor/cache/praxis-ca6f964fc155/lib/praxis/router/simple.rb:126:in `call'\r\n  <APP_ROOT>/vendor/cache/praxis-ca6f964fc155/lib/praxis/router.rb:77:in `call'\r\n  <APP_ROOT>/vendor/cache/praxis-ca6f964fc155/lib/praxis/application.rb:115:in `block in call'\r\n  <APP_ROOT>/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.7/lib/active_support/notifications.rb:164:in `block in instrument'\r\n  <APP_ROOT>/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.7/lib/active_support/notifications/instrumenter.rb:20:in `instrument'\r\n  <APP_ROOT>/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.7/lib/active_support/notifications.rb:164:in `instrument'\r\n  <APP_ROOT>/vendor/cache/praxis-ca6f964fc155/lib/praxis/notifications.rb:24:in `instrument'\r\n  <APP_ROOT>/vendor/cache/praxis-ca6f964fc155/lib/praxis/application.rb:114:in `call'\r\n  <APP_ROOT>/vendor/bundle/ruby/2.1.0/gems/stalin-0.2.0/lib/stalin/adapter/rack.rb:30:in `call'\r\n  <APP_ROOT>/vendor/cache/global_session-66c8bdcf73b8/lib/global_session/rack.rb:146:in `call'\r\n  <APP_ROOT>/vendor/bundle/ruby/2.1.0/gems/rack-contrib-1.4.0/lib/rack/contrib/cookies.rb:44:in `call'\r\n  <APP_ROOT>/vendor/bundle/ruby/2.1.0/gems/right_support-2.11.3/lib/right_support/rack/request_logger.rb:129:in `call'\r\n  <APP_ROOT>/vendor/bundle/ruby/2.1.0/gems/right_support-2.11.3/lib/right_support/rack/request_tracker.rb:78:in `call'\r\n  <APP_ROOT>/vendor/bundle/ruby/2.1.0/gems/rack_injection-0.2.0/lib/rack_injection.rb:12:in `call'\r\n  <APP_ROOT>/vendor/bundle/ruby/2.1.0/gems/rack-contrib-1.4.0/lib/rack/contrib/runtime.rb:18:in `call'\r\n  <APP_ROOT>/vendor/bundle/ruby/2.1.0/gems/rainbows-4.7.0/lib/rainbows/max_body.rb:66:in `block in call'\r\n  <APP_ROOT>/vendor/bundle/ruby/2.1.0/gems/rainbows-4.7.0/lib/rainbows/max_body.rb:59:in `catch'\r\n  <APP_ROOT>/vendor/bundle/ruby/2.1.0/gems/rainbows-4.7.0/lib/rainbows/max_body.rb:59:in `call'\r\n  <APP_ROOT>/vendor/bundle/ruby/2.1.0/gems/rainbows-4.7.0/lib/rainbows/process_client.rb:44:in `process_loop'\r\n  <APP_ROOT>/vendor/bundle/ruby/2.1.0/gems/rainbows-4.7.0/lib/rainbows/thread_pool.rb:41:in `sync_worker'\r\n  <APP_ROOT>/vendor/bundle/ruby/2.1.0/gems/rainbows-4.7.0/lib/rainbows/thread_pool.rb:25:in `block (2 levels) in worker_loop'\r\n```\r\nMy test sends 100 concurrent requests to the service, all the same exact request format. Of the 100 requests, 2 or 3 return \"400 Bad Request\" with the above validation error, while the rest of the requests return 200 OK.\r\n\r\nHere's the response body for the failures:\r\n```\r\n{\r\n  \"name\": \"ValidationError\",\r\n  \"summary\": \"Error loading params.\",\r\n  \"errors\": [\r\n    \"Error loading attribute $.params of type  from value {\\\"limit\\\"=>\\\"1\\\"}\\nStructure definition for type #<Class:0x00000004241fb8> is invalid. The following exception has occurred: #<RuntimeError: can't add a new key into hash during iteration>\"\r\n  ],\r\n  \"cause\": {\r\n    \"name\": \"Attributor::InvalidDefinition\",\r\n    \"message\": \"Structure definition for type #<Class:0x00000004241fb8> is invalid. The following exception has occurred: #<RuntimeError: can't add a new key into hash during iteration>\"\r\n  }\r\n}\r\n```\r\n\r\nIt feels like this could be a problem with thread safety in the params hash processing in praxis/attributor, so I thought I would report here.\r\n\r\nPlease let me know if I should report this under praxis or here and how I can help. Cheers."}}
{"actor":{"display_login":"justingaylor"}}