From 05c65a9a3f688144559b34217d33ff35e249fe08 Mon Sep 17 00:00:00 2001 From: ti-srebot <66930949+ti-srebot@users.noreply.github.com> Date: Fri, 10 Jul 2020 14:30:56 +0800 Subject: [PATCH] ddl: fix admin repair table will reload fail on the other node (#18285) (#18323) --- infoschema/builder.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/infoschema/builder.go b/infoschema/builder.go index 51c7ee6826ccf..1d2e36d3e8c91 100644 --- a/infoschema/builder.go +++ b/infoschema/builder.go @@ -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 @@ -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) }