Bug 反馈
清晰准确地描述您发现的问题,提供任何可能复现问题的步骤有助于研发同学及时处理问题
【 Bug 的影响】
tidb 5.2.2
【可能的问题复现步骤】
select 语句很快 结果集也就 几十 行
INSERT INTO Material_Rank_List_Daily
(
Platform_Type
,
material_type
,
Img_Path
,
Material_Cover
,
Material_Name
,
Spec_Material_Id
,
Material_Id
,
Agent_Material_Id
,
upload_User_Id
,
upload_User_Name
,
design_user
,
Customer_Id
,
Customer_Name
,
Industry_Id
,
Industry_Name
,
material_tag
,
totalCost
,
cost
,
impression
,
click
,
conversion
,
conversion_cost
,
conversion_rate
,
ctr
,
video_play_count
,
video_outer_play_count
,
video_outer_play100_count
,
video_play_rate
,
video_play_over_rate
,
video_avg_play_time
,
Modify_Time
,
Create_Time
) SELECT
temp.Platform_Type,
temp.Material_Type,
temp.Img_Path,
NULL,
temp.material_name,
temp.Spec_Material_Id,
temp.Material_Id,
temp.Agent_Material_Id,
temp.Upload_User_Id,
eus.display_name,
temp.design_user,
temp.Customer_Id,
temp.Customer_Name,
temp.Industry_Id,
temp.Industry_Name,
GROUP_CONCAT(
DISTINCT cmt.tag_name SEPARATOR ‘|’
) AS material_tag,
0,
temp.cost,
temp.impression,
temp.click,
temp.conversion,
temp.conversion_cost,
temp.conversion_rate,
temp.ctr,
temp.video_play_count,
temp.video_outer_play_count,
temp.video_outer_play100_count,
temp.video_play_rate,
temp.video_play_over_rate,
temp.video_avg_play_time,
NOW(),
NOW()
FROM
(
SELECT
t2.*
FROM
(
SELECT
, rank () over (
PARTITION BY Industry_Id
ORDER BY
cost DESC
) AS rk
FROM
(
SELECT
Platform_Type,
Material_Type,
Spec_Material_Id,
Material_Id,
agent_material_id,
material_name,
max(Img_Path) AS Img_Path,
GROUP_CONCAT(
DISTINCT Role_Name,
‘:’,
User_Name
ORDER BY
Role_Name SEPARATOR ‘;’
) AS Design_User,
customer_id,
GROUP_CONCAT(
DISTINCT “(”,
customer_id,
‘)’,
customer_name
ORDER BY
customer_id SEPARATOR ‘、’
) AS customer_name,
Industry_Id,
industry_name,
User_Id AS Upload_User_Id,
sum(cost) AS cost,
sum(impression) AS impression,
sum(click) AS click,
sum(conversion) AS conversion,
ifnull(
SUM(cost) / SUM(conversion),
0
) AS conversion_cost,
ifnull(
SUM(conversion) / SUM(click),
0
) AS conversion_rate,
ifnull(
SUM(click) / SUM(impression),
0
) AS ctr,
SUM(video_play_count) AS video_play_count,
SUM(video_outer_play_count) AS video_outer_play_count,
sum(video_outer_play100_count) AS video_outer_play100_count,
ifnull(
SUM(video_play_count) / SUM(impression),
0
) AS video_play_rate,
ifnull(
video_outer_play100_count / video_play_count,
0
) AS video_play_over_rate,
video_avg_play_time
FROM
Material_Participant_Daily_Report
WHERE
Report_Date = ‘2021-12-14’
AND cost > 0
AND Industry_Id <> 0
AND material_type = 0
GROUP BY
ifnull(
Spec_Material_Id,
Agent_Material_Id
),
Industry_Id
) t1
) t2
WHERE
rk <= 10
) temp
LEFT JOIN mbg_business.creative_material_tag_info cmti ON temp.Spec_Material_Id = cmti.Spec_Material_Id
LEFT JOIN mbg_business.creative_material_tag cmt ON cmti.material_tag_id = cmt.id
LEFT JOIN mbg_core.emarbox_user eus ON temp.Upload_User_Id = eus.user_id
GROUP BY
ifnull(
Spec_Material_Id,
Agent_Material_Id
)
【看到的非预期行为】
[2021/12/14 11:24:17.646 +08:00] [INFO] [conn.go:1007] [“command dispatched failed”] [conn=4580375] [connInfo=“id:4580375, addr:123.59.17.29:58626 status:10, collation:latin1_swedish_ci, user:dspwrite”] [command=Query] [status=“inTxn:0, autocommit:1”] [sql="INSERT INTO Material_Rank_List_Daily
(\r\
\tPlatform_Type
,\r\
\tmaterial_type
,\r\
\tImg_Path
,\r\
\tMaterial_Cover
,\r\
\tMaterial_Name
,\r\
\tSpec_Material_Id
,\r\
\tMaterial_Id
,\r\
\tAgent_Material_Id
,\r\
\tupload_User_Id
,\r\
\tupload_User_Name
,\r\
\tdesign_user
,\r\
\tCustomer_Id
,\r\
\tCustomer_Name
,\r\
\tIndustry_Id
,\r\
\tIndustry_Name
,\r\
\tmaterial_tag
,\r\
\ttotalCost
,\r\
\tcost
,\r\
\timpression
,\r\
\tclick
,\r\
\tconversion
,\r\
\tconversion_cost
,\r\
\tconversion_rate
,\r\
\tctr
,\r\
\tvideo_play_count
,\r\
\tvideo_outer_play_count
,\r\
\tvideo_outer_play100_count
,\r\
\tvideo_play_rate
,\r\
\tvideo_play_over_rate
,\r\
\tvideo_avg_play_time
,\r\
\tModify_Time
,\r\
\tCreate_Time
\r\
) SELECT\r\
\ttemp.Platform_Type,\r\
\ttemp.Material_Type,\r\
\ttemp.Img_Path,\r\
\tNULL,\r\
\ttemp.material_name,\r\
\ttemp.Spec_Material_Id,\r\
\ttemp.Material_Id,\r\
\ttemp.Agent_Material_Id,\r\
\ttemp.Upload_User_Id,\r\
\teus.display_name,\r\
\ttemp.design_user,\r\
\ttemp.Customer_Id,\r\
\ttemp.Customer_Name,\r\
\ttemp.Industry_Id,\r\
\ttemp.Industry_Name,\r\
\tGROUP_CONCAT(\r\
\t\tDISTINCT cmt.tag_name SEPARATOR ‘|’\r\
\t) AS material_tag,\r\
\t0,\r\
\ttemp.cost,\r\
\ttemp.impression,\r\
\ttemp.click,\r\
\ttemp.conversion,\r\
\ttemp.conversion_cost,\r\
\ttemp.conversion_rate,\r\
\ttemp.ctr,\r\
\ttemp.video_play_count,\r\
\ttemp.video_outer_play_count,\r\
\ttemp.video_outer_play100_count,\r\
\ttemp.video_play_rate,\r\
\ttemp.video_play_over_rate,\r\
\ttemp.video_avg_play_time,\r\
\tNOW(),\r\
\tNOW()\r\
FROM\r\
\t(\r\
\t\tSELECT\r\
\t\t\tt2.\r\
\t\tFROM\r\
\t\t\t(\r\
\t\t\t\tSELECT\r\
\t\t\t\t\t*, rank () over (\r\
\t\t\t\t\t\tPARTITION BY Industry_Id\r\
\t\t\t\t\t\tORDER BY\r\
\t\t\t\t\t\t\tcost DESC\r\
\t\t\t\t\t) AS rk\r\
\t\t\t\tFROM\r\
\t\t\t\t\t(\r\
\t\t\t\t\t\tSELECT\r\
\t\t\t\t\t\t\tPlatform_Type,\r\
\t\t\t\t\t\t\tMaterial_Type,\r\
\t\t\t\t\t\t\tSpec_Material_Id,\r\
\t\t\t\t\t\t\tMaterial_Id,\r\
\t\t\t\t\t\t\tagent_material_id,\r\
\t\t\t\t\t\t\tmaterial_name,\r\
\t\t\t\t\t\t\tmax(Img_Path) AS Img_Path,\r\
\t\t\t\t\t\t\tGROUP_CONCAT(\r\
\t\t\t\t\t\t\t\tDISTINCT Role_Name,\r\
\t\t\t\t\t\t\t\t’:’,\r\
\t\t\t\t\t\t\t\tUser_Name\r\
\t\t\t\t\t\t\tORDER BY\r\
\t\t\t\t\t\t\t\tRole_Name SEPARATOR ‘;’\r\
\t\t\t\t\t\t\t) AS Design_User,\r\
\t\t\t\t\t\t\tcustomer_id,\r\
\t\t\t\t\t\t\tGROUP_CONCAT(\r\
\t\t\t\t\t\t\t\tDISTINCT “(”,\r\
\t\t\t\t\t\t\t\tcustomer_id,\r\
\t\t\t\t\t\t\t\t’)’,\r\
\t\t\t\t\t\t\t\tcustomer_name\r\
\t\t\t\t\t\t\tORDER BY\r\
\t\t\t\t\t\t\t\tcustomer_id SEPARATOR ‘、’\r\
\t\t\t\t\t\t\t) AS customer_name,\r\
\t\t\t\t\t\t\tIndustry_Id,\r\
\t\t\t\t\t\t\tindustry_name,\r\
\t\t\t\t\t\t\tUser_Id AS Upload_User_Id,\r\
\t\t\t\t\t\t\tsum(cost) AS cost,\r\
\t\t\t\t\t\t\tsum(impression) AS impression,\r\
\t\t\t\t\t\t\tsum(click) AS click,\r\
\t\t\t\t\t\t\tsum(conversion) AS conversion,\r\
\t\t\t\t\t\t\tifnull(\r\
\t\t\t\t\t\t\t\tSUM(cost) / SUM(conversion),\r\
\t\t\t\t\t\t\t\t0\r\
\t\t\t\t\t\t\t) AS conversion_cost,\r\
\t\t\t\t\t\t\tifnull(\r\
\t\t\t\t\t\t\t\tSUM(conversion) / SUM(click),\r\
\t\t\t\t\t\t\t\t0\r\
\t\t\t\t\t\t\t) AS conversion_rate,\r\
\t\t\t\t\t\t\tifnull(\r\
\t\t\t\t\t\t\t\tSUM(click) / SUM(impression),\r\
\t\t\t\t\t\t\t\t0\r\
\t\t\t\t\t\t\t) AS ctr,\r\
\t\t\t\t\t\t\tSUM(video_play_count) AS video_play_count,\r\
\t\t\t\t\t\t\tSUM(video_outer_play_count) AS video_outer_play_count,\r\
\t\t\t\t\t\t\tsum(video_outer_play100_count) AS video_outer_play100_count,\r\
\t\t\t\t\t\t\tifnull(\r\
\t\t\t\t\t\t\t\tSUM(video_play_count) / SUM(impression),\r\
\t\t\t\t\t\t\t\t0\r\
\t\t\t\t\t\t\t) AS video_play_rate,\r\
\t\t\t\t\t\t\tifnull(\r\
\t\t\t\t\t\t\t\tvideo_outer_play100_count / video_play_count,\r\
\t\t\t\t\t\t\t\t0\r\
\t\t\t\t\t\t\t) AS video_play_over_rate,\r\
\t\t\t\t\t\t\tvideo_avg_play_time\r\
\t\t\t\t\t\tFROM\r\
\t\t\t\t\t\t\tMaterial_Participant_Daily_Report\r\
\t\t\t\t\t\tWHERE\r\
\t\t\t\t\t\t\tReport_Date = ‘2021-12-14’\r\
\t\t\t\t\t\tAND cost > 0\r\
\t\t\t\t\t\tAND Industry_Id <> 0\r\
\t\t\t\t\t\tAND material_type = 0\r\
\t\t\t\t\t\tGROUP BY\r\
\t\t\t\t\t\t\tifnull(\r\
\t\t\t\t\t\t\t\tSpec_Material_Id,\r\
\t\t\t\t\t\t\t\tAgent_Material_Id\r\
\t\t\t\t\t\t\t),\r\
\t\t\t\t\t\t\tIndustry_Id\r\
\t\t\t\t\t) t1\r\
\t\t\t) t2\r\
\t\tWHERE\r\
\t\t\trk <= 10\r\
\t) temp\r\
LEFT JOIN mbg_business.creative_material_tag_info cmti ON temp.Spec_Material_Id = cmti.Spec_Material_Id\r\
LEFT JOIN mbg_business.creative_material_tag cmt ON cmti.material_tag_id = cmt.id\r\
LEFT JOIN mbg_core.emarbox_user eus ON temp.Upload_User_Id = eus.user_id\r\
GROUP BY\r\
\tifnull(\r\
\t\tSpec_Material_Id,\r\
\t\tAgent_Material_Id\r\
\t)"] [txn_mode=PESSIMISTIC] [err=“runtime error: invalid memory address or nil pointer dereference\ngithub.com/pingcap/tidb/executor.(*IndexNestedLoopHashJoin).finishJoinWorkers\
\t/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/executor/index_lookup_hash_join.go:203\ngithub.com/pingcap/tidb/util.WithRecovery.func1\
\t/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/util/misc.go:91\
runtime.gopanic\
\t/usr/local/go/src/runtime/panic.go:965\
runtime.panicmem\
\t/usr/local/go/src/runtime/panic.go:212\
runtime.sigpanic\
\t/usr/local/go/src/runtime/signal_unix.go:734\
github.com/pingcap/tidb/util/chunk.(*Chunk).NumRows\
\t/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/util/chunk/chunk.go:349\ngithub.com/pingcap/tidb/executor.(*vecGroupChecker).splitIntoGroups\
\t/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/executor/aggregate.go:1456\ngithub.com/pingcap/tidb/executor.(*PipelinedWindowExec).getRowsInPartition\
\t/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/executor/pipelined_window.go:188\ngithub.com/pingcap/tidb/executor.(*PipelinedWindowExec).Next\
\t/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/executor/pipelined_window.go:124\ngithub.com/pingcap/tidb/executor.Next\
\t/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/executor/executor.go:285\
github.com/pingcap/tidb/executor.(*SelectionExec).Next\
\t/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/executor/executor.go:1301\ngithub.com/pingcap/tidb/executor.Next\
\t/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/executor/executor.go:285\
github.com/pingcap/tidb/executor.(*outerWorker).buildTask\
\t/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/executor/index_lookup_join.go:402\ngithub.com/pingcap/tidb/executor.(*indexHashJoinOuterWorker).buildTask\
\t/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/executor/index_lookup_hash_join.go:359\ngithub.com/pingcap/tidb/executor.(*indexHashJoinOuterWorker).run\
\t/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/executor/index_lookup_hash_join.go:328\ngithub.com/pingcap/tidb/executor.(*IndexNestedLoopHashJoin).startWorkers.func1\
\t/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/executor/index_lookup_hash_join.go:171\ngithub.com/pingcap/tidb/util.WithRecovery\
\t/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/util/misc.go:99\
runtime.goexit\
\t/usr/local/go/src/runtime/asm_amd64.s:1371”]
【期望看到的行为】
【相关组件及具体版本】
【其他背景信息或者截图】
如集群拓扑,系统和内核版本,应用 app 信息等;如果问题跟 SQL 有关,请提供 SQL 语句和相关表的 Schema 信息;如果节点日志存在关键报错,请提供相关节点的日志内容或文件;如果一些业务敏感信息不便提供,请留下联系方式,我们与您私下沟通。