Skip to content

Commit

Permalink
ddl: fix admin repair table will reload fail on the other node (#18285)…
Browse files Browse the repository at this point in the history
… (#18323)
  • Loading branch information
ti-srebot authored Jul 10, 2020
1 parent 3ac2d86 commit 05c65a9
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions infoschema/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (b *Builder) ApplyDiff(m *meta.Meta, diff *model.SchemaDiff) ([]int64, erro
}
var oldTableID, newTableID int64
switch diff.Type {
case model.ActionCreateTable, model.ActionCreateSequence, model.ActionRecoverTable, model.ActionRepairTable:
case model.ActionCreateTable, model.ActionCreateSequence, model.ActionRecoverTable:
newTableID = diff.TableID
case model.ActionDropTable, model.ActionDropView, model.ActionDropSequence:
oldTableID = diff.TableID
Expand All @@ -74,7 +74,12 @@ func (b *Builder) ApplyDiff(m *meta.Meta, diff *model.SchemaDiff) ([]int64, erro
// We try to reuse the old allocator, so the cached auto ID can be reused.
var allocs autoid.Allocators
if tableIDIsValid(oldTableID) {
if oldTableID == newTableID && diff.Type != model.ActionRenameTable {
if oldTableID == newTableID && diff.Type != model.ActionRenameTable &&
// For repairing table in TiDB cluster, given 2 normal node and 1 repair node.
// For normal node's information schema, repaired table is existed.
// For repair node's information schema, repaired table is filtered (couldn't find it in `is`).
// So here skip to reserve the allocators when repairing table.
diff.Type != model.ActionRepairTable {
oldAllocs, _ := b.is.AllocByID(oldTableID)
allocs = filterAllocators(diff, oldAllocs)
}
Expand Down

0 comments on commit 05c65a9

Please sign in to comment.