{"action":"created","comment":{"url":"https://api.github.com/repos/apache/spark/pulls/comments/90679120","pull_request_review_id":11198912,"id":90679120,"diff_hunk":"@@ -163,12 +164,20 @@ object SparkHadoopMapReduceWriter extends Logging {\n             outputMetricsAndBytesWrittenCallback, recordsWritten)\n           recordsWritten += 1\n         }\n-\n+        writer.close(taskContext)","path":"core/src/main/scala/org/apache/spark/internal/io/SparkHadoopMapReduceWriter.scala","position":22,"original_position":22,"commit_id":"9654fab9756350cc5dcb7c402673437a3b19e464","original_commit_id":"9654fab9756350cc5dcb7c402673437a3b19e464","user":{"login":"srowen","id":822522,"avatar_url":"https://avatars.githubusercontent.com/u/822522?v=3","gravatar_id":"","url":"https://api.github.com/users/srowen","html_url":"https://github.com/srowen","followers_url":"https://api.github.com/users/srowen/followers","following_url":"https://api.github.com/users/srowen/following{/other_user}","gists_url":"https://api.github.com/users/srowen/gists{/gist_id}","starred_url":"https://api.github.com/users/srowen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/srowen/subscriptions","organizations_url":"https://api.github.com/users/srowen/orgs","repos_url":"https://api.github.com/users/srowen/repos","events_url":"https://api.github.com/users/srowen/events{/privacy}","received_events_url":"https://api.github.com/users/srowen/received_events","type":"User","site_admin":false},"body":"Ah, but do you still want to null it here so that it doesn't also cause a close() in the catch block? the commit could fail.","created_at":"2016-12-02T16:58:21Z","updated_at":"2016-12-02T16:58:21Z","html_url":"https://github.com/apache/spark/pull/16098#discussion_r90679120","pull_request_url":"https://api.github.com/repos/apache/spark/pulls/16098","_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/comments/90679120"},"html":{"href":"https://github.com/apache/spark/pull/16098#discussion_r90679120"},"pull_request":{"href":"https://api.github.com/repos/apache/spark/pulls/16098"}}},"pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/16098","id":96055955,"html_url":"https://github.com/apache/spark/pull/16098","diff_url":"https://github.com/apache/spark/pull/16098.diff","patch_url":"https://github.com/apache/spark/pull/16098.patch","issue_url":"https://api.github.com/repos/apache/spark/issues/16098","number":16098,"state":"open","locked":false,"title":"[SPARK-18672][CORE] Close recordwriter in SparkHadoopMapReduceWriter before committing","user":{"login":"HyukjinKwon","id":6477701,"avatar_url":"https://avatars.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\nIt seems some APIs such as `PairRDDFunctions.saveAsHadoopDataset()` do not close the record writer before issuing the commit for the task.\r\n\r\nOn Windows, the output in the temp directory is being open and output committer tries to rename it from temp directory to the output directory after finishing writing. \r\n\r\nSo, it fails to move the file. It seems we should close the writer actually before committing the task like the other writers such as `FileFormatWriter`.\r\n\r\nIdentified failure was as below:\r\n\r\n```\r\nFAILURE! - in org.apache.spark.JavaAPISuite\r\nwriteWithNewAPIHadoopFile(org.apache.spark.JavaAPISuite)  Time elapsed: 0.25 sec  <<< ERROR!\r\norg.apache.spark.SparkException: Job aborted.\r\n\tat org.apache.spark.JavaAPISuite.writeWithNewAPIHadoopFile(JavaAPISuite.java:1231)\r\nCaused by: org.apache.spark.SparkException: \r\nJob aborted due to stage failure: Task 0 in stage 0.0 failed 1 times, most recent failure: Lost task 0.0 in stage 0.0 (TID 0, localhost, executor driver): org.apache.spark.SparkException: Task failed while writing rows\r\n\tat org.apache.spark.internal.io.SparkHadoopMapReduceWriter$.org$apache$spark$internal$io$SparkHadoopMapReduceWriter$$executeTask(SparkHadoopMapReduceWriter.scala:182)\r\n\tat org.apache.spark.internal.io.SparkHadoopMapReduceWriter$$anonfun$3.apply(SparkHadoopMapReduceWriter.scala:100)\r\n\tat org.apache.spark.internal.io.SparkHadoopMapReduceWriter$$anonfun$3.apply(SparkHadoopMapReduceWriter.scala:99)\r\n\tat org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:87)\r\n\tat org.apache.spark.scheduler.Task.run(Task.scala:108)\r\n\tat org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:282)\r\n\tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)\r\n\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)\r\n\tat java.lang.Thread.run(Thread.java:745)\r\nCaused by: java.io.IOException: Could not rename file:/C:/projects/spark/core/target/tmp/1480553515529-0/output/_temporary/0/_temporary/attempt_20161201005155_0000_r_000000_0 to file:/C:/projects/spark/core/target/tmp/1480553515529-0/output/_temporary/0/task_20161201005155_0000_r_000000\r\n\tat org.apache.hadoop.mapreduce.lib.output.FileOutputCommitter.commitTask(FileOutputCommitter.java:436)\r\n\tat org.apache.hadoop.mapreduce.lib.output.FileOutputCommitter.commitTask(FileOutputCommitter.java:415)\r\n\tat org.apache.spark.mapred.SparkHadoopMapRedUtil$.performCommit$1(SparkHadoopMapRedUtil.scala:50)\r\n\tat org.apache.spark.mapred.SparkHadoopMapRedUtil$.commitTask(SparkHadoopMapRedUtil.scala:76)\r\n\tat org.apache.spark.internal.io.HadoopMapReduceCommitProtocol.commitTask(HadoopMapReduceCommitProtocol.scala:153)\r\n\tat org.apache.spark.internal.io.SparkHadoopMapReduceWriter$$anonfun$4.apply(SparkHadoopMapReduceWriter.scala:167)\r\n\tat org.apache.spark.internal.io.SparkHadoopMapReduceWriter$$anonfun$4.apply(SparkHadoopMapReduceWriter.scala:156)\r\n\tat org.apache.spark.util.Utils$.tryWithSafeFinallyAndFailureCallbacks(Utils.scala:1341)\r\n\tat org.apache.spark.internal.io.SparkHadoopMapReduceWriter$.org$apache$spark$internal$io$SparkHadoopMapReduceWriter$$executeTask(SparkHadoopMapReduceWriter.scala:168)\r\n\t... 8 more\r\nDriver stacktrace:\r\n\tat org.apache.spark.JavaAPISuite.writeWithNewAPIHadoopFile(JavaAPISuite.java:1231)\r\nCaused by: org.apache.spark.SparkException: Task failed while writing rows\r\nCaused by: java.io.IOException: Could not rename file:/C:/projects/spark/core/target/tmp/1480553515529-0/output/_temporary/0/_temporary/attempt_20161201005155_0000_r_000000_0 to file:/C:/projects/spark/core/target/tmp/1480553515529-0/output/_temporary/0/task_20161201005155_0000_r_000000\r\n```\r\n\r\nThis PR proposes to close this before committing the task.\r\n\r\n## How was this patch tested?\r\n\r\nManually tested via AppVeyor. \r\n\r\n**Before**\r\n\r\nhttps://ci.appveyor.com/project/spark-test/spark/build/94-scala-tests\r\n\r\n**After**\r\n\r\nhttps://ci.appveyor.com/project/spark-test/spark/build/93-scala-tests\r\n\r\n\r\n","created_at":"2016-12-01T09:49:58Z","updated_at":"2016-12-02T16:58:21Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0277ce312fc2aaf00ecef56eec1874f5de80e477","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/apache/spark/pulls/16098/commits","review_comments_url":"https://api.github.com/repos/apache/spark/pulls/16098/comments","review_comment_url":"https://api.github.com/repos/apache/spark/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/spark/issues/16098/comments","statuses_url":"https://api.github.com/repos/apache/spark/statuses/9654fab9756350cc5dcb7c402673437a3b19e464","head":{"label":"HyukjinKwon:close-wirter-first","ref":"close-wirter-first","sha":"9654fab9756350cc5dcb7c402673437a3b19e464","user":{"login":"HyukjinKwon","id":6477701,"avatar_url":"https://avatars.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://avatars.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":"2016-12-02T16:50:24Z","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":253963,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"apache:master","ref":"master","sha":"2f8776ccad532fbed17381ff97d302007918b8d8","user":{"login":"apache","id":47359,"avatar_url":"https://avatars.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://avatars.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":"2016-12-02T09:59:31Z","pushed_at":"2016-12-02T16:50:26Z","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":618042,"stargazers_count":10945,"watchers_count":10945,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":10220,"mirror_url":"git://git.apache.org/spark.git","open_issues_count":448,"forks":10220,"open_issues":448,"watchers":10945,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/16098"},"html":{"href":"https://github.com/apache/spark/pull/16098"},"issue":{"href":"https://api.github.com/repos/apache/spark/issues/16098"},"comments":{"href":"https://api.github.com/repos/apache/spark/issues/16098/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/spark/pulls/16098/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/spark/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/spark/pulls/16098/commits"},"statuses":{"href":"https://api.github.com/repos/apache/spark/statuses/9654fab9756350cc5dcb7c402673437a3b19e464"}}}}
{"actor":{"display_login":"srowen"}}