{"action":"created","issue":{"url":"https://api.github.com/repos/cantino/huginn/issues/1454","repository_url":"https://api.github.com/repos/cantino/huginn","labels_url":"https://api.github.com/repos/cantino/huginn/issues/1454/labels{/name}","comments_url":"https://api.github.com/repos/cantino/huginn/issues/1454/comments","events_url":"https://api.github.com/repos/cantino/huginn/issues/1454/events","html_url":"https://github.com/cantino/huginn/issues/1454","id":151306563,"number":1454,"title":"2 Events from 1 Agent when running multiple workers","user":{"login":"TildeWill","id":163532,"avatar_url":"https://avatars.githubusercontent.com/u/163532?v=3","gravatar_id":"","url":"https://api.github.com/users/TildeWill","html_url":"https://github.com/TildeWill","followers_url":"https://api.github.com/users/TildeWill/followers","following_url":"https://api.github.com/users/TildeWill/following{/other_user}","gists_url":"https://api.github.com/users/TildeWill/gists{/gist_id}","starred_url":"https://api.github.com/users/TildeWill/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TildeWill/subscriptions","organizations_url":"https://api.github.com/users/TildeWill/orgs","repos_url":"https://api.github.com/users/TildeWill/repos","events_url":"https://api.github.com/users/TildeWill/events{/privacy}","received_events_url":"https://api.github.com/users/TildeWill/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2016-04-27T06:08:49Z","updated_at":"2016-05-02T20:35:56Z","closed_at":null,"body":"As I'm digging in to this problem I thought I'd open an issue in case someone else comes across this problem and/or has some insight. All this is locally on my MacBook Pro. I ran a script that dsander posted in another thread to create 500 pairs of agents (1000 total) plus one ManualEventAgent to kick off a set of web requests back to the web server. \r\n```ruby\r\ntrigger = User.find(1).agents.create!(type: \"Agents::ManualEventAgent\", name: \"PostTrigger\")\r\n\r\n500.times do |i|\r\n  options = {\"secret\" => \"supersecretstring\", \"expected_receive_period_in_days\" => 1, \"payload_path\" => \"payload\"}\r\n  webhook = User.find(1).agents.create!(type: 'Agents::WebhookAgent', name: \"Webhook #{i}\", options: options)\r\n  options = {\"post_url\" => \"http://localhost:5000/users/1/web_requests/#{webhook.id}/supersecretstring\", \"expected_receive_period_in_days\" => \"1\", \"content_type\" => \"form\", \"method\" => \"post\", \"payload\" => {\"payload\" => {\"agent\" => \"#{i}\"}}, \"headers\" => {}}\r\n  webhook = User.find(1).agents.new(type: 'Agents::PostAgent', name: \"Post #{i}\", options: options)\r\n  webhook.sources << trigger\r\n  webhook.save!\r\nend\r\n\r\n```\r\n\r\nExpected outcome: 501 Events, Actual: 502 (or more) Events.\r\n\r\nMy Procfile looks like this:\r\n```\r\nweb: bundle exec rails server -p ${PORT-3000} -b ${IP-0.0.0.0}\r\nscheduler: bundle exec rails runner bin/schedule.rb\r\nworker1: bundle exec script/delayed_job -i 1 run\r\nworker2: bundle exec script/delayed_job -i 2 run\r\n```\r\n\r\nIf I comment out the second worker, I get the expected 501 Events. \r\n\r\nThe extra event looks like a duplicate. Their id's are back-to-back (eg. 302 and 303) with the same agent_id. \r\nOther stuff that might be relevant that I can think of: \r\n`DELAYED_JOB_SLEEP_DELAY=10`\r\nRuby 2.2.3\r\npostgres (PostgreSQL) 9.4.5\r\n"},"comment":{"url":"https://api.github.com/repos/cantino/huginn/issues/comments/216355495","html_url":"https://github.com/cantino/huginn/issues/1454#issuecomment-216355495","issue_url":"https://api.github.com/repos/cantino/huginn/issues/1454","id":216355495,"user":{"login":"TildeWill","id":163532,"avatar_url":"https://avatars.githubusercontent.com/u/163532?v=3","gravatar_id":"","url":"https://api.github.com/users/TildeWill","html_url":"https://github.com/TildeWill","followers_url":"https://api.github.com/users/TildeWill/followers","following_url":"https://api.github.com/users/TildeWill/following{/other_user}","gists_url":"https://api.github.com/users/TildeWill/gists{/gist_id}","starred_url":"https://api.github.com/users/TildeWill/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TildeWill/subscriptions","organizations_url":"https://api.github.com/users/TildeWill/orgs","repos_url":"https://api.github.com/users/TildeWill/repos","events_url":"https://api.github.com/users/TildeWill/events{/privacy}","received_events_url":"https://api.github.com/users/TildeWill/received_events","type":"User","site_admin":false},"created_at":"2016-05-02T20:35:56Z","updated_at":"2016-05-02T20:35:56Z","body":"I changed my setup script to be \r\n```ruby\r\ntrigger = User.find(1).agents.create!(type: \"Agents::ManualEventAgent\", name: \"PostTrigger\"); nil;\r\n\r\n500.times do |i|\r\n  options = {\r\n    :expected_receive_period_in_days => \"2\",\r\n    :rules => [{\r\n      :type => \"regex\",\r\n      :value => \"rain\",\r\n      :path => \"conditions\"\r\n    }],\r\n    :message => \"Agent: #{i} -It looks like '{{conditions}}' tomorrow in {{location}}\"\r\n  }\r\n\r\n  agent = User.find(1).agents.new(type: 'Agents::TriggerAgent', name: \"First Agent #{i}\", options: options)\r\n  agent.sources << trigger\r\n  agent.save!\r\nend\r\n```\r\nand Procfile looks like:\r\n```\r\nweb: bundle exec rails server -p ${PORT-3000} -b ${IP-0.0.0.0}\r\nschedule: bundle exec rails runner bin/schedule.rb\r\ndj: bundle exec rake jobs:work\r\n```\r\nwith a start command to kick off 2 workers: `bundle exec foreman start -m dj=2,web=1,schedule=1`\r\n\r\nResults: Event.count = 507"}}