pingcap / pingcap/tidb

Support add TiFlash replica for all tables in a database

Open
#32,254 0 comments 1 reaction 0 assignees View on GitHub
type/feature-request
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Feature Request

**Is your feature request related to a problem? Please describe:**

**Describe the feature you'd like:**

1. Add parser support for `ALTER DATABASE n SET TIFLASH REPLICA n LOCATION LABELS l`
2. When handling this SQL in executor, we use a loop which generate-run-finish `AlterTableSetTiFlashReplica` for all tables in this databases one by one.

We also introduced a rate limiter which is enabled after unavailable table count is beyond TiDBBatchPendingTiFlashCount:
1. When a new table want to enqueue ddl job `AlterTableSetTiFlashReplica`, and the limit is reached, it will wait for `tiflashCheckPendingTablesRetry*tiflashCheckPendingTablesWaitTime`
2. If the limit is still reached after this waiting, the DDL job will evetually be enqueued and executed, so as to force a schema update from owner.
3. The checking procedure above is done every `tiflashCheckPendingTablesTick` tables, but if condition2 happened, we will force a check for the next table.

**Describe alternatives you've considered:**

**Teachability, Documentation, Adoption, Migration Strategy:**

Prelims:
- [x] Move test into testify [#31844](https://github.com/pingcap/tidb/issues/31844)

Required Features:
- [x] Parser https://github.com/pingcap/tidb/pull/32255
- [x] DDL basic implementation #32431
- [ ] Rate limiter #32526

Optional Enhancements:
- [x] Backoff https://github.com/pingcap/tidb/pull/32317
- [ ] Batch update status ddl
- [ ] Batch alter table ddl

Bugfixs:
- [x] #32367
- [x] #32192

Documents:
- [ ] https://github.com/pingcap/docs-cn/pull/8540

Test infra:
- [x] https://github.com/pingcap/endless/pull/472

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.