Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ddl: Implement basic version of TiFlash replica management #30842

Merged
merged 278 commits into from
Jan 19, 2022
Merged
Show file tree
Hide file tree
Changes from 218 commits
Commits
Show all changes
278 commits
Select commit Hold shift + click to select a range
1bc4a9d
Add test when set pd rule fails
CalvinNeo Nov 18, 2021
20511ab
Want to test multiple tidb for one owner, but fail
CalvinNeo Nov 18, 2021
661b67e
Add test for block add partition
CalvinNeo Nov 18, 2021
1435278
Enhance
CalvinNeo Nov 18, 2021
252798a
Remove multi test, since it can't be done in unit test
CalvinNeo Nov 18, 2021
e6cc202
fmt
CalvinNeo Nov 18, 2021
31e0cae
Fix tidb build error
CalvinNeo Nov 19, 2021
60c1258
Refactor
CalvinNeo Nov 19, 2021
3af4f30
Fmt
CalvinNeo Nov 19, 2021
be9022d
Merge branch 'master' into proto3
CalvinNeo Nov 19, 2021
ffc6768
Fix
CalvinNeo Nov 19, 2021
cb60dca
Merge branch 'proto3' of github.com:CalvinNeo/tidb into proto3
CalvinNeo Nov 19, 2021
553bf61
Fmt
CalvinNeo Nov 19, 2021
41b2f2a
Fix linter
CalvinNeo Nov 19, 2021
879ea77
Fix lint2
CalvinNeo Nov 19, 2021
1c7cfbe
Fix lint3
CalvinNeo Nov 19, 2021
3383d38
lint3
CalvinNeo Nov 19, 2021
a2aadcc
fix goimports
CalvinNeo Nov 19, 2021
4dc9a91
Fix goimports
CalvinNeo Nov 19, 2021
1a6759c
SerialSuite
CalvinNeo Nov 19, 2021
8e79cf1
remove tiflash test, check can pass test
CalvinNeo Nov 19, 2021
da2d047
add back
CalvinNeo Nov 19, 2021
3f99afd
Remove instant ddl, then test
CalvinNeo Nov 19, 2021
ca717c3
fix
CalvinNeo Nov 19, 2021
ae47ed0
fix
CalvinNeo Nov 19, 2021
af5ab2a
torlerate
CalvinNeo Nov 19, 2021
03556ca
f
CalvinNeo Nov 19, 2021
6ac2aec
fix
CalvinNeo Nov 22, 2021
c63b5c0
fix
CalvinNeo Nov 22, 2021
3ce0e8e
fix
CalvinNeo Nov 22, 2021
5463681
fix
CalvinNeo Nov 22, 2021
c5b984a
disable one test
CalvinNeo Nov 22, 2021
43ce645
fix
CalvinNeo Nov 22, 2021
81bac45
fix
CalvinNeo Nov 22, 2021
2314ff9
remove all newly added
CalvinNeo Nov 22, 2021
165f92b
ditto
CalvinNeo Nov 22, 2021
d91725b
Fix
CalvinNeo Nov 22, 2021
bca837a
use EnablePollLoop
CalvinNeo Nov 22, 2021
d661e19
fix
CalvinNeo Nov 22, 2021
6bc1a43
fix
CalvinNeo Nov 22, 2021
9df2d03
EnablePollLoop back
CalvinNeo Nov 22, 2021
d14a70c
Disable all of TestTableStorageStats
CalvinNeo Nov 22, 2021
d38fde4
go import
CalvinNeo Nov 22, 2021
1210d46
fix
CalvinNeo Nov 22, 2021
90fa6fe
poll loop switch per ddl
CalvinNeo Nov 22, 2021
8f77b00
make enableTiFlashPoll inside ddl, and run
CalvinNeo Nov 22, 2021
3548084
fix
CalvinNeo Nov 22, 2021
57ba3d7
fix
CalvinNeo Nov 23, 2021
1a07dd3
try fix domain
CalvinNeo Nov 23, 2021
274eb8e
Merge remote-tracking branch 'upstream/master' into proto3
CalvinNeo Nov 23, 2021
7ca24bb
fix
CalvinNeo Nov 23, 2021
78df5a2
fix
CalvinNeo Nov 23, 2021
da92c60
old tests disable poll loop
CalvinNeo Nov 23, 2021
ea39ad7
fix
CalvinNeo Nov 23, 2021
d51f70d
fix
CalvinNeo Nov 23, 2021
8c749fe
fix
CalvinNeo Nov 23, 2021
f44dd59
up
CalvinNeo Nov 24, 2021
0a4ef72
Add back gc test
CalvinNeo Nov 24, 2021
3e87958
add location label check
CalvinNeo Nov 24, 2021
349d839
remove tso and available checking codes
CalvinNeo Nov 25, 2021
cca4d21
refactor
CalvinNeo Nov 25, 2021
d034bf2
Add massive test
CalvinNeo Nov 25, 2021
5c0f5b8
polish
CalvinNeo Nov 25, 2021
2c4d509
remove redandant code
CalvinNeo Nov 25, 2021
db9d716
fix
CalvinNeo Nov 25, 2021
3b7652f
fix
CalvinNeo Nov 25, 2021
76f8404
disable http
CalvinNeo Nov 26, 2021
3639d40
disable http
CalvinNeo Nov 26, 2021
55bc375
remove /tiflash/replica test
CalvinNeo Nov 26, 2021
c70c6fa
delete placement rule in gc worker(only in mock case), and pass test
CalvinNeo Nov 26, 2021
29f4d25
add more log
CalvinNeo Nov 26, 2021
4111c19
try add more logs
CalvinNeo Nov 26, 2021
3eb9c30
solve truncate partition case
CalvinNeo Nov 27, 2021
d49a305
remove logs
CalvinNeo Nov 27, 2021
d5068e8
just change /tiflash/replica
CalvinNeo Nov 28, 2021
1d8b122
fmt
CalvinNeo Nov 28, 2021
727f5d3
fix
CalvinNeo Nov 29, 2021
0a74268
atomic
CalvinNeo Nov 29, 2021
c7080fc
reorg tests and fix truncate table error
CalvinNeo Nov 29, 2021
135b00b
try fix
CalvinNeo Nov 29, 2021
038d52a
try fix2
CalvinNeo Nov 29, 2021
891867d
fix
CalvinNeo Nov 29, 2021
164c5bc
try add back origin tests
CalvinNeo Nov 29, 2021
036347f
fix
CalvinNeo Nov 29, 2021
34be977
comment back
CalvinNeo Nov 29, 2021
690b2c3
fix
CalvinNeo Nov 29, 2021
a7f3a77
fix
CalvinNeo Nov 29, 2021
a4f476f
remvoe truncate table
CalvinNeo Nov 29, 2021
cf74e04
back
CalvinNeo Nov 29, 2021
32a64ce
Merge branch 'master' into proto3
CalvinNeo Nov 29, 2021
6ad1436
remove again
CalvinNeo Nov 29, 2021
b91ba55
Merge branch 'proto3' of github.com:CalvinNeo/tidb into proto3
CalvinNeo Nov 29, 2021
cf45cd0
enable
CalvinNeo Nov 29, 2021
cf89d85
try
CalvinNeo Nov 29, 2021
440a867
try remove table.go
CalvinNeo Nov 29, 2021
c7116c7
enable one
CalvinNeo Nov 29, 2021
692114d
enable one
CalvinNeo Nov 29, 2021
2bb2fdc
goimport
CalvinNeo Nov 29, 2021
02f5f41
try
CalvinNeo Nov 29, 2021
78e674e
try fix
CalvinNeo Nov 29, 2021
0737098
Fix
CalvinNeo Nov 29, 2021
f0b023e
fix
CalvinNeo Nov 30, 2021
79c2bee
Merge branch 'master' into proto3
CalvinNeo Nov 30, 2021
8146fea
uncomment exxecutor, and try
CalvinNeo Nov 30, 2021
358db99
prune useless function
CalvinNeo Nov 30, 2021
8452902
Merge branch 'master' into proto3
CalvinNeo Nov 30, 2021
7fed0d6
add tests for flashback
CalvinNeo Nov 30, 2021
3b3a663
fmt
CalvinNeo Nov 30, 2021
0791346
will immediately remove when gc
CalvinNeo Nov 30, 2021
e3726c2
backoff part 1
CalvinNeo Nov 30, 2021
3ec5879
update test
CalvinNeo Nov 30, 2021
b1fe8f4
polish
CalvinNeo Dec 1, 2021
94f623c
fix
CalvinNeo Dec 2, 2021
6d685a0
fix test
CalvinNeo Dec 2, 2021
fa3132c
fix
CalvinNeo Dec 2, 2021
51e9905
fmt
CalvinNeo Dec 2, 2021
ffc7064
add more logs
CalvinNeo Dec 3, 2021
229e756
modify backoff strategy
CalvinNeo Dec 3, 2021
961a43a
enhance ut
CalvinNeo Dec 3, 2021
7859029
fix
CalvinNeo Dec 3, 2021
fd817f7
fix
CalvinNeo Dec 3, 2021
6b18d49
fix
CalvinNeo Dec 3, 2021
9745cae
Polish
CalvinNeo Dec 6, 2021
7bd1d9c
polish
CalvinNeo Dec 6, 2021
ff25c42
polish
CalvinNeo Dec 6, 2021
e0c05ae
Polish functions
CalvinNeo Dec 6, 2021
bf464e3
refactor to polish
CalvinNeo Dec 6, 2021
e37eabb
fix
CalvinNeo Dec 7, 2021
dda76c9
Fix
CalvinNeo Dec 7, 2021
63352bf
fmt
CalvinNeo Dec 7, 2021
5dcc9cf
add test
CalvinNeo Dec 7, 2021
b974157
fmt
CalvinNeo Dec 7, 2021
871c09f
Merge branch 'master' into proto3
CalvinNeo Dec 7, 2021
79a479c
test move
CalvinNeo Dec 7, 2021
1d71c6c
try remove GetPDRegionRecordStats
CalvinNeo Dec 7, 2021
0e776d7
Merge branch 'proto3' of github.com:CalvinNeo/tidb into proto3
CalvinNeo Dec 7, 2021
5603269
fmt
CalvinNeo Dec 7, 2021
d74e768
rewrite backoff
CalvinNeo Dec 8, 2021
74f9070
fmt
CalvinNeo Dec 9, 2021
2fa2278
polish
CalvinNeo Dec 9, 2021
dc193a2
fix bugs
CalvinNeo Dec 9, 2021
2f717ce
partial
CalvinNeo Dec 9, 2021
7f6eece
reduced
CalvinNeo Dec 9, 2021
267d4c7
we do not handle err when table is not exist
CalvinNeo Dec 13, 2021
c94b899
Refactor
CalvinNeo Dec 13, 2021
be45261
fix
CalvinNeo Dec 13, 2021
503a453
add log for time
CalvinNeo Dec 16, 2021
25ac922
add commit
CalvinNeo Dec 17, 2021
91c4b05
fmt
CalvinNeo Dec 17, 2021
41cc5a8
fmt
CalvinNeo Dec 17, 2021
de80e03
fmt
CalvinNeo Dec 17, 2021
fd47db9
Merge branch 'master' into part2
CalvinNeo Dec 17, 2021
0f6b15d
fix
CalvinNeo Dec 17, 2021
e713d43
Fix
CalvinNeo Dec 17, 2021
3b57888
Polish
CalvinNeo Dec 20, 2021
269faac
fmt
CalvinNeo Dec 20, 2021
736af52
fix
CalvinNeo Dec 20, 2021
420f768
polish
CalvinNeo Dec 20, 2021
83cd230
fix
CalvinNeo Dec 20, 2021
d19b983
polish
CalvinNeo Dec 20, 2021
fa35b8c
Merge branch 'master' into part2
CalvinNeo Dec 20, 2021
7eee4db
fix
CalvinNeo Dec 20, 2021
4ddefae
Remove some unnecessary codes
CalvinNeo Dec 20, 2021
c252fd3
Merge branch 'part2' of github.com:CalvinNeo/tidb into part2
CalvinNeo Dec 20, 2021
5dbec02
polish
CalvinNeo Dec 20, 2021
b9f6227
polish
CalvinNeo Dec 20, 2021
18eea69
fix
CalvinNeo Dec 20, 2021
8828867
fmt
CalvinNeo Dec 20, 2021
a4b0fe9
polish
CalvinNeo Dec 21, 2021
2d3d1f3
fmt
CalvinNeo Dec 21, 2021
224ee7d
polish
CalvinNeo Dec 21, 2021
c300d24
fix
CalvinNeo Dec 22, 2021
c59a4d1
fixed
CalvinNeo Dec 22, 2021
b103dc9
fix2
CalvinNeo Dec 22, 2021
71f30f8
fix
CalvinNeo Dec 22, 2021
7a9c708
avoid too much log
CalvinNeo Dec 22, 2021
9ac332f
fix
CalvinNeo Dec 22, 2021
98d40b4
Polish
CalvinNeo Dec 28, 2021
246044f
update according to review
CalvinNeo Dec 28, 2021
c30283a
modify according to review
CalvinNeo Dec 28, 2021
666f7e8
Modify pd rule: step1
CalvinNeo Dec 29, 2021
1036b72
refactor pd: step 2
CalvinNeo Dec 29, 2021
503ff68
fix error
CalvinNeo Dec 30, 2021
4d2f2a6
add mockTiFlashPlacementManager
CalvinNeo Dec 31, 2021
cf8f59c
fix
CalvinNeo Dec 31, 2021
bc6a102
Fix under mock addr
CalvinNeo Dec 31, 2021
b606bbd
split out MockTiFlash
CalvinNeo Jan 4, 2022
7cc02ef
Abort when pd rule fails in truncates
CalvinNeo Jan 4, 2022
a70d019
move add partition's pd into ddl job
CalvinNeo Jan 4, 2022
1383b24
Remove PD Http server
CalvinNeo Jan 4, 2022
005a7a9
Fix a problem when there are multiple regions in one line
CalvinNeo Jan 4, 2022
d17b7cb
Fix serveral errors
CalvinNeo Jan 4, 2022
01dd901
Another way
CalvinNeo Jan 4, 2022
d2f2bd5
Merge remote-tracking branch 'upstream/master' into part2
CalvinNeo Jan 6, 2022
f47f2ce
fix after merge part2.1
CalvinNeo Jan 6, 2022
363b560
fix
CalvinNeo Jan 6, 2022
e74d575
fix
CalvinNeo Jan 6, 2022
f0de184
remove enable tiflash poll
CalvinNeo Jan 6, 2022
ca4f016
clean codes
CalvinNeo Jan 6, 2022
70aa861
fix
CalvinNeo Jan 6, 2022
88e09fd
clean codes
CalvinNeo Jan 6, 2022
d3dae9b
add tests
CalvinNeo Jan 7, 2022
784d9e7
fix test
CalvinNeo Jan 10, 2022
3e398f1
fix
CalvinNeo Jan 10, 2022
a5f7f07
fmt
CalvinNeo Jan 10, 2022
87d32f7
fix
CalvinNeo Jan 10, 2022
60f3cb4
fix
CalvinNeo Jan 10, 2022
cb9286a
fix ut
CalvinNeo Jan 10, 2022
7c5936f
fix
CalvinNeo Jan 10, 2022
d87e5df
fix
CalvinNeo Jan 10, 2022
937707a
fix fmt
CalvinNeo Jan 10, 2022
fbcbad9
fix
CalvinNeo Jan 10, 2022
7eeefeb
add back set new rule
CalvinNeo Jan 11, 2022
4e30663
polish
CalvinNeo Jan 11, 2022
066a9f7
try fix and fail
CalvinNeo Jan 11, 2022
5af9b86
fix tests
CalvinNeo Jan 11, 2022
fa12a5e
fix
CalvinNeo Jan 11, 2022
6c43557
Fix tests
CalvinNeo Jan 11, 2022
91b3e6c
Fixed
CalvinNeo Jan 11, 2022
8b6c08c
fix fmt
CalvinNeo Jan 11, 2022
c3108e9
disable pullPdLoop
CalvinNeo Jan 13, 2022
e3f44df
Remove
CalvinNeo Jan 14, 2022
75b1702
Merge branch 'master' into part2
ti-chi-bot Jan 17, 2022
8b58102
Merge branch 'master' into part2
ti-chi-bot Jan 17, 2022
9f8faef
Merge branch 'master' into part2
ti-chi-bot Jan 17, 2022
9ea8f34
Merge branch 'master' into part2
ti-chi-bot Jan 17, 2022
52009f0
Merge branch 'master' into part2
ti-chi-bot Jan 17, 2022
c7fe72a
Merge branch 'master' into part2
ti-chi-bot Jan 17, 2022
96f4e07
Merge branch 'master' into part2
ti-chi-bot Jan 17, 2022
c72d36d
Merge branch 'master' into part2
ti-chi-bot Jan 17, 2022
7044993
Merge branch 'master' into part2
ti-chi-bot Jan 17, 2022
2e6444c
Merge branch 'master' into part2
ti-chi-bot Jan 17, 2022
dc8f50a
fix for create like
CalvinNeo Jan 17, 2022
215467a
Merge branch 'part2' of github.com:CalvinNeo/tidb into part2
CalvinNeo Jan 17, 2022
4713803
fix interval
CalvinNeo Jan 18, 2022
b97d20a
Merge branch 'master' into part2
CalvinNeo Jan 18, 2022
e41ba03
Merge branch 'master' into part2
ti-chi-bot Jan 18, 2022
565ea53
Merge branch 'master' into part2
ti-chi-bot Jan 18, 2022
622c133
Merge branch 'master' into part2
ti-chi-bot Jan 18, 2022
1f12a08
Merge branch 'master' into part2
ti-chi-bot Jan 18, 2022
a882041
fix
CalvinNeo Jan 18, 2022
bffc988
Merge branch 'part2' of github.com:CalvinNeo/tidb into part2
CalvinNeo Jan 18, 2022
e8999f0
fix
CalvinNeo Jan 18, 2022
be0e3e0
fix
CalvinNeo Jan 18, 2022
f0277af
fix
CalvinNeo Jan 18, 2022
891557c
fix
CalvinNeo Jan 18, 2022
3e15449
fix
CalvinNeo Jan 18, 2022
32dfce1
Merge branch 'master' into part2
CalvinNeo Jan 19, 2022
7a2ea09
Merge branch 'master' into part2
ti-chi-bot Jan 19, 2022
1f7ffd5
Merge branch 'master' into part2
ti-chi-bot Jan 19, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ddl/db_change_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ func (s *testStateChangeSuiteBase) SetUpSuite(c *C) {
session.SetSchemaLease(s.lease)
s.dom, err = session.BootstrapSession(s.store)
c.Assert(err, IsNil)
ddl.DisableTiFlashPoll(s.dom.DDL())
s.se, err = session.CreateSession4Test(s.store)
c.Assert(err, IsNil)
_, err = s.se.Execute(context.Background(), "create database test_db_state default charset utf8 default collate utf8_bin")
Expand Down
1 change: 1 addition & 0 deletions ddl/db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ func setUpSuite(s *testDBSuite, c *C) {

s.dom, err = session.BootstrapSession(s.store)
c.Assert(err, IsNil)
ddl.DisableTiFlashPoll(s.dom.DDL())
s.s, err = session.CreateSession4Test(s.store)
c.Assert(err, IsNil)
s.ctx = s.s.(sessionctx.Context)
Expand Down
37 changes: 31 additions & 6 deletions ddl/ddl.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,10 @@ type ddl struct {
limitJobCh chan *limitJobTask

*ddlCtx
workers map[workerType]*worker
sessPool *sessionPool
delRangeMgr delRangeManager
workers map[workerType]*worker
sessPool *sessionPool
delRangeMgr delRangeManager
enableTiFlashPoll bool
xhebox marked this conversation as resolved.
Show resolved Hide resolved
}

// ddlCtx is the context when we use worker to handle DDL jobs.
Expand Down Expand Up @@ -230,6 +231,25 @@ func (dc *ddlCtx) isOwner() bool {
return isOwner
}

// EnableTiFlashPoll enables TiFlash poll loop aka pollTiFlashReplicaStatus.
func EnableTiFlashPoll(d interface{}) {
if dd, ok := d.(*ddl); ok {
dd.enableTiFlashPoll = true
}
}

// DisableTiFlashPoll disables TiFlash poll loop aka pollTiFlashReplicaStatus.
func DisableTiFlashPoll(d interface{}) {
if dd, ok := d.(*ddl); ok {
dd.enableTiFlashPoll = false
}
}

// IsTiFlashPollEnabled reveals enableTiFlashPoll
func (d *ddl) IsTiFlashPollEnabled() bool {
return d.enableTiFlashPoll
}

// RegisterStatsHandle registers statistics handle and its corresponding even channel for ddl.
func (d *ddl) RegisterStatsHandle(h *handle.Handle) {
d.ddlCtx.statsHandle = h
Expand Down Expand Up @@ -312,9 +332,10 @@ func newDDL(ctx context.Context, options ...Option) *ddl {
ddlCtx.mu.hook = opt.Hook
ddlCtx.mu.interceptor = &BaseInterceptor{}
d := &ddl{
ctx: ctx,
ddlCtx: ddlCtx,
limitJobCh: make(chan *limitJobTask, batchAddingJobs),
ctx: ctx,
ddlCtx: ddlCtx,
limitJobCh: make(chan *limitJobTask, batchAddingJobs),
enableTiFlashPoll: true,
}

return d
Expand Down Expand Up @@ -387,6 +408,10 @@ func (d *ddl) Start(ctxPool *pools.ResourcePool) error {
variable.RegisterStatistics(d)

metrics.DDLCounter.WithLabelValues(metrics.CreateDDLInstance).Inc()

// Start some background routine to manage TiFlash replica.
go d.PollTiFlashRoutine()

return nil
}

Expand Down
25 changes: 25 additions & 0 deletions ddl/ddl_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
"github.com/pingcap/failpoint"
"github.com/pingcap/tidb/config"
"github.com/pingcap/tidb/ddl/label"
"github.com/pingcap/tidb/domain/infosync"
"github.com/pingcap/tidb/expression"
"github.com/pingcap/tidb/infoschema"
"github.com/pingcap/tidb/kv"
Expand Down Expand Up @@ -4720,6 +4721,27 @@ func (d *ddl) AlterTableSetTiFlashReplica(ctx sessionctx.Context, ident ast.Iden
return errors.Trace(err)
}

// We should check this first, in order to avoid creating redundant DDL jobs.
tblInfo := tb.Meta()
if d.IsTiFlashPollEnabled() {
CalvinNeo marked this conversation as resolved.
Show resolved Hide resolved
// Must set placement rule before the ActionSetTiFlashReplica job is in queue.
if pi := tblInfo.GetPartitionInfo(); pi != nil {
logutil.BgLogger().Info("Set TiFlash replica pd rule for partitioned table", zap.Int64("tableID", tblInfo.ID))
if e := infosync.ConfigureTiFlashPDForPartitions(false, &pi.Definitions, replicaInfo.Count, &replicaInfo.Labels); e != nil {
return errors.Trace(e)
}
// Partitions that in adding mid-state. They have high priorities, so we should set accordingly pd rules.
if e := infosync.ConfigureTiFlashPDForPartitions(true, &pi.AddingDefinitions, replicaInfo.Count, &replicaInfo.Labels); e != nil {
return errors.Trace(e)
}
} else {
logutil.BgLogger().Info("Set TiFlash replica pd rule", zap.Int64("tableID", tblInfo.ID))
if e := infosync.ConfigureTiFlashPDForTable(tblInfo.ID, replicaInfo.Count, &replicaInfo.Labels); e != nil {
return errors.Trace(e)
}
}
}

job := &model.Job{
SchemaID: schema.ID,
TableID: tb.Meta().ID,
Expand Down Expand Up @@ -4812,13 +4834,15 @@ func (d *ddl) AlterTableDropStatistics(ctx sessionctx.Context, ident ast.Ident,
func (d *ddl) UpdateTableReplicaInfo(ctx sessionctx.Context, physicalID int64, available bool) error {
is := d.infoCache.GetLatest()
tb, ok := is.TableByID(physicalID)

if !ok {
tb, _, _ = is.FindTableByPartitionID(physicalID)
if tb == nil {
return infoschema.ErrTableNotExists.GenWithStack("Table which ID = %d does not exist.", physicalID)
}
}
tbInfo := tb.Meta()

if tbInfo.TiFlashReplica == nil || (tbInfo.ID == physicalID && tbInfo.TiFlashReplica.Available == available) ||
(tbInfo.ID != physicalID && available == tbInfo.TiFlashReplica.IsPartitionAvailable(physicalID)) {
return nil
Expand All @@ -4837,6 +4861,7 @@ func (d *ddl) UpdateTableReplicaInfo(ctx sessionctx.Context, physicalID int64, a
BinlogInfo: &model.HistoryInfo{},
Args: []interface{}{available, physicalID},
}
// Will return when job is finished.
err := d.doDDLJob(ctx, job)
err = d.callHookOnChanged(err)
return errors.Trace(err)
Expand Down
Loading