pingcap/tidb

ddl/ddl.go: Recv from chan `task.err` may block forever when send is skipped

Open

#26,763 创建于 2021年7月31日

在 GitHub 查看
 (4 评论) (0 反应) (1 负责人)Go (6,186 fork)batch import
help wantedsig/sql-infratype/enhancement

仓库指标

Star
 (40,090 star)
PR 合并指标
 (平均合并 14天 4小时) (30 天内合并 346 个 PR)

描述

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

We found this bug through a WIP Fuzzing project by system-pclub, PSU

2. What did you expect to see? (Required)

In ddl_worker.go, limitDDLJobs() calls addBatchDDLJobs() on L272 if selecting the first case, which in turn calls sending operation task.err <-err on L311. https://github.com/pingcap/tidb/blob/fa71a0e46d427e8a7450a2dce27f8c0d4c02a45c/ddl/ddl_worker.go#L258-L275 https://github.com/pingcap/tidb/blob/fa71a0e46d427e8a7450a2dce27f8c0d4c02a45c/ddl/ddl_worker.go#L310-L311 Then in ddl.go, doDDLJob() calls receiving operation err := <-task.err on L540 https://github.com/pingcap/tidb/blob/fa71a0e46d427e8a7450a2dce27f8c0d4c02a45c/ddl/ddl.go#L534-L540

3. What did you see instead (Required)

If the select in limitDDLJobs() chooses the second case, the sending operation in function addBatchDDLJobs() will be skipped. Thus the receiving operation in doDDLJob() will block forever.

4. What is your TiDB version? (Required)

branch: master commit: 7e6690df8e8d5474b1872edbd279bb1b3c510ee5

贡献者指南