{"action":"created","issue":{"url":"https://api.github.com/repos/elastic/beats/issues/864","labels_url":"https://api.github.com/repos/elastic/beats/issues/864/labels{/name}","comments_url":"https://api.github.com/repos/elastic/beats/issues/864/comments","events_url":"https://api.github.com/repos/elastic/beats/issues/864/events","html_url":"https://github.com/elastic/beats/pull/864","id":129100983,"number":864,"title":"update mockbeat to reveals a data race when stopping the application","user":{"login":"cyrilleverrier","id":16701739,"avatar_url":"https://avatars.githubusercontent.com/u/16701739?v=3","gravatar_id":"","url":"https://api.github.com/users/cyrilleverrier","html_url":"https://github.com/cyrilleverrier","followers_url":"https://api.github.com/users/cyrilleverrier/followers","following_url":"https://api.github.com/users/cyrilleverrier/following{/other_user}","gists_url":"https://api.github.com/users/cyrilleverrier/gists{/gist_id}","starred_url":"https://api.github.com/users/cyrilleverrier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cyrilleverrier/subscriptions","organizations_url":"https://api.github.com/users/cyrilleverrier/orgs","repos_url":"https://api.github.com/users/cyrilleverrier/repos","events_url":"https://api.github.com/users/cyrilleverrier/events{/privacy}","received_events_url":"https://api.github.com/users/cyrilleverrier/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-01-27T10:33:42Z","updated_at":"2016-01-27T10:42:29Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/elastic/beats/pulls/864","html_url":"https://github.com/elastic/beats/pull/864","diff_url":"https://github.com/elastic/beats/pull/864.diff","patch_url":"https://github.com/elastic/beats/pull/864.patch"},"body":"When this patch is applied, running \r\n```\r\ncd $GOPATH/src/github.com/elastic/beats/libbeat/\r\nRACE_DETECTOR=1 make system-tests\r\n```\r\n\r\nThis triggers the following data race detection:\r\n```\r\n2016/01/27 10:22:46.388070 beat.go:242: DBG  Initializing output plugins\r\n2016/01/27 10:22:46.388145 geolite.go:30: INFO GeoIP disabled: No paths were set under output.geoip.paths\r\n2016/01/27 10:22:46.388186 file.go:48: INFO File output base filename set to: mockbeat\r\n2016/01/27 10:22:46.388219 file.go:60: INFO Rotate every bytes set to: 1024000\r\n2016/01/27 10:22:46.388245 file.go:69: INFO Number of files set to: 7\r\n2016/01/27 10:22:46.388350 outputs.go:129: INFO Activated file as output plugin.\r\n2016/01/27 10:22:46.388379 publish.go:273: DBG  Create output worker\r\n2016/01/27 10:22:46.388552 publish.go:327: DBG  No output is defined to store the topology. The server fields might not be filled.\r\n2016/01/27 10:22:46.388603 publish.go:347: INFO Publisher name: dell\r\n2016/01/27 10:22:46.388925 async.go:91: INFO Flush Interval set to: -1ms\r\n2016/01/27 10:22:46.388954 async.go:99: INFO Max Bulk Size set to: -1\r\n2016/01/27 10:22:46.388993 beat.go:254: INFO Init Beat: mockbeat; Version: 9.9.9\r\n2016/01/27 10:22:46.389394 beat.go:283: INFO mockbeat sucessfully setup. Start running.\r\n2016/01/27 10:22:46.471014 service.go:33: DBG  Received sigterm/sigint, stopping\r\n2016/01/27 10:22:46.471087 beat.go:333: INFO Start exiting beat\r\n2016/01/27 10:22:46.471137 beat.go:301: INFO Stopping Beat\r\n==================\r\nWARNING: DATA RACE\r\nRead by goroutine 8:\r\n  github.com/elastic/beats/libbeat/beat.(*Beat).Stop()\r\n      github.com/elastic/beats/libbeat/beat/_obj/beat.go:303 +0x9a\r\n  github.com/elastic/beats/libbeat/beat.Run()\r\n      github.com/elastic/beats/libbeat/beat/_obj/beat.go:145 +0x144\r\n  github.com/elastic/beats/libbeat.main()\r\n      github.com/elastic/beats/libbeat/_test/_obj_test/libbeat.go:14 +0xd3\r\n  github.com/elastic/beats/libbeat.TestSystem()\r\n      /home/cyrille/code/go/workspace/src/github.com/elastic/beats/libbeat/libbeat_test.go:17 +0x54\r\n  testing.tRunner()\r\n      /usr/lib/go/src/testing/testing.go:456 +0xdc\r\n\r\nPrevious write by goroutine 9:\r\n  github.com/elastic/beats/libbeat/beat.(*Beat).Run()\r\n      github.com/elastic/beats/libbeat/beat/_obj/beat.go:285 +0x492\r\n  github.com/elastic/beats/libbeat/beat.(*Beat).Start()\r\n      github.com/elastic/beats/libbeat/beat/_obj/beat.go:186 +0x27e\r\n  github.com/elastic/beats/libbeat/beat.Run.func1()\r\n      github.com/elastic/beats/libbeat/beat/_obj/beat.go:127 +0x68\r\n\r\nGoroutine 8 (running) created at:\r\n  testing.RunTests()\r\n      /usr/lib/go/src/testing/testing.go:561 +0xaa3\r\n  testing.(*M).Run()\r\n      /usr/lib/go/src/testing/testing.go:494 +0xe4\r\n  main.main()\r\n      github.com/elastic/beats/libbeat/_test/_testmain.go:270 +0x38d\r\n\r\nGoroutine 9 (running) created at:\r\n  github.com/elastic/beats/libbeat/beat.Run()\r\n      github.com/elastic/beats/libbeat/beat/_obj/beat.go:139 +0xb6\r\n  github.com/elastic/beats/libbeat.main()\r\n      github.com/elastic/beats/libbeat/_test/_obj_test/libbeat.go:14 +0xd3\r\n  github.com/elastic/beats/libbeat.TestSystem()\r\n      /home/cyrille/code/go/workspace/src/github.com/elastic/beats/libbeat/libbeat_test.go:17 +0x54\r\n  testing.tRunner()\r\n      /usr/lib/go/src/testing/testing.go:456 +0xdc\r\n==================\r\n2016/01/27 10:22:46.471560 beat.go:311: INFO Cleaning up mockbeat before shutting down.\r\n2016/01/27 10:22:46.471679 beat.go:146: INFO Exit beat completed\r\nPASS\r\ncoverage: 11.3% of statements in github.com/elastic/beats/libbeat/...\r\nFound 1 data race(s)\r\n```\r\n\r\nThe variable `b.state` in `beat.go` is read and written by 2 go routines:  Run() and the go func started by Run()\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/elastic/beats/issues/comments/175545963","html_url":"https://github.com/elastic/beats/pull/864#issuecomment-175545963","issue_url":"https://api.github.com/repos/elastic/beats/issues/864","id":175545963,"user":{"login":"ruflin","id":244900,"avatar_url":"https://avatars.githubusercontent.com/u/244900?v=3","gravatar_id":"","url":"https://api.github.com/users/ruflin","html_url":"https://github.com/ruflin","followers_url":"https://api.github.com/users/ruflin/followers","following_url":"https://api.github.com/users/ruflin/following{/other_user}","gists_url":"https://api.github.com/users/ruflin/gists{/gist_id}","starred_url":"https://api.github.com/users/ruflin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ruflin/subscriptions","organizations_url":"https://api.github.com/users/ruflin/orgs","repos_url":"https://api.github.com/users/ruflin/repos","events_url":"https://api.github.com/users/ruflin/events{/privacy}","received_events_url":"https://api.github.com/users/ruflin/received_events","type":"User","site_admin":false},"created_at":"2016-01-27T10:42:29Z","updated_at":"2016-01-27T10:42:29Z","body":"To fix this we should probably introduce a function updateState with a mutex."}}