Skip to content

cleanMDLInfo misses a timeout deadline on etcd request #60611

@NaturezzZ

Description

@NaturezzZ

Bug Report

Function cleanMDLInfo of pkg/ddl/job_scheduler.go does not set a timeout deadline for etcd request Delete.

_, err = s.etcdCli.Delete(s.schCtx, path, clientv3.WithPrefix())

Other requests on etcd creates a new ctx with a deadline. This function does not, so the function will stuck if the etcd request meets a time out error.

It should be fixed as following:

etcdCtx, cancel := context.WithTimeout(s.schCtx, util.KeyOpDefaultTimeout)
_, err = s.etcdCli.Delete(etcdCtx, path, clientv3.WithPrefix())
cancel()

I am willing to submit a PR to fix this bug.

1. Minimal reproduce step (Required)

Any requests related to cleanMDLInfo. For example, access_path_seletection.test

set tidb_cost_model_version=1;
CREATE TABLE `access_path_selection` (
`a` int,
`b` int,
KEY `IDX_a` (`a`),
KEY `IDX_b` (`b`),
KEY `IDX_ab` (`a`, `b`)
);
explain format = 'brief' select a from access_path_selection where a < 3;
# In this query, IDX_ab is better than IDX_a.
# The reason is that we have to do double scan if we use IDX_a since it doesn't contain column b.
explain format = 'brief' select a, b from access_path_selection where a < 3;
# In this query, IDX_ab can't be used, so IDX_b is the best.
explain format = 'brief' select a, b from access_path_selection where b < 3;
explain format = 'brief' select a, b from access_path_selection where a < 3 and b < 3;
# _tidb_rowid should also be considered as PK.
explain format = 'brief' select a, b from access_path_selection where a > 10 order by _tidb_rowid;
explain format = 'brief' select max(_tidb_rowid) from access_path_selection;
# Use indexPath in this query.
explain format = 'brief' select count(1) from access_path_selection;

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

s.etcdCli.Delete(etcdCtx, path, clientv3.WithPrefix()) returns DeadlineExceeded

3. What did you see instead (Required)

s.etcdCli.Delete(etcdCtx, path, clientv3.WithPrefix()) is stuck, and further blocks cleanMDLInfo.

4. What is your TiDB version? (Required)

v8.5.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions