{"action":"closed","issue":{"url":"https://api.github.com/repos/Jumpscale/jsagentcontroller/issues/1","labels_url":"https://api.github.com/repos/Jumpscale/jsagentcontroller/issues/1/labels{/name}","comments_url":"https://api.github.com/repos/Jumpscale/jsagentcontroller/issues/1/comments","events_url":"https://api.github.com/repos/Jumpscale/jsagentcontroller/issues/1/events","html_url":"https://github.com/Jumpscale/jsagentcontroller/issues/1","id":96507235,"number":1,"title":"On agent restart, the first command in queues get lost","user":{"login":"muhamadazmy","id":10920323,"avatar_url":"https://avatars.githubusercontent.com/u/10920323?v=3","gravatar_id":"","url":"https://api.github.com/users/muhamadazmy","html_url":"https://github.com/muhamadazmy","followers_url":"https://api.github.com/users/muhamadazmy/followers","following_url":"https://api.github.com/users/muhamadazmy/following{/other_user}","gists_url":"https://api.github.com/users/muhamadazmy/gists{/gist_id}","starred_url":"https://api.github.com/users/muhamadazmy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/muhamadazmy/subscriptions","organizations_url":"https://api.github.com/users/muhamadazmy/orgs","repos_url":"https://api.github.com/users/muhamadazmy/repos","events_url":"https://api.github.com/users/muhamadazmy/events{/privacy}","received_events_url":"https://api.github.com/users/muhamadazmy/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Jumpscale/jsagentcontroller/labels/bug","name":"bug","color":"fc2929"}],"state":"closed","locked":false,"assignee":{"login":"maxux","id":4141584,"avatar_url":"https://avatars.githubusercontent.com/u/4141584?v=3","gravatar_id":"","url":"https://api.github.com/users/maxux","html_url":"https://github.com/maxux","followers_url":"https://api.github.com/users/maxux/followers","following_url":"https://api.github.com/users/maxux/following{/other_user}","gists_url":"https://api.github.com/users/maxux/gists{/gist_id}","starred_url":"https://api.github.com/users/maxux/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maxux/subscriptions","organizations_url":"https://api.github.com/users/maxux/orgs","repos_url":"https://api.github.com/users/maxux/repos","events_url":"https://api.github.com/users/maxux/events{/privacy}","received_events_url":"https://api.github.com/users/maxux/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/Jumpscale/jsagentcontroller/milestones/1","html_url":"https://github.com/Jumpscale/jsagentcontroller/milestones/1.0","labels_url":"https://api.github.com/repos/Jumpscale/jsagentcontroller/milestones/1/labels","id":1219774,"number":1,"title":"1.0","description":"- Agent events and events handlers","creator":{"login":"muhamadazmy","id":10920323,"avatar_url":"https://avatars.githubusercontent.com/u/10920323?v=3","gravatar_id":"","url":"https://api.github.com/users/muhamadazmy","html_url":"https://github.com/muhamadazmy","followers_url":"https://api.github.com/users/muhamadazmy/followers","following_url":"https://api.github.com/users/muhamadazmy/following{/other_user}","gists_url":"https://api.github.com/users/muhamadazmy/gists{/gist_id}","starred_url":"https://api.github.com/users/muhamadazmy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/muhamadazmy/subscriptions","organizations_url":"https://api.github.com/users/muhamadazmy/orgs","repos_url":"https://api.github.com/users/muhamadazmy/repos","events_url":"https://api.github.com/users/muhamadazmy/events{/privacy}","received_events_url":"https://api.github.com/users/muhamadazmy/received_events","type":"User","site_admin":false},"open_issues":0,"closed_issues":1,"state":"open","created_at":"2015-07-22T08:20:31Z","updated_at":"2015-08-05T06:23:31Z","due_on":null,"closed_at":null},"comments":3,"created_at":"2015-07-22T08:24:38Z","updated_at":"2015-08-05T06:23:31Z","closed_at":"2015-08-05T06:23:31Z","body":"Scenario:\r\n- Agent consumes cmds ...\r\n- While agent on a long-poll (waiting state), agent is restarted\r\n- Agent starts again and start polling.\r\n- Send command on redis queue\r\n- The command is lost and never delivered to the agent.\r\n\r\nI think the reason for this is that when the agent restarted, the long poll on the AC side (the waiting co-routine) never exited. When the agent start polling again another co-routine was created on the AC side. So now we have 2 co-routines that are polling on the same queue.\r\nWhen a command is pushed to the queue, the first co-routine consumes it and of course the command is lost because the agent is not actually receiving on this channel anymore.\r\n\r\nI think the fix should be that when the actually HTTP connection is lost, the co-routine must cancel the queue waiting."}}