{"id":4067,"date":"2020-09-22T16:15:52","date_gmt":"2020-09-22T08:15:52","guid":{"rendered":"https:\/\/nj.transwarp.cn:8180\/?p=4067"},"modified":"2025-07-31T15:17:47","modified_gmt":"2025-07-31T07:17:47","slug":"mapjoin%e4%b8%8bexecutorlostfailure%e9%97%ae%e9%a2%98","status":"publish","type":"post","link":"https:\/\/kbwp.transwarp.cn\/?p=4067","title":{"rendered":"mapjoin\u4e0bExecutorLostFailure\u95ee\u9898"},"content":{"rendered":"<h3>\u6982\u8981\u63cf\u8ff0<\/h3>\n<hr \/>\n<p><strong>MapJoin\u662fHive\u7684\u4e00\u79cd\u4f18\u5316\u64cd\u4f5c\uff0c\u5176\u9002\u7528\u4e8e\u5c0f\u8868JOIN\u5927\u8868\u7684\u573a\u666f\uff0c\u7531\u4e8e\u8868\u7684JOIN\u64cd\u4f5c\u662f\u5728Map\u7aef\u4e14\u5728\u5185\u5b58\u8fdb\u884c\u7684\uff0c\u6240\u4ee5\u5176\u5e76\u4e0d\u9700\u8981\u542f\u52a8Reduce\u4efb\u52a1\u4e5f\u5c31\u4e0d\u9700\u8981\u7ecf\u8fc7shuffle\u9636\u6bb5\uff0c\u4ece\u800c\u80fd\u5728\u4e00\u5b9a\u7a0b\u5ea6\u4e0a\u8282\u7701\u8d44\u6e90\u63d0\u9ad8JOIN\u6548\u7387\u3002<\/strong><\/p>\n<p>\u53ef\u4ee5\u6709\u5982\u4e0b2\u79cd\u65b9\u5f0f\u89e6\u53d1mapjoin<\/p>\n<ol>\n<li>\u624b\u5de5\u52a0Mapjoin hint\u7684\u65b9\u5f0f<\/li>\n<li>\u81ea\u52a8\u8f6c\u6362\u7684\u65b9\u5f0f\n<ul>\n<li>SET ngmr.mapjoin.autoconvert            \uff1a\u63a7\u5236\u5f00\u5173\uff0c\u9ed8\u8ba4\u4e3atrue<\/li>\n<li>SET hive.mapjoin.smalltable.filesize\uff1a  \uff1a\u6839\u636e\u5c0f\u8868\u5728HDFS\u4e0a\u7684\u5927\u5c0f\u5224\u65ad\u662f\u5426\u505amapjoin<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p>\u800c\u901a\u8fc7\u81ea\u52a8\u8f6c\u6362\u7684\u65b9\u5f0f\u5927\u5bb6\u53ef\u4ee5\u770b\u5230\uff0c<strong><font color=red>\u7531\u4e8eORC\u6587\u4ef6\u662fzlib\u5217\u5f0f\u5b58\u50a8\u4e0b\u538b\u7f29\u7684\uff0c\u901a\u5e38\u57283X\u5de6\u53f3\uff0c\u5982\u679c\u5e93\u91cc\u9762\u6709\u5927\u91cf\u91cd\u590d\u7684\u6570\u636e\uff0c\u538b\u7f29\u6bd4\u4f1a\u975e\u5e38\u9ad8\uff0c\u5bfc\u81f4\u4e00\u4e2a\u5343\u4e07\u884c\u7684\u8868\u88ab\u4f5c\u4e3a\u5c0f\u8868\uff0c\u5f53\u5efaHash\u8868\u65f6\uff0c\u5185\u5b58\u5c31\u7206\u6389\u4e86\uff0c\u8fd9\u4e5f\u662f\u89e6\u53d1executor\u5f02\u5e38\u6700\u4e3b\u8981\u7684\u573a\u666f\u4e4b\u4e00\u3002<\/font><\/strong><\/p>\n<p>\u672c\u6587\u4e3b\u8981\u56f4\u7ed5\u8fd9\u4e2a\u6545\u969c\u573a\u666f\u6848\u4f8b\u4ece\u5b9e\u9645\u573a\u666f\u7684\u89d2\u5ea6\u8fdb\u884c\u6545\u969c\u6392\u67e5\uff0c\u5e0c\u671b\u80fd\u591f\u52a0\u6df1\u5927\u5bb6\u5bf9\u8be5\u95ee\u9898\u7684\u7406\u89e3\u3002<\/p>\n<h3>\u6545\u969c\u73b0\u8c61<\/h3>\n<hr \/>\n<p><strong>SQL\u6267\u884c\u62a5\u9519\uff0c<br \/>\n<font color=red>Job aborted due to stage failure: Task 4 in stage 466.2 failed 4 times, most recent failure: Lost task 4.3 in stage 466.2 (TID 10312, 10.50.52.35): ExecutorLostFailure (executor lost)<\/font><\/strong><\/p>\n<p><img decoding=\"async\" src=\"\/wp-content\/uploads\/2020\/09\/image-1600672790153.png\" alt=\"file\" \/><\/p>\n<p><strong>\u6267\u884c\u7684sql\u8bed\u53e5\uff1a<\/strong><\/p>\n<pre><code class=\"language-sql\">create table \ntemp_data.w_etlc_act6 STORED\n AS orc \n as \n select a.* ,\n coalesce(b.beat_p,0) beat_p ,\n coalesce(beat_p_b,0) beat_p_b ,\n coalesce(b.er_all,0) er_all ,\n coalesce(b.er_all_b,0) er_all_b ,\n coalesce(b.num_total,0) num_total ,\n coalesce(b.num_total_b,0) num_total_b ,\n coalesce(b.ttl_days_stk_gc,0) ttl_days_stk_gc ,\n coalesce(b.ttl_days_stk_gc_b,0) ttl_days_stk_gc_b ,\n coalesce(c.churn_n,0) churn_n ,\n d.fin_or_act \n from temp_data.w_etlc_act1 a \n left join temp_data.w_etlc_act2 b \n on a.client_id=b.client_id  and a.week_id=b.week_id \n left join temp_data.w_etlc_act3 c \n on a.client_id=c.client_id and a.week_id=c.week_id \n left join temp_data.w_etlc_act5 d \n on a.client_id=d.client_id<\/code><\/pre>\n<h3>\u6545\u969c\u6392\u67e5<\/h3>\n<hr \/>\n<h4>1. executor\u65e5\u5fd7\u5206\u6790<\/h4>\n<p>\u4e00\u822c\u6765\u8bf4\uff0c\u5bfc\u81f4executor\u53d1\u751ffull GC\u7684\u60c5\u51b5\u6bd4\u8f83\u5c11\uff0c\u6700\u5e38\u89c1\u7684\u5c31\u662fmapjoin\u7684\u5c0f\u8868\u592a\u5927\u4e86\uff0c\u5bfc\u81f4executor\u7aef\u6784\u5efa\u7684\u5c0f\u8868hashtable\u592a\u5927\uff0c\u9020\u6210\u5185\u5b58\u4f7f\u7528\u7206\u70b8\u3002<\/p>\n<p>\u901a\u8fc7\u5173\u952e\u5b57&quot;SmallTable disk size &quot;\u5728executor\u65e5\u5fd7\u4e2d\u8fdb\u884c\u641c\u7d22\uff0c\u7531\u4e8ehive.mapjoin.smalltable.filesize\u53c2\u6570\u9ed8\u8ba4\u4e3a25M\uff0c\u6240\u4ee51767917.2822265625 KBytes\u8fd9\u79cd\u8d85\u8fc71G\uff0cexecutor\u57fa\u672c\u5c31\u6302\u4e86\u3002<\/p>\n<p><img decoding=\"async\" src=\"\/wp-content\/uploads\/2020\/09\/image-1600673229750.png\" alt=\"file\" \/><\/p>\n<h4>2. server\u65e5\u5fd7\u5206\u6790<\/h4>\n<p>\u901a\u8fc7\u5173\u952e\u5b57&quot;For mapjoin autoconvert&quot;\u5728executor\u65e5\u5fd7\u4e2d\u8fdb\u884c\u641c\u7d22\u83b7\u53d6\u5230join\u76844\u5f20\u8868\u5728hdfs\u4e2d\u7684\u5927\u5c0f\uff0c\u53e6\u5916\u7ed3\u5408analyze\u547d\u4ee4\u83b7\u53d6numFiles\u3001numRows\u3001totalSize\u7b49\u4fe1\u606f<\/p>\n<table>\n<thead>\n<tr>\n<th style=\"text-align: left;\">TableName<\/th>\n<th style=\"text-align: left;\">numFiles<\/th>\n<th style=\"text-align: left;\">NumRows<\/th>\n<th style=\"text-align: left;\">TotalSize(byte)<\/th>\n<th style=\"text-align: left;\">TotalSize(Mb)<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align: left;\">temp_data.w_etlc_act1<\/td>\n<td style=\"text-align: left;\">90<\/td>\n<td style=\"text-align: left;\">54279997<\/td>\n<td style=\"text-align: left;\">164577007<\/td>\n<td style=\"text-align: left;\">157<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\">temp_data.w_etlc_act2<\/td>\n<td style=\"text-align: left;\">37<\/td>\n<td style=\"text-align: left;\">54859009<\/td>\n<td style=\"text-align: left;\">135889449<\/td>\n<td style=\"text-align: left;\">129<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\">temp_data.w_etlc_act3<\/td>\n<td style=\"text-align: left;\">62<\/td>\n<td style=\"text-align: left;\">54859009<\/td>\n<td style=\"text-align: left;\">13908288<\/td>\n<td style=\"text-align: left;\">13.2<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\">temp_data.w_etlc_act5<\/td>\n<td style=\"text-align: left;\">30<\/td>\n<td style=\"text-align: left;\">654587<\/td>\n<td style=\"text-align: left;\">3573763<\/td>\n<td style=\"text-align: left;\">3.40<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<pre><code class=\"language-shell\">Map Join Converter: Table temp_data.w_etlc_act1 => 164577007.                    \nMap Join Converter: Table temp_data.w_etlc_act2 => 1358894492.                   \nFor mapjoin autoconvert, the size of two join tables is 164577007 and 1358894492 \nMap Join Converter: Table temp_data.w_etlc_act3 => 13908288.                     \nFor mapjoin autoconvert, the size of two join tables is 3046942998 and 13908288  \nMap Join Converter: Table temp_data.w_etlc_act5 => 3573763.                      \nFor mapjoin autoconvert, the size of two join tables is 6121702572 and 3573763   \n<\/code><\/pre>\n<p>temp_data.w_etlc_act3\u5c0f\u8868\u663e\u793a\u4ec5\u4ec5\u53ea\u670913.3M\uff0c\u4e5f\u5c31\u662f\u8bf4\u5728HDFS\u4e2d\u5b9e\u9645\u5b58\u50a813.3M\uff0c\u4f46\u662f\u5728executor\u4e2d\u5360\u7528\u4e861.68G\uff0c\u731c\u6d4b\u8be5\u8868\u538b\u7f29\u6bd4\u975e\u5e38\u9ad8\uff0c\u91cd\u590d\u6570\u636e\u5f88\u591a.<\/p>\n<h4>3. \u68c0\u67e5\u8868\u7684\u91cd\u590d\u7387<\/h4>\n<p>\u68c0\u67e5\u8868\u7684\u91cd\u590d\u7387\u7684\u65b9\u6cd5\uff0c\u8fd9\u91cc\u5217\u4e3e2\u79cd<br \/>\na\u3001\u5229\u7528compute_stats\u51fd\u6570\u83b7\u53d6struct\u4e2d\u7684numdistinctvalues\uff0c\u6570\u503c\/\u603b\u6761\u6570\u7684\u6bd4\u7387\u8d8a\u5c11\uff0c\u4ee3\u8868\u91cd\u590d\u7387\u8d8a\u9ad8<\/p>\n<pre><code class=\"language-sql\">select \n    compute_stats(column_1).numdistinctvalues,\n    compute_stats(column_2).numdistinctvalues,\n    compute_stats(column_3).numdistinctvalues\n    ...\nfrom temp_data.w_etlc_act3;<\/code><\/pre>\n<p>b\u3001\u5229\u7528analyze table &#8230; for columns \u547d\u4ee4\u5bf9\u8868\u8fdb\u884c\u5143\u6570\u636e\u5206\u6790\uff0c\u5c06\u7ed3\u679c\u751f\u6210\u5230\u5143\u6570\u636e\u8868<\/p>\n<pre><code class=\"language-sql\">ANALYZE TABLE temp_data.w_etlc_act3 compute statistics for columns;<\/code><\/pre>\n<p>\u7136\u540e\u5230\u5143\u6570\u636e\u4e2d\u5173\u8054\u67e5\u8be2<\/p>\n<pre><code class=\"language-sql\">select t.TBL_NAME '\u8868\u540d',\n             d.<code>NAME<\/code> '\u5e93\u540d',\n             tcs.COLUMN_NAME '\u5b57\u6bb5\u540d',\n             NUM_NULLS*1.0\/tp.numRows '\u7a7a\u503c\u7387',\n             1-NUM_DISTINCTS*1.0\/tp.numRows '\u91cd\u590d\u5b57\u6bb5\u5360\u6bd4'\nfrom DBS d\n\/*DBS\u7684\u4e3b\u952eDB_ID*\/\ninner join TBLS t\n    on d.DB_ID = t.DB_ID\ninner join TAB_COL_STATS tcs\n    on t.TBL_ID=tcs.TBL_ID\nleft  join (\n    select TBL_ID,\n                \/*\u6587\u4ef6\u5b58\u50a8\u7684\u5927\u5c0f*\/\n                max(case PARAM_KEY when 'numRows'\n                        then PARAM_VALUE else 0 end) numRows\n    \/*TABLE_PARAMS \u8bb0\u5f55\u7684\u8868\u5c5e\u6027*\/\n    from TABLE_PARAMS\n    GROUP BY TBL_ID\n) tp\n  on t.TBL_ID=tp.TBL_ID\nwhere d.<code>NAME<\/code>='temp_data'  and t.TBL_NAME='w_etlc_act3';<\/code><\/pre>\n<p><strong>\u5ba2\u6237\u6839\u636e\u65b9\u6cd51\u83b7\u53d6\u5230temp_data.w_etlc_act3\u88683\u5217\u6570\u636e\u7684\u5217\u91cd\u590d\u503c\u6570\u91cf\uff0c\u8868\u603b\u6761\u657054859009\u884c\uff0cweek_id\u548cchurn_n\u5217\u7684\u503c\u53ea\u6709\u4e0d\u5230100\u4e2a\uff0c\u538b\u7f29\u6bd4\u5f88\u9ad8<\/strong><\/p>\n<pre><code class=\"language-sql\">> select \n    compute_stats(client_id).numdistinctvalues,\n    compute_stats(week_id).numdistinctvalues,\n    compute_stats(churn_n).numdistinctvalues \n    from temp_data.w_etlc_act3;\n+--------------------+--------------------+--------------------+\n| numdistinctvalues  | numdistinctvalues  | numdistinctvalues  |\n+--------------------+--------------------+--------------------+\n| 808974             | 93                 | 20                 |\n+--------------------+--------------------+--------------------+\n1 row selected (3.916 seconds)<\/code><\/pre>\n<h3>\u89e3\u51b3\u65b9\u6cd5<\/h3>\n<hr \/>\n<p>\u4e3a\u4e86\u907f\u514d\u51fa\u73b0\u4e0a\u8ff0\u95ee\u9898\uff0c\u9ad8\u7248\u672cinceptor\u964d\u4f4e\u4e86\u53c2\u6570 <code>hive.mapjoin.smalltable.filesize<\/code> \u7684\u503c\uff0c\u4ece\u539f\u6765\u7684 25000000 \u964d\u4f4e\u5230 5000000\uff0c\u5f88\u5927\u7a0b\u5ea6\u4e0a\u907f\u514d\u4e86\u8be5\u95ee\u9898\u7684\u53d1\u751f\u3002<\/p>\n<p>\u9000\u5316\u5230 <code>common join<\/code>\uff0c\u5982\u679c\u51fa\u73b0\u8ba1\u7b97\u503e\u659c\u95ee\u9898\uff0c\u53ef\u4ee5\u8003\u8651 \u65b0\u7248\u672c\u7684 <code>skewjoin<\/code> \u529f\u80fd\u3002<\/p>\n<p><strong>FAQ:<\/strong><\/p>\n<p>\u9644\u4e0a\u4e00\u4e2ajmap\u622a\u56fe\uff0cSeqKeyN\u5bf9\u8c61\u662f\u6784\u5efamapjoin\u5c0f\u8868\u65f6\u7528\u7684\uff0c\u51fa\u73b0\u8fc7\u591a\u7684\u8bdd\u53ef\u4ee5\u5224\u65ad\u662fmapjoin\u4e2d\u5c0f\u8868\u81a8\u80c0\u5bfc\u81f4\u7684\u3002<\/p>\n<p><img decoding=\"async\" src=\"\/wp-content\/uploads\/2020\/09\/image-1753946223013.png\" alt=\"file\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6982\u8981\u63cf\u8ff0 MapJoin\u662fHive\u7684\u4e00\u79cd\u4f18\u5316\u64cd\u4f5c\uff0c\u5176\u9002\u7528\u4e8e\u5c0f\u8868JOIN\u5927\u8868\u7684\u573a\u666f\uff0c\u7531\u4e8e\u8868\u7684JOIN\u64cd\u4f5c\u662f\u5728Ma ..<\/p>\n<div class=\"clear-fix\"><\/div>\n<p><a href=\"https:\/\/kbwp.transwarp.cn\/?p=4067\" title=\"read more...\">Read more<\/a><\/p>\n","protected":false},"author":12,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[40],"tags":[],"class_list":["post-4067","post","type-post","status-publish","format-standard","hentry","category-sql_issue"],"acf":[],"_links":{"self":[{"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts\/4067","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/users\/12"}],"replies":[{"embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4067"}],"version-history":[{"count":4,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts\/4067\/revisions"}],"predecessor-version":[{"id":17005,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts\/4067\/revisions\/17005"}],"wp:attachment":[{"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4067"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4067"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4067"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}