gbase 8a追踪产生笛卡尔积的具体sql
异常现象
SQL执行超时(超过8小时都未执行完),同时观察到节点产生大量临时物化文件。
分析过程:
查看临时文件存储:占用约3T空间,整个存储空间为10T,临时文件达到3T,很不正常。
[gbase@node01 cache_gbase]$ du -h /opt/gnode/tmpdata --max-depth=1
3.1T /opt/gnode/tmpdata/cache_gbase
4.0K /opt/gnode/tmpdata/krb5cc_gbase
3.1T /opt/gnode/tmpdata进一步查看临时文件:有大量临时物化文件,体量异常的大
1.8G -rw------- 1 gbase gbase 1.8G 11月 17 15:37 s0002665030_GB_MAT000051595EB60xcee99840.express_tmp
1.8G -rw------- 1 gbase gbase 1.8G 11月 17 15:39 s0002665030_GB_MAT0000517A3750x4a492e8c0.express_tmp
1.8G -rw------- 1 gbase gbase 1.8G 11月 17 15:39 s0002665030_GB_MAT0000513C8E20x4a49310c0.express_tmp
1.8G -rw------- 1 gbase gbase 1.8G 11月 17 15:39 s0002665030_GB_MAT0000520C07D0x291171c00.express_tmp
1.8G -rw------- 1 gbase gbase 1.8G 11月 17 15:39 s0002665030_GB_MAT000052086C30x1d6660f80.express_tmp
1.8G -rw------- 1 gbase gbase 1.8G 11月 17 15:41 s0002665030_GB_MAT0000546EDF720x4f879cc0.express_tmp
1.8G -rw------- 1 gbase gbase 1.8G 11月 17 15:41 s0002665030_GB_MAT0000543A41D40x4f879180.express_tmp
1.8G -rw------- 1 gbase gbase 1.8G 11月 17 15:43 s0002665030_GB_MAT0000523BDC10x13f3e6080.express_tmp
1.8G -rw------- 1 gbase gbase 1.8G 11月 17 15:43 s0002665030_GB_MAT000052595EB60xcee99840.express_tmp
1.8G -rw------- 1 gbase gbase 1.8G 11月 17 15:45 s0002665030_GB_MAT0000527A3750x4a492e8c0.express_tmp
1.8G -rw------- 1 gbase gbase 1.8G 11月 17 15:45 s0002665030_GB_MAT0000523C8E20x4a49310c0.express_tmp
1.8G -rw------- 1 gbase gbase 1.8G 11月 17 15:45 s0002665030_GB_MAT0000530C07D0x291171c00.express_tmp
1.8G -rw------- 1 gbase gbase 1.8G 11月 17 15:45 s0002665030_GB_MAT000053086C30x1d6660f80.express_tmp
512M -rw------- 1 gbase gbase 512M 11月 17 15:47 s0002665030_GB_MAT0000540C07D0x291171c00.express_tmp
512M -rw------- 1 gbase gbase 512M 11月 17 15:47 s0002665030_GB_MAT000054086C30x1d6660f80.express_tmp
1.8G -rw------- 1 gbase gbase 1.8G 11月 17 15:47 s0002665030_GB_MAT0000556EDF720x4f879cc0.express_tmp
1.8G -rw------- 1 gbase gbase 1.8G 11月 17 15:47 s0002665030_GB_MAT0000553A41D40x4f879180.express_tmp
512M -rw------- 1 gbase gbase 256M 11月 17 15:47 s0002665030_GB_MAT0000566EDF720x4f879cc0.express_tmp
512M -rw------- 1 gbase gbase 256M 11月 17 15:47 s0002665030_GB_MAT0000563A41D40x4f879180.express_tmp
1.1G -rw------- 1 gbase gbase 768M 11月 17 15:47 s0002665030_GB_MAT0000537A3750x4a492e8c0.express_tmp
1.1G -rw------- 1 gbase gbase 768M 11月 17 15:48 s0002665030_GB_MAT0000533C8E20x4a49310c0.express_tmp
91M -rw------- 1 gbase gbase 88M 11月 17 15:48 s0002665030_GB_HSJ0000004B9D50x1c8f6bf80.express_tmp
1.6G -rw------- 1 gbase gbase 1.3G 11月 17 15:48 s0002665030_GB_MAT0000533BDC10x13f3e6080.express_tmp
1.6G -rw------- 1 gbase gbase 1.3G 11月 17 15:48 s0002665030_GB_MAT000053595EB60xcee99840.express_tmp
根据临时物化文件中的相关ID查询节点gn层任务。例如“s0002665030_GB_MAT000053595EB60xcee99840.express_tmp”,通过2665030查gn层的任务:一条delete语句。
gncli ......
gbase> select * from information_schema.processlist where id = 2665030\G;
*************************** 1. row ***************************
ID: 2665030
TASKID: 26636508635
SUBTASKID: 0
THREADID: 20266
USER: test
HOST: 192.168.4.58:11524
DB: testdb
COMMAND: Query
START_TIME: 2020-11-17 10:19:03
TIME: 19797
STATE: deleting from main table
RESOURCE_POOL_NAME: NULL
RESOURCE_POOL_ID: NULL
RESOURCE_POOl_PRIORITY: NULL
WAITING_TIME: NULL
RUNNING_TIME: NULL
PARALLEL_DEGREE: NULL
CPU_USAGE: NULL
MEM_USAGE: 3622709196
TEMP_DISKSPACE_SORT: 0
TEMP_DISKSPACE_JOIN: 0
TEMP_DISKSPACE_AGGR: 0
INFO: /*192.168.4.58_53606_9_2020-11-17_10:19:03*/ DELETE FROM `t` USING `testdb`.`hv_temp_n19` `t` WHERE (`t`.`mpp_date` < (SELECT /*192.168.4.58_53606_9_2020-11-17_10:19:03*/ /*+ TID('26636508635') */ MAX(`t1`.`mpp_date`) AS `max(mpp_date)` FROM `testdb`.`hv_temp_n19` `t1` WHERE (`t1`.`bj` = '1') AND (`t`.`systemid` = `t1`.`systemid`)))
TRACE: show trace is closed!
1 row in set (Elapsed: 00:00:00.02)
根据gn层SQL中的gc层ID 53606,查gc层任务:确认异常SQL为一条delete语句。
[gbase@node01 ~]$ gccli -ugbase -p -h192.168.4.58
gbase> select * from information_schema.processlist where id = 53606 \G;
*************************** 1. row ***************************
ID: 53606
TASKID: 26636508634
SUBTASKID: 0
THREADID: 19037
USER: test
HOST: 10.130.73.45:62711
VC: test
DB: testdb
COMMAND: Query
START_TIME: 2020-11-17 10:19:03
TIME: 19998
STATE: start deleting
RESOURCE_POOL_NAME: NULL
RESOURCE_POOL_ID: NULL
RESOURCE_POOl_PRIORITY: NULL
WAITING_TIME: NULL
RUNNING_TIME: NULL
LOCK: NULL
WAIT: NULL
INFO: delete from hv_temp t
where mpp_date< (select max(mpp_date) from hv_temp t1 where t.systemid=t1.systemid and t1.bj='1')
TRACE: NULL
1 row in set (Elapsed: 00:00:00.01)
热门帖子
- 12025-12-01浏览数:182765
- 22023-05-09浏览数:25067
- 42023-09-25浏览数:18527
- 52020-05-11浏览数:17529