{"action":"created","comment":{"url":"https://api.github.com/repos/apache/spark/pulls/comments/91849698","pull_request_review_id":12361514,"id":91849698,"diff_hunk":"@@ -352,4 +353,28 @@ class PartitionedTablePerfStatsSuite\n       }\n     }\n   }\n+\n+  test(\"SPARK-18700: add lock for each table's realation in cache\") {\n+    withTable(\"test\") {\n+      withTempDir { dir =>\n+        HiveCatalogMetrics.reset()\n+        setupPartitionedHiveTable(\"test\", dir)\n+        // select the table in multi-threads\n+        val executorPool = Executors.newFixedThreadPool(10)\n+        (1 to 10).map(threadId => {\n+          val runnable = new Runnable {\n+            override def run(): Unit = {\n+              spark.sql(\"select * from test where partCol1 = 999\").count()\n+            }\n+          }\n+          executorPool.execute(runnable)\n+          None\n+        })\n+        executorPool.shutdown()\n+        executorPool.awaitTermination(30, TimeUnit.SECONDS)\n+        // check the cache hit, the cache only load once\n+        assert(HiveCatalogMetrics.METRIC_DATASOUCE_TABLE_CACHE_HITS.getCount() == 9)","path":"sql/hive/src/test/scala/org/apache/spark/sql/hive/PartitionedTablePerfStatsSuite.scala","position":32,"original_position":32,"commit_id":"276656e92614207be0a5918d9681ded6353edf98","original_commit_id":"82cf00e3522e90d153ed0d7481b838d415a8a383","user":{"login":"ericl","id":14922,"avatar_url":"https://avatars.githubusercontent.com/u/14922?v=3","gravatar_id":"","url":"https://api.github.com/users/ericl","html_url":"https://github.com/ericl","followers_url":"https://api.github.com/users/ericl/followers","following_url":"https://api.github.com/users/ericl/following{/other_user}","gists_url":"https://api.github.com/users/ericl/gists{/gist_id}","starred_url":"https://api.github.com/users/ericl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ericl/subscriptions","organizations_url":"https://api.github.com/users/ericl/orgs","repos_url":"https://api.github.com/users/ericl/repos","events_url":"https://api.github.com/users/ericl/events{/privacy}","received_events_url":"https://api.github.com/users/ericl/received_events","type":"User","site_admin":false},"body":"Yeah that's fine, as long as it fails some fraction of the time it will eventually show up as a flaky test.","created_at":"2016-12-11T07:21:19Z","updated_at":"2016-12-11T07:22:47Z","html_url":"https://github.com/apache/spark/pull/16135#discussion_r91849698","pull_request_url":"https://api.github.com/repos/apache/spark/pulls/16135","_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/comments/91849698"},"html":{"href":"https://github.com/apache/spark/pull/16135#discussion_r91849698"},"pull_request":{"href":"https://api.github.com/repos/apache/spark/pulls/16135"}}},"pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/16135","id":96423956,"html_url":"https://github.com/apache/spark/pull/16135","diff_url":"https://github.com/apache/spark/pull/16135.diff","patch_url":"https://github.com/apache/spark/pull/16135.patch","issue_url":"https://api.github.com/repos/apache/spark/issues/16135","number":16135,"state":"open","locked":false,"title":"[SPARK-18700][SQL] Add StripedLock for each table's relation in cache","user":{"login":"xuanyuanking","id":4833765,"avatar_url":"https://avatars.githubusercontent.com/u/4833765?v=3","gravatar_id":"","url":"https://api.github.com/users/xuanyuanking","html_url":"https://github.com/xuanyuanking","followers_url":"https://api.github.com/users/xuanyuanking/followers","following_url":"https://api.github.com/users/xuanyuanking/following{/other_user}","gists_url":"https://api.github.com/users/xuanyuanking/gists{/gist_id}","starred_url":"https://api.github.com/users/xuanyuanking/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xuanyuanking/subscriptions","organizations_url":"https://api.github.com/users/xuanyuanking/orgs","repos_url":"https://api.github.com/users/xuanyuanking/repos","events_url":"https://api.github.com/users/xuanyuanking/events{/privacy}","received_events_url":"https://api.github.com/users/xuanyuanking/received_events","type":"User","site_admin":false},"body":"## What changes were proposed in this pull request?\r\n\r\nAs the scenario describe in [SPARK-18700](https://issues.apache.org/jira/browse/SPARK-18700), when cachedDataSourceTables invalided, the coming few queries will fetch all FileStatus in listLeafFiles function. In the condition of table has many partitions, these jobs will occupy much memory of driver finally may cause driver OOM.\r\n\r\nIn this patch, add StripedLock for each table's relation in cache not for the whole cachedDataSourceTables, each table's load cache operation protected by it.\r\n\r\n## How was this patch tested?\r\n\r\nAdd a multi-thread access table test in `PartitionedTablePerfStatsSuite` and cacheHit metrics in `HiveCatalogMetrics`\r\n\r\n","created_at":"2016-12-04T06:52:27Z","updated_at":"2016-12-11T07:22:47Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d2405bffa2fb663d0f70ee1d6414cb068433f944","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/apache/spark/pulls/16135/commits","review_comments_url":"https://api.github.com/repos/apache/spark/pulls/16135/comments","review_comment_url":"https://api.github.com/repos/apache/spark/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/spark/issues/16135/comments","statuses_url":"https://api.github.com/repos/apache/spark/statuses/276656e92614207be0a5918d9681ded6353edf98","head":{"label":"xuanyuanking:SPARK-18700","ref":"SPARK-18700","sha":"276656e92614207be0a5918d9681ded6353edf98","user":{"login":"xuanyuanking","id":4833765,"avatar_url":"https://avatars.githubusercontent.com/u/4833765?v=3","gravatar_id":"","url":"https://api.github.com/users/xuanyuanking","html_url":"https://github.com/xuanyuanking","followers_url":"https://api.github.com/users/xuanyuanking/followers","following_url":"https://api.github.com/users/xuanyuanking/following{/other_user}","gists_url":"https://api.github.com/users/xuanyuanking/gists{/gist_id}","starred_url":"https://api.github.com/users/xuanyuanking/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xuanyuanking/subscriptions","organizations_url":"https://api.github.com/users/xuanyuanking/orgs","repos_url":"https://api.github.com/users/xuanyuanking/repos","events_url":"https://api.github.com/users/xuanyuanking/events{/privacy}","received_events_url":"https://api.github.com/users/xuanyuanking/received_events","type":"User","site_admin":false},"repo":{"id":52511431,"name":"spark","full_name":"xuanyuanking/spark","owner":{"login":"xuanyuanking","id":4833765,"avatar_url":"https://avatars.githubusercontent.com/u/4833765?v=3","gravatar_id":"","url":"https://api.github.com/users/xuanyuanking","html_url":"https://github.com/xuanyuanking","followers_url":"https://api.github.com/users/xuanyuanking/followers","following_url":"https://api.github.com/users/xuanyuanking/following{/other_user}","gists_url":"https://api.github.com/users/xuanyuanking/gists{/gist_id}","starred_url":"https://api.github.com/users/xuanyuanking/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xuanyuanking/subscriptions","organizations_url":"https://api.github.com/users/xuanyuanking/orgs","repos_url":"https://api.github.com/users/xuanyuanking/repos","events_url":"https://api.github.com/users/xuanyuanking/events{/privacy}","received_events_url":"https://api.github.com/users/xuanyuanking/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/xuanyuanking/spark","description":"Mirror of Apache Spark","fork":true,"url":"https://api.github.com/repos/xuanyuanking/spark","forks_url":"https://api.github.com/repos/xuanyuanking/spark/forks","keys_url":"https://api.github.com/repos/xuanyuanking/spark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/xuanyuanking/spark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/xuanyuanking/spark/teams","hooks_url":"https://api.github.com/repos/xuanyuanking/spark/hooks","issue_events_url":"https://api.github.com/repos/xuanyuanking/spark/issues/events{/number}","events_url":"https://api.github.com/repos/xuanyuanking/spark/events","assignees_url":"https://api.github.com/repos/xuanyuanking/spark/assignees{/user}","branches_url":"https://api.github.com/repos/xuanyuanking/spark/branches{/branch}","tags_url":"https://api.github.com/repos/xuanyuanking/spark/tags","blobs_url":"https://api.github.com/repos/xuanyuanking/spark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/xuanyuanking/spark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/xuanyuanking/spark/git/refs{/sha}","trees_url":"https://api.github.com/repos/xuanyuanking/spark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/xuanyuanking/spark/statuses/{sha}","languages_url":"https://api.github.com/repos/xuanyuanking/spark/languages","stargazers_url":"https://api.github.com/repos/xuanyuanking/spark/stargazers","contributors_url":"https://api.github.com/repos/xuanyuanking/spark/contributors","subscribers_url":"https://api.github.com/repos/xuanyuanking/spark/subscribers","subscription_url":"https://api.github.com/repos/xuanyuanking/spark/subscription","commits_url":"https://api.github.com/repos/xuanyuanking/spark/commits{/sha}","git_commits_url":"https://api.github.com/repos/xuanyuanking/spark/git/commits{/sha}","comments_url":"https://api.github.com/repos/xuanyuanking/spark/comments{/number}","issue_comment_url":"https://api.github.com/repos/xuanyuanking/spark/issues/comments{/number}","contents_url":"https://api.github.com/repos/xuanyuanking/spark/contents/{+path}","compare_url":"https://api.github.com/repos/xuanyuanking/spark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/xuanyuanking/spark/merges","archive_url":"https://api.github.com/repos/xuanyuanking/spark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/xuanyuanking/spark/downloads","issues_url":"https://api.github.com/repos/xuanyuanking/spark/issues{/number}","pulls_url":"https://api.github.com/repos/xuanyuanking/spark/pulls{/number}","milestones_url":"https://api.github.com/repos/xuanyuanking/spark/milestones{/number}","notifications_url":"https://api.github.com/repos/xuanyuanking/spark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/xuanyuanking/spark/labels{/name}","releases_url":"https://api.github.com/repos/xuanyuanking/spark/releases{/id}","deployments_url":"https://api.github.com/repos/xuanyuanking/spark/deployments","created_at":"2016-02-25T09:08:00Z","updated_at":"2016-02-25T09:08:28Z","pushed_at":"2016-12-11T07:03:48Z","git_url":"git://github.com/xuanyuanking/spark.git","ssh_url":"git@github.com:xuanyuanking/spark.git","clone_url":"https://github.com/xuanyuanking/spark.git","svn_url":"https://github.com/xuanyuanking/spark","homepage":null,"size":252160,"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":"edb0ad9d486427fa983923fde5d4987c863ca31e","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-11T02:40:01Z","pushed_at":"2016-12-11T07:15:43Z","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":621526,"stargazers_count":11030,"watchers_count":11030,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":10325,"mirror_url":"git://git.apache.org/spark.git","open_issues_count":447,"forks":10325,"open_issues":447,"watchers":11030,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/16135"},"html":{"href":"https://github.com/apache/spark/pull/16135"},"issue":{"href":"https://api.github.com/repos/apache/spark/issues/16135"},"comments":{"href":"https://api.github.com/repos/apache/spark/issues/16135/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/spark/pulls/16135/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/spark/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/spark/pulls/16135/commits"},"statuses":{"href":"https://api.github.com/repos/apache/spark/statuses/276656e92614207be0a5918d9681ded6353edf98"}}}}
{"actor":{"display_login":"ericl"}}