{"action":"created","comment":{"url":"https://api.github.com/repos/apache/spark/pulls/comments/312436149","pull_request_review_id":273082324,"id":312436149,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDMxMjQzNjE0OQ==","diff_hunk":"@@ -114,27 +116,42 @@ class HDFSMetadataLog[T <: AnyRef : ClassTag](sparkSession: SparkSession, path:\n     }\n   }\n \n-  /** Write a batch to a temp file then rename it to the batch file.\n+  private def writeBatchToFile(metadata: T, path: Path): Unit = {\n+    writeBatchToFileWithRetries(metadata, path)\n+  }\n+\n+  /**\n+   * Write a batch to a temp file then rename it to the batch file.\n    *\n    * There may be multiple [[HDFSMetadataLog]] using the same metadata path. Although it is not a\n    * valid behavior, we still need to prevent it from destroying the files.\n    */\n-  private def writeBatchToFile(metadata: T, path: Path): Unit = {\n-    val output = fileManager.createAtomic(path, overwriteIfPossible = false)\n-    try {\n-      serialize(metadata, output)\n-      output.close()\n-    } catch {\n-      case e: FileAlreadyExistsException =>\n-        output.cancel()\n-        // If next batch file already exists, then another concurrently running query has\n-        // written it.\n-        throw new ConcurrentModificationException(\n-          s\"Multiple streaming queries are concurrently using $path\", e)\n-      case e: Throwable =>\n-        output.cancel()\n-        throw e\n-    }\n+  private def writeBatchToFileWithRetries(metadata: T, path: Path): Unit = {\n+    var retryCount = 0\n+    var isSuccess = false\n+    do {\n+      val output = fileManager.createAtomic(path, overwriteIfPossible = false)\n+      try {\n+        serialize(metadata, output)\n+        output.close()\n+        isSuccess = true\n+      } catch {\n+        case e: FileAlreadyExistsException =>\n+          output.cancel()\n+          // If next batch file already exists, then another concurrently running query has\n+          // written it.\n+          throw new ConcurrentModificationException(\n+            s\"Multiple streaming queries are concurrently using $path\", e)\n+        case e: Throwable =>\n+          output.cancel()\n+          if (retryCount >= metaDataNumRetries) {\n+            throw new IOException(","path":"sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/HDFSMetadataLog.scala","position":61,"original_position":59,"commit_id":"7baa3492ecba858fe1258f9b8c5bb7d64edea03d","original_commit_id":"e6c1bf6809a52c466adf88a32ce553d055a660cf","user":{"login":"ulysses-you","id":12025282,"node_id":"MDQ6VXNlcjEyMDI1Mjgy","avatar_url":"https://avatars0.githubusercontent.com/u/12025282?v=4","gravatar_id":"","url":"https://api.github.com/users/ulysses-you","html_url":"https://github.com/ulysses-you","followers_url":"https://api.github.com/users/ulysses-you/followers","following_url":"https://api.github.com/users/ulysses-you/following{/other_user}","gists_url":"https://api.github.com/users/ulysses-you/gists{/gist_id}","starred_url":"https://api.github.com/users/ulysses-you/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ulysses-you/subscriptions","organizations_url":"https://api.github.com/users/ulysses-you/orgs","repos_url":"https://api.github.com/users/ulysses-you/repos","events_url":"https://api.github.com/users/ulysses-you/events{/privacy}","received_events_url":"https://api.github.com/users/ulysses-you/received_events","type":"User","site_admin":false},"body":"Yeah, original exception is better. `CheckpointFileManager` can be customized so the exception is uncontrollable. ","created_at":"2019-08-09T11:21:30Z","updated_at":"2019-08-09T11:21:30Z","html_url":"https://github.com/apache/spark/pull/25333#discussion_r312436149","pull_request_url":"https://api.github.com/repos/apache/spark/pulls/25333","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/comments/312436149"},"html":{"href":"https://github.com/apache/spark/pull/25333#discussion_r312436149"},"pull_request":{"href":"https://api.github.com/repos/apache/spark/pulls/25333"}},"in_reply_to_id":311592688},"pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/25333","id":303615216,"node_id":"MDExOlB1bGxSZXF1ZXN0MzAzNjE1MjE2","html_url":"https://github.com/apache/spark/pull/25333","diff_url":"https://github.com/apache/spark/pull/25333.diff","patch_url":"https://github.com/apache/spark/pull/25333.patch","issue_url":"https://api.github.com/repos/apache/spark/issues/25333","number":25333,"state":"open","locked":false,"title":"[SPARK-28597][SS] Add config to retry spark streaming's meta log when it met error","user":{"login":"ulysses-you","id":12025282,"node_id":"MDQ6VXNlcjEyMDI1Mjgy","avatar_url":"https://avatars0.githubusercontent.com/u/12025282?v=4","gravatar_id":"","url":"https://api.github.com/users/ulysses-you","html_url":"https://github.com/ulysses-you","followers_url":"https://api.github.com/users/ulysses-you/followers","following_url":"https://api.github.com/users/ulysses-you/following{/other_user}","gists_url":"https://api.github.com/users/ulysses-you/gists{/gist_id}","starred_url":"https://api.github.com/users/ulysses-you/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ulysses-you/subscriptions","organizations_url":"https://api.github.com/users/ulysses-you/orgs","repos_url":"https://api.github.com/users/ulysses-you/repos","events_url":"https://api.github.com/users/ulysses-you/events{/privacy}","received_events_url":"https://api.github.com/users/ulysses-you/received_events","type":"User","site_admin":false},"body":"## What changes were proposed in this pull request?\r\n\r\nNow, HDFSMetaDataLog is the only implement of MetaDataLog. If HDFSMetaDataLog.writeBatchToFile() execute error, then total app will be terminated.\r\n\r\nThe meta data log is very important for spark, we should retry some times when exception, and add a config to control retry times.\r\n\r\nFor example HDFS has a bug that close error if has no enough replicas detail [HDFS-11486](https://issues.apache.org/jira/browse/HDFS-11486)\r\n\r\n## How was this patch tested?\r\n","created_at":"2019-08-02T02:14:54Z","updated_at":"2019-08-09T11:21:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":"63db9fbaa29303a07fc0bd76a4750665cfce4fb3","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":1406587328,"node_id":"MDU6TGFiZWwxNDA2NTg3MzI4","url":"https://api.github.com/repos/apache/spark/labels/STRUCTURED%20STREAMING","name":"STRUCTURED STREAMING","color":"ededed","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/apache/spark/pulls/25333/commits","review_comments_url":"https://api.github.com/repos/apache/spark/pulls/25333/comments","review_comment_url":"https://api.github.com/repos/apache/spark/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/spark/issues/25333/comments","statuses_url":"https://api.github.com/repos/apache/spark/statuses/7baa3492ecba858fe1258f9b8c5bb7d64edea03d","head":{"label":"ulysses-you:SPARK-28597","ref":"SPARK-28597","sha":"7baa3492ecba858fe1258f9b8c5bb7d64edea03d","user":{"login":"ulysses-you","id":12025282,"node_id":"MDQ6VXNlcjEyMDI1Mjgy","avatar_url":"https://avatars0.githubusercontent.com/u/12025282?v=4","gravatar_id":"","url":"https://api.github.com/users/ulysses-you","html_url":"https://github.com/ulysses-you","followers_url":"https://api.github.com/users/ulysses-you/followers","following_url":"https://api.github.com/users/ulysses-you/following{/other_user}","gists_url":"https://api.github.com/users/ulysses-you/gists{/gist_id}","starred_url":"https://api.github.com/users/ulysses-you/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ulysses-you/subscriptions","organizations_url":"https://api.github.com/users/ulysses-you/orgs","repos_url":"https://api.github.com/users/ulysses-you/repos","events_url":"https://api.github.com/users/ulysses-you/events{/privacy}","received_events_url":"https://api.github.com/users/ulysses-you/received_events","type":"User","site_admin":false},"repo":{"id":195747855,"node_id":"MDEwOlJlcG9zaXRvcnkxOTU3NDc4NTU=","name":"spark","full_name":"ulysses-you/spark","private":false,"owner":{"login":"ulysses-you","id":12025282,"node_id":"MDQ6VXNlcjEyMDI1Mjgy","avatar_url":"https://avatars0.githubusercontent.com/u/12025282?v=4","gravatar_id":"","url":"https://api.github.com/users/ulysses-you","html_url":"https://github.com/ulysses-you","followers_url":"https://api.github.com/users/ulysses-you/followers","following_url":"https://api.github.com/users/ulysses-you/following{/other_user}","gists_url":"https://api.github.com/users/ulysses-you/gists{/gist_id}","starred_url":"https://api.github.com/users/ulysses-you/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ulysses-you/subscriptions","organizations_url":"https://api.github.com/users/ulysses-you/orgs","repos_url":"https://api.github.com/users/ulysses-you/repos","events_url":"https://api.github.com/users/ulysses-you/events{/privacy}","received_events_url":"https://api.github.com/users/ulysses-you/received_events","type":"User","site_admin":false},"html_url":"https://github.com/ulysses-you/spark","description":"Apache Spark","fork":true,"url":"https://api.github.com/repos/ulysses-you/spark","forks_url":"https://api.github.com/repos/ulysses-you/spark/forks","keys_url":"https://api.github.com/repos/ulysses-you/spark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ulysses-you/spark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ulysses-you/spark/teams","hooks_url":"https://api.github.com/repos/ulysses-you/spark/hooks","issue_events_url":"https://api.github.com/repos/ulysses-you/spark/issues/events{/number}","events_url":"https://api.github.com/repos/ulysses-you/spark/events","assignees_url":"https://api.github.com/repos/ulysses-you/spark/assignees{/user}","branches_url":"https://api.github.com/repos/ulysses-you/spark/branches{/branch}","tags_url":"https://api.github.com/repos/ulysses-you/spark/tags","blobs_url":"https://api.github.com/repos/ulysses-you/spark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ulysses-you/spark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ulysses-you/spark/git/refs{/sha}","trees_url":"https://api.github.com/repos/ulysses-you/spark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ulysses-you/spark/statuses/{sha}","languages_url":"https://api.github.com/repos/ulysses-you/spark/languages","stargazers_url":"https://api.github.com/repos/ulysses-you/spark/stargazers","contributors_url":"https://api.github.com/repos/ulysses-you/spark/contributors","subscribers_url":"https://api.github.com/repos/ulysses-you/spark/subscribers","subscription_url":"https://api.github.com/repos/ulysses-you/spark/subscription","commits_url":"https://api.github.com/repos/ulysses-you/spark/commits{/sha}","git_commits_url":"https://api.github.com/repos/ulysses-you/spark/git/commits{/sha}","comments_url":"https://api.github.com/repos/ulysses-you/spark/comments{/number}","issue_comment_url":"https://api.github.com/repos/ulysses-you/spark/issues/comments{/number}","contents_url":"https://api.github.com/repos/ulysses-you/spark/contents/{+path}","compare_url":"https://api.github.com/repos/ulysses-you/spark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ulysses-you/spark/merges","archive_url":"https://api.github.com/repos/ulysses-you/spark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ulysses-you/spark/downloads","issues_url":"https://api.github.com/repos/ulysses-you/spark/issues{/number}","pulls_url":"https://api.github.com/repos/ulysses-you/spark/pulls{/number}","milestones_url":"https://api.github.com/repos/ulysses-you/spark/milestones{/number}","notifications_url":"https://api.github.com/repos/ulysses-you/spark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ulysses-you/spark/labels{/name}","releases_url":"https://api.github.com/repos/ulysses-you/spark/releases{/id}","deployments_url":"https://api.github.com/repos/ulysses-you/spark/deployments","created_at":"2019-07-08T06:11:57Z","updated_at":"2019-08-02T00:51:36Z","pushed_at":"2019-08-08T23:02:54Z","git_url":"git://github.com/ulysses-you/spark.git","ssh_url":"git@github.com:ulysses-you/spark.git","clone_url":"https://github.com/ulysses-you/spark.git","svn_url":"https://github.com/ulysses-you/spark","homepage":"","size":302349,"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":0,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"apache:master","ref":"master","sha":"4e7a4cd20e2f6e19b45fee6bfd24071ce4c88dd8","user":{"login":"apache","id":47359,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ3MzU5","avatar_url":"https://avatars0.githubusercontent.com/u/47359?v=4","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,"node_id":"MDEwOlJlcG9zaXRvcnkxNzE2NTY1OA==","name":"spark","full_name":"apache/spark","private":false,"owner":{"login":"apache","id":47359,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ3MzU5","avatar_url":"https://avatars0.githubusercontent.com/u/47359?v=4","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},"html_url":"https://github.com/apache/spark","description":"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":"2019-08-09T11:07:46Z","pushed_at":"2019-08-09T10:37:02Z","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":"","size":302967,"stargazers_count":22938,"watchers_count":22938,"language":"Scala","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":19730,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":519,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":19730,"open_issues":519,"watchers":22938,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/25333"},"html":{"href":"https://github.com/apache/spark/pull/25333"},"issue":{"href":"https://api.github.com/repos/apache/spark/issues/25333"},"comments":{"href":"https://api.github.com/repos/apache/spark/issues/25333/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/spark/pulls/25333/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/spark/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/spark/pulls/25333/commits"},"statuses":{"href":"https://api.github.com/repos/apache/spark/statuses/7baa3492ecba858fe1258f9b8c5bb7d64edea03d"}},"author_association":"NONE"}}
{"actor":{"display_login":"ulysses-you"}}