{"action":"created","issue":{"url":"https://api.github.com/repos/gocd/gocd/issues/497","labels_url":"https://api.github.com/repos/gocd/gocd/issues/497/labels{/name}","comments_url":"https://api.github.com/repos/gocd/gocd/issues/497/comments","events_url":"https://api.github.com/repos/gocd/gocd/issues/497/events","html_url":"https://github.com/gocd/gocd/issues/497","id":42622116,"number":497,"title":"Race condition between stages of a pipeline","user":{"login":"NachbarsLumpi","id":8520682,"avatar_url":"https://avatars.githubusercontent.com/u/8520682?v=3","gravatar_id":"","url":"https://api.github.com/users/NachbarsLumpi","html_url":"https://github.com/NachbarsLumpi","followers_url":"https://api.github.com/users/NachbarsLumpi/followers","following_url":"https://api.github.com/users/NachbarsLumpi/following{/other_user}","gists_url":"https://api.github.com/users/NachbarsLumpi/gists{/gist_id}","starred_url":"https://api.github.com/users/NachbarsLumpi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NachbarsLumpi/subscriptions","organizations_url":"https://api.github.com/users/NachbarsLumpi/orgs","repos_url":"https://api.github.com/users/NachbarsLumpi/repos","events_url":"https://api.github.com/users/NachbarsLumpi/events{/privacy}","received_events_url":"https://api.github.com/users/NachbarsLumpi/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2014-09-12T12:01:30Z","updated_at":"2015-02-17T03:40:25Z","closed_at":null,"body":"Consider 2 pipelines with 3 stages each:\r\n\r\npipeline1\r\n-stage1\r\n-stage2\r\n-stage3\r\n\r\nIf one schedules the pipeline a typical order of execution would be:\r\n\r\n* run1: stage1\r\n* run1: stage2\r\n* run1: stage3\r\n\r\nNow if one schedules pipeline1 again while stage2 is executing, the order of execution changes to:\r\n\r\n* run1: stage1\r\n* run1: stage2\r\n* run2: stage1\r\n* run1: stage3\r\n* run2: stage2\r\n* run2: stage3\r\n\r\nThe intermittent execution of stage1 between stage2 and stage3 of the first run can yield bad/broken/incorrect results and offends the definition of \"stages are always executed in order\".\r\n\r\nIMHO, the job scheduling should delay the execution of a previous stage in a single pipeline until the previous execution is finished or the behaviour should be at least configurable such that the order of execution is:\r\n\r\n* run1: stage1\r\n* run1: stage2\r\n* run1: stage3\r\n* run2: stage1\r\n* run2: stage2\r\n* run2: stage3"},"comment":{"url":"https://api.github.com/repos/gocd/gocd/issues/comments/74612888","html_url":"https://github.com/gocd/gocd/issues/497#issuecomment-74612888","issue_url":"https://api.github.com/repos/gocd/gocd/issues/497","id":74612888,"user":{"login":"jramapuram","id":8204807,"avatar_url":"https://avatars.githubusercontent.com/u/8204807?v=3","gravatar_id":"","url":"https://api.github.com/users/jramapuram","html_url":"https://github.com/jramapuram","followers_url":"https://api.github.com/users/jramapuram/followers","following_url":"https://api.github.com/users/jramapuram/following{/other_user}","gists_url":"https://api.github.com/users/jramapuram/gists{/gist_id}","starred_url":"https://api.github.com/users/jramapuram/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jramapuram/subscriptions","organizations_url":"https://api.github.com/users/jramapuram/orgs","repos_url":"https://api.github.com/users/jramapuram/repos","events_url":"https://api.github.com/users/jramapuram/events{/privacy}","received_events_url":"https://api.github.com/users/jramapuram/received_events","type":"User","site_admin":false},"created_at":"2015-02-17T03:40:25Z","updated_at":"2015-02-17T03:40:25Z","body":"This is a problem for me as well. We have one initial pipeline that:\r\n\r\n - destroys a container\r\n - rebuild a container\r\n - start a container\r\n\r\nThis causes issues if we are later in the pipeline chain as the agent drops off."}}