pingcap / pingcap/tidb

Lock and unlock in `AcquireDistributedLock` can be stuck by internal RPC

Open
#61,288 1 comment 0 reactions 1 assignee Claimed by @tangenta View on GitHub
component/ddl type/bug
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Bug Report

In function `AcquireDistributedLock` of `pkg/owner/manager.go`, lock and unlock operation use a context without timeout. Therefore, the RPCs in these two operations have no deadline, which means that once the RPC like `Txn` stuck, these operations will be blocked endlessly.

https://github.com/pingcap/tidb/blob/master/pkg/owner/manager.go#L638
https://github.com/pingcap/tidb/blob/master/pkg/owner/manager.go#L656

### 1. Minimal reproduce step (Required)

Any query triggers `AcquireDistributedLock`.

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

Lock and unlock operations return `DeadlineExceeded`, not blocked endlessly.

### 3. What did you see instead (Required)

Lock and unlock operations are blocked by internal RPCs, further block `AcquireDistributedLock`.

### 4. What is your TiDB version? (Required)

master

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.