pingcap / pingcap/tidb

Speed up unsafe destroy range by batching multiple ranges in one request

Open
#54,076 0 comments 0 reactions 0 assignees View on GitHub
type/enhancement
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Enhancement

TiDB uses `UnsafeDestroyRange` to GC deleted or truncated tables.

In most cases, the 99th percentile latency of `UnsafeDestroyRange` is about 500ms.
If users drop hundreds of thousands of tables, this can potentially block TiDB's
GC safe point for an extended period due to its serial execution.

Based on observations, users often drop adjacent tables. Therefore, we can
speed up `UnsafeDestroyRange` by batching multiple tables in one request.
For example, `[t1, t2)` and `[t2, t3)` can be batched into `[t1, t3)`.

Since table IDs are allocated monotonically, it is possible to determine if two
tables are adjacent even when their IDs are not contiguous.

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.