{"action":"created","issue":{"url":"https://api.github.com/repos/jenkinsci/job-dsl-plugin/issues/751","repository_url":"https://api.github.com/repos/jenkinsci/job-dsl-plugin","labels_url":"https://api.github.com/repos/jenkinsci/job-dsl-plugin/issues/751/labels{/name}","comments_url":"https://api.github.com/repos/jenkinsci/job-dsl-plugin/issues/751/comments","events_url":"https://api.github.com/repos/jenkinsci/job-dsl-plugin/issues/751/events","html_url":"https://github.com/jenkinsci/job-dsl-plugin/pull/751","id":134381077,"number":751,"title":"Fix problem with running the DSL in multiple threads","user":{"login":"marc-guenther","id":393230,"avatar_url":"https://avatars.githubusercontent.com/u/393230?v=3","gravatar_id":"","url":"https://api.github.com/users/marc-guenther","html_url":"https://github.com/marc-guenther","followers_url":"https://api.github.com/users/marc-guenther/followers","following_url":"https://api.github.com/users/marc-guenther/following{/other_user}","gists_url":"https://api.github.com/users/marc-guenther/gists{/gist_id}","starred_url":"https://api.github.com/users/marc-guenther/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marc-guenther/subscriptions","organizations_url":"https://api.github.com/users/marc-guenther/orgs","repos_url":"https://api.github.com/users/marc-guenther/repos","events_url":"https://api.github.com/users/marc-guenther/events{/privacy}","received_events_url":"https://api.github.com/users/marc-guenther/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2016-02-17T19:45:45Z","updated_at":"2016-03-18T15:05:16Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/jenkinsci/job-dsl-plugin/pulls/751","html_url":"https://github.com/jenkinsci/job-dsl-plugin/pull/751","diff_url":"https://github.com/jenkinsci/job-dsl-plugin/pull/751.diff","patch_url":"https://github.com/jenkinsci/job-dsl-plugin/pull/751.patch"},"body":"We use GPars eachParallel() to split up generation of jobs\r\ninto multiple threads. This significantly reduced our\r\nrun time from 25min to 5min.\r\n\r\nUnfortunately, it leads to a race condition, which causes\r\nrandom jobs to be lost (and deleted) on each run.\r\n\r\nUltimately, it all boils down to this non thread-safe statement\r\nin JobParent.processItem():\r\n  referencedJobs << job\r\n\r\nMaking the 5 collections asSynchronized() fixed the problem for us."},"comment":{"url":"https://api.github.com/repos/jenkinsci/job-dsl-plugin/issues/comments/198400371","html_url":"https://github.com/jenkinsci/job-dsl-plugin/pull/751#issuecomment-198400371","issue_url":"https://api.github.com/repos/jenkinsci/job-dsl-plugin/issues/751","id":198400371,"user":{"login":"daspilker","id":47957,"avatar_url":"https://avatars.githubusercontent.com/u/47957?v=3","gravatar_id":"","url":"https://api.github.com/users/daspilker","html_url":"https://github.com/daspilker","followers_url":"https://api.github.com/users/daspilker/followers","following_url":"https://api.github.com/users/daspilker/following{/other_user}","gists_url":"https://api.github.com/users/daspilker/gists{/gist_id}","starred_url":"https://api.github.com/users/daspilker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/daspilker/subscriptions","organizations_url":"https://api.github.com/users/daspilker/orgs","repos_url":"https://api.github.com/users/daspilker/repos","events_url":"https://api.github.com/users/daspilker/events{/privacy}","received_events_url":"https://api.github.com/users/daspilker/received_events","type":"User","site_admin":false},"created_at":"2016-03-18T15:05:16Z","updated_at":"2016-03-18T15:05:16Z","body":"Yes, `JobManagement` is shared between items. But if you do not use the \"interesting\" code, you should be safe. There may be plugins providing misbehaving DSL methods through the extension points. I did a quick code review of all extensions listed on the API Viewer homepage (https://jenkinsci.github.io/job-dsl-plugin/) and those are safe as of now.\r\n\r\nIt would be nice if we could improve the single-thread performance of Job DSL. I never optimized that and I have no idea what the hot spots are. Can you attach a profiler to Jenkins or take some thread dumps while your seed job is running?"}}