{"action":"created","comment":{"url":"https://api.github.com/repos/apache/spark/pulls/comments/122847863","pull_request_review_id":44998475,"id":122847863,"diff_hunk":"@@ -31,7 +31,15 @@ inputCon <- socketConnection(\n     port = port, open = \"rb\", blocking = TRUE, timeout = connectionTimeout)\n \n while (TRUE) {\n-  ready <- socketSelect(list(inputCon))\n+  ready <- socketSelect(list(inputCon), timeout = 1)","path":"R/pkg/inst/worker/daemon.R","position":5,"original_position":5,"commit_id":"fa7a2261e915ae11f3c83139bcf8d9f62a5929c6","original_commit_id":"74deb2341ba2aabd58f280b5f7e463b6cad78c41","user":{"login":"shivaram","id":143893,"avatar_url":"https://avatars2.githubusercontent.com/u/143893?v=3","gravatar_id":"","url":"https://api.github.com/users/shivaram","html_url":"https://github.com/shivaram","followers_url":"https://api.github.com/users/shivaram/followers","following_url":"https://api.github.com/users/shivaram/following{/other_user}","gists_url":"https://api.github.com/users/shivaram/gists{/gist_id}","starred_url":"https://api.github.com/users/shivaram/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shivaram/subscriptions","organizations_url":"https://api.github.com/users/shivaram/orgs","repos_url":"https://api.github.com/users/shivaram/repos","events_url":"https://api.github.com/users/shivaram/events{/privacy}","received_events_url":"https://api.github.com/users/shivaram/received_events","type":"User","site_admin":false},"body":"To make my point a bit more clear, if there are no workers running, we can block on this `select` and dont need the one second timeout in that case ? ","created_at":"2017-06-19T23:17:32Z","updated_at":"2017-06-19T23:17:32Z","html_url":"https://github.com/apache/spark/pull/18320#discussion_r122847863","pull_request_url":"https://api.github.com/repos/apache/spark/pulls/18320","_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/comments/122847863"},"html":{"href":"https://github.com/apache/spark/pull/18320#discussion_r122847863"},"pull_request":{"href":"https://api.github.com/repos/apache/spark/pulls/18320"}}},"pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/18320","id":125949517,"html_url":"https://github.com/apache/spark/pull/18320","diff_url":"https://github.com/apache/spark/pull/18320.diff","patch_url":"https://github.com/apache/spark/pull/18320.patch","issue_url":"https://api.github.com/repos/apache/spark/issues/18320","number":18320,"state":"open","locked":false,"title":"[SPARK-21093][R] Terminate R's worker processes in the parent of R's daemon to prevent a leak","user":{"login":"HyukjinKwon","id":6477701,"avatar_url":"https://avatars3.githubusercontent.com/u/6477701?v=3","gravatar_id":"","url":"https://api.github.com/users/HyukjinKwon","html_url":"https://github.com/HyukjinKwon","followers_url":"https://api.github.com/users/HyukjinKwon/followers","following_url":"https://api.github.com/users/HyukjinKwon/following{/other_user}","gists_url":"https://api.github.com/users/HyukjinKwon/gists{/gist_id}","starred_url":"https://api.github.com/users/HyukjinKwon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HyukjinKwon/subscriptions","organizations_url":"https://api.github.com/users/HyukjinKwon/orgs","repos_url":"https://api.github.com/users/HyukjinKwon/repos","events_url":"https://api.github.com/users/HyukjinKwon/events{/privacy}","received_events_url":"https://api.github.com/users/HyukjinKwon/received_events","type":"User","site_admin":false},"body":"## What changes were proposed in this pull request?\r\n\r\n`mcfork` in R looks opening a pipe ahead but the existing logic does not properly close it when it is executed hot. This leads to the failure of more forking due to the limit for number of files open.\r\n\r\nThis hot execution looks particularly for `gapply`/`gapplyCollect`. For unknown reason, this happens more easily in CentOS and could be reproduced in Mac too.\r\n\r\nAll the details are described in https://issues.apache.org/jira/browse/SPARK-21093\r\n\r\nThis PR proposes simply to terminate R's worker processes in the parent of R's daemon to prevent a leak.\r\n\r\n## How was this patch tested?\r\n\r\nI ran the codes below on both CentOS and Mac with that configuration disabled/enabled.\r\n\r\n```r\r\ndf <- createDataFrame(list(list(1L, 1, \"1\", 0.1)), c(\"a\", \"b\", \"c\", \"d\"))\r\ncollect(gapply(df, \"a\", function(key, x) { x }, schema(df)))\r\ncollect(gapply(df, \"a\", function(key, x) { x }, schema(df)))\r\n...  # 30 times\r\n```\r\n\r\nAlso, now it passes R tests on CentOS as below:\r\n\r\n```\r\nSparkSQL functions: Spark package found in SPARK_HOME: .../spark\r\n..............................................................................................................................................................\r\n..............................................................................................................................................................\r\n..............................................................................................................................................................\r\n..............................................................................................................................................................\r\n..............................................................................................................................................................\r\n....................................................................................................................................\r\n```\r\n","created_at":"2017-06-16T02:45:59Z","updated_at":"2017-06-19T23:17:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5332d3c07a3b0802abce1fe10f9c4e9bd3179833","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/apache/spark/pulls/18320/commits","review_comments_url":"https://api.github.com/repos/apache/spark/pulls/18320/comments","review_comment_url":"https://api.github.com/repos/apache/spark/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/spark/issues/18320/comments","statuses_url":"https://api.github.com/repos/apache/spark/statuses/fa7a2261e915ae11f3c83139bcf8d9f62a5929c6","head":{"label":"HyukjinKwon:SPARK-21093","ref":"SPARK-21093","sha":"fa7a2261e915ae11f3c83139bcf8d9f62a5929c6","user":{"login":"HyukjinKwon","id":6477701,"avatar_url":"https://avatars3.githubusercontent.com/u/6477701?v=3","gravatar_id":"","url":"https://api.github.com/users/HyukjinKwon","html_url":"https://github.com/HyukjinKwon","followers_url":"https://api.github.com/users/HyukjinKwon/followers","following_url":"https://api.github.com/users/HyukjinKwon/following{/other_user}","gists_url":"https://api.github.com/users/HyukjinKwon/gists{/gist_id}","starred_url":"https://api.github.com/users/HyukjinKwon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HyukjinKwon/subscriptions","organizations_url":"https://api.github.com/users/HyukjinKwon/orgs","repos_url":"https://api.github.com/users/HyukjinKwon/repos","events_url":"https://api.github.com/users/HyukjinKwon/events{/privacy}","received_events_url":"https://api.github.com/users/HyukjinKwon/received_events","type":"User","site_admin":false},"repo":{"id":42300713,"name":"spark","full_name":"HyukjinKwon/spark","owner":{"login":"HyukjinKwon","id":6477701,"avatar_url":"https://avatars3.githubusercontent.com/u/6477701?v=3","gravatar_id":"","url":"https://api.github.com/users/HyukjinKwon","html_url":"https://github.com/HyukjinKwon","followers_url":"https://api.github.com/users/HyukjinKwon/followers","following_url":"https://api.github.com/users/HyukjinKwon/following{/other_user}","gists_url":"https://api.github.com/users/HyukjinKwon/gists{/gist_id}","starred_url":"https://api.github.com/users/HyukjinKwon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HyukjinKwon/subscriptions","organizations_url":"https://api.github.com/users/HyukjinKwon/orgs","repos_url":"https://api.github.com/users/HyukjinKwon/repos","events_url":"https://api.github.com/users/HyukjinKwon/events{/privacy}","received_events_url":"https://api.github.com/users/HyukjinKwon/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/HyukjinKwon/spark","description":"Mirror of Apache Spark","fork":true,"url":"https://api.github.com/repos/HyukjinKwon/spark","forks_url":"https://api.github.com/repos/HyukjinKwon/spark/forks","keys_url":"https://api.github.com/repos/HyukjinKwon/spark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/HyukjinKwon/spark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/HyukjinKwon/spark/teams","hooks_url":"https://api.github.com/repos/HyukjinKwon/spark/hooks","issue_events_url":"https://api.github.com/repos/HyukjinKwon/spark/issues/events{/number}","events_url":"https://api.github.com/repos/HyukjinKwon/spark/events","assignees_url":"https://api.github.com/repos/HyukjinKwon/spark/assignees{/user}","branches_url":"https://api.github.com/repos/HyukjinKwon/spark/branches{/branch}","tags_url":"https://api.github.com/repos/HyukjinKwon/spark/tags","blobs_url":"https://api.github.com/repos/HyukjinKwon/spark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/HyukjinKwon/spark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/HyukjinKwon/spark/git/refs{/sha}","trees_url":"https://api.github.com/repos/HyukjinKwon/spark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/HyukjinKwon/spark/statuses/{sha}","languages_url":"https://api.github.com/repos/HyukjinKwon/spark/languages","stargazers_url":"https://api.github.com/repos/HyukjinKwon/spark/stargazers","contributors_url":"https://api.github.com/repos/HyukjinKwon/spark/contributors","subscribers_url":"https://api.github.com/repos/HyukjinKwon/spark/subscribers","subscription_url":"https://api.github.com/repos/HyukjinKwon/spark/subscription","commits_url":"https://api.github.com/repos/HyukjinKwon/spark/commits{/sha}","git_commits_url":"https://api.github.com/repos/HyukjinKwon/spark/git/commits{/sha}","comments_url":"https://api.github.com/repos/HyukjinKwon/spark/comments{/number}","issue_comment_url":"https://api.github.com/repos/HyukjinKwon/spark/issues/comments{/number}","contents_url":"https://api.github.com/repos/HyukjinKwon/spark/contents/{+path}","compare_url":"https://api.github.com/repos/HyukjinKwon/spark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/HyukjinKwon/spark/merges","archive_url":"https://api.github.com/repos/HyukjinKwon/spark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/HyukjinKwon/spark/downloads","issues_url":"https://api.github.com/repos/HyukjinKwon/spark/issues{/number}","pulls_url":"https://api.github.com/repos/HyukjinKwon/spark/pulls{/number}","milestones_url":"https://api.github.com/repos/HyukjinKwon/spark/milestones{/number}","notifications_url":"https://api.github.com/repos/HyukjinKwon/spark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/HyukjinKwon/spark/labels{/name}","releases_url":"https://api.github.com/repos/HyukjinKwon/spark/releases{/id}","deployments_url":"https://api.github.com/repos/HyukjinKwon/spark/deployments","created_at":"2015-09-11T09:47:43Z","updated_at":"2016-04-11T01:30:54Z","pushed_at":"2017-06-19T12:21:55Z","git_url":"git://github.com/HyukjinKwon/spark.git","ssh_url":"git@github.com:HyukjinKwon/spark.git","clone_url":"https://github.com/HyukjinKwon/spark.git","svn_url":"https://github.com/HyukjinKwon/spark","homepage":null,"size":273946,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"apache:master","ref":"master","sha":"edcb878e2fbd0d85bf70614fed37f4cbf0caa95e","user":{"login":"apache","id":47359,"avatar_url":"https://avatars3.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"repo":{"id":17165658,"name":"spark","full_name":"apache/spark","owner":{"login":"apache","id":47359,"avatar_url":"https://avatars3.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apache/spark","description":"Mirror of Apache Spark","fork":false,"url":"https://api.github.com/repos/apache/spark","forks_url":"https://api.github.com/repos/apache/spark/forks","keys_url":"https://api.github.com/repos/apache/spark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/spark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/spark/teams","hooks_url":"https://api.github.com/repos/apache/spark/hooks","issue_events_url":"https://api.github.com/repos/apache/spark/issues/events{/number}","events_url":"https://api.github.com/repos/apache/spark/events","assignees_url":"https://api.github.com/repos/apache/spark/assignees{/user}","branches_url":"https://api.github.com/repos/apache/spark/branches{/branch}","tags_url":"https://api.github.com/repos/apache/spark/tags","blobs_url":"https://api.github.com/repos/apache/spark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/spark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/spark/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/spark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/spark/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/spark/languages","stargazers_url":"https://api.github.com/repos/apache/spark/stargazers","contributors_url":"https://api.github.com/repos/apache/spark/contributors","subscribers_url":"https://api.github.com/repos/apache/spark/subscribers","subscription_url":"https://api.github.com/repos/apache/spark/subscription","commits_url":"https://api.github.com/repos/apache/spark/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/spark/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/spark/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/spark/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/spark/contents/{+path}","compare_url":"https://api.github.com/repos/apache/spark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/spark/merges","archive_url":"https://api.github.com/repos/apache/spark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/spark/downloads","issues_url":"https://api.github.com/repos/apache/spark/issues{/number}","pulls_url":"https://api.github.com/repos/apache/spark/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/spark/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/spark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/spark/labels{/name}","releases_url":"https://api.github.com/repos/apache/spark/releases{/id}","deployments_url":"https://api.github.com/repos/apache/spark/deployments","created_at":"2014-02-25T08:00:08Z","updated_at":"2017-06-19T21:09:35Z","pushed_at":"2017-06-19T23:06:47Z","git_url":"git://github.com/apache/spark.git","ssh_url":"git@github.com:apache/spark.git","clone_url":"https://github.com/apache/spark.git","svn_url":"https://github.com/apache/spark","homepage":null,"size":277155,"stargazers_count":13227,"watchers_count":13227,"language":"Scala","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":12471,"mirror_url":"git://git.apache.org/spark.git","open_issues_count":429,"forks":12471,"open_issues":429,"watchers":13227,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/18320"},"html":{"href":"https://github.com/apache/spark/pull/18320"},"issue":{"href":"https://api.github.com/repos/apache/spark/issues/18320"},"comments":{"href":"https://api.github.com/repos/apache/spark/issues/18320/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/spark/pulls/18320/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/spark/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/spark/pulls/18320/commits"},"statuses":{"href":"https://api.github.com/repos/apache/spark/statuses/fa7a2261e915ae11f3c83139bcf8d9f62a5929c6"}}}}
{"actor":{"display_login":"shivaram"}}